removed useless assignment variables
backport r48265 without to using refinements
stubs are already sorted, so we don't have to resort

The stub specifications and the regular specifications are sorted in the
same way.  Since the list of full specifications is based on the list of
already sorted stub specifications, there is no need to sort the full
specs.
Merge pull request #1061 from rubygems/backport-r48265

backport r48265 without to using refinements
Merge pull request #1035 from hsbt/remove-useless-variables

Removed useless assignment variables
Merge pull request #1063 from tenderlove/resort

stubs are already sorted, so we don't have to resort
fix warning in stub specifications

if the name and version methods haven't been called, the instance
variables will not be initialized, and calling to_spec will warn. This
ensures that the data has actually been loaded before looping through
the loaded specs.
Skip pristine install for non-cached gem unknown at remote source

This prevents failure on trying to do a pristine installation for a
private gem that is not cached.
Fetch gem to proper cache dir when gem path is not gem home

This fixes the pristine installation error for a gem that is installed
to other GEM PATH than $GEM_HOME and the cache file for that gem is
missing.

Example scenario:

```
$ cat ~/.gemrc
---
:sources:
- https://rubygems.org/
gem: --no-ri --no-rdoc
gempath:
- /Users/tkareine/gem-repo

$ gem env
RubyGems Environment:
  ...
  - INSTALLATION DIRECTORY: /Users/tkareine/.gem/ruby/1.9.3
  ...
  - GEM PATHS:
     - /Users/tkareine/.gem/ruby/1.9.3
     - /Users/tkareine/gem-repo
  ...

$ gem install -i ~/gem-repo timecop
Fetching: timecop-0.7.1.gem (100%)
Successfully installed timecop-0.7.1
1 gem installed

$ rm gem-repo/cache/timecop-0.7.1.gem
```

Without the fix we get an error:

```
$ gem pristine timecop
Restoring gems to pristine condition...
Cached gem for timecop-0.7.1 not found, attempting to fetch...
Fetching: timecop-0.7.1.gem (100%)
ERROR:  While executing gem ... (Gem::InstallError)
    invalid gem: No such file or directory - /Users/tkareine/gem-repo/cache/timecop-0.7.1.gem
```

With the fix:

```
$ gem pristine timecop
Restoring gems to pristine condition...
Cached gem for timecop-0.7.1 not found, attempting to fetch...
Fetching: timecop-0.7.1.gem (100%)
Restored timecop-0.7.1
```
Skip pristine install for gems bundled with old Ruby

MRI Rubies older than 2.0.0 do not store bundled gem specification files
under `default` subdirectory, failing to be recognized as default gems
and thus be skipped from pristine installs by Rubygems.

We observe that old Ruby stores these gems with a regular pattern in
spec's summary field:

```
$ cat ~/.rubies/ruby-1.9.3-p551/lib/ruby/gems/1.9.1/specifications/bigdecimal-1.1.0.gemspec
Gem::Specification.new do |s|
  s.name = "bigdecimal"
  s.version = "1.1.0"
  s.summary = "This bigdecimal is bundled with Ruby"
  s.executables = []
end
```

We use this to detect bundled gems when using old Ruby. This allows us
to run pristine install on all gems without errors:

```
$ gem pristine --all
Restoring gems to pristine condition...
Skipped bigdecimal-1.1.0, it is bundled with Ruby < 2.0.0
Skipped io-console-0.3, it is bundled with Ruby < 2.0.0
Skipped json-1.5.5, it is bundled with Ruby < 2.0.0
...
```

It's unclear to me if this detection should be combined to
`Gem::BasicSpecification#default_gem?` and made available to other
commands (such as `gem clean`).