rubygems-update 1.7.2 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rubygems-update might be problematic. Click here for more details.

Files changed (104) hide show
  1. data.tar.gz.sig +0 -0
  2. data/.autotest +5 -1
  3. data/History.txt +101 -4
  4. data/LICENSE.txt +42 -37
  5. data/MIT.txt +20 -0
  6. data/Manifest.txt +5 -4
  7. data/Rakefile +6 -7
  8. data/lib/rubygems.rb +175 -278
  9. data/lib/rubygems/builder.rb +7 -6
  10. data/lib/rubygems/command_manager.rb +16 -2
  11. data/lib/rubygems/commands/build_command.rb +13 -11
  12. data/lib/rubygems/commands/cert_command.rb +1 -1
  13. data/lib/rubygems/commands/cleanup_command.rb +10 -19
  14. data/lib/rubygems/commands/contents_command.rb +5 -5
  15. data/lib/rubygems/commands/dependency_command.rb +17 -40
  16. data/lib/rubygems/commands/fetch_command.rb +1 -1
  17. data/lib/rubygems/commands/install_command.rb +2 -1
  18. data/lib/rubygems/commands/lock_command.rb +4 -4
  19. data/lib/rubygems/commands/outdated_command.rb +18 -6
  20. data/lib/rubygems/commands/pristine_command.rb +25 -15
  21. data/lib/rubygems/commands/query_command.rb +9 -6
  22. data/lib/rubygems/commands/setup_command.rb +1 -1
  23. data/lib/rubygems/commands/specification_command.rb +8 -23
  24. data/lib/rubygems/commands/stale_command.rb +2 -1
  25. data/lib/rubygems/commands/unpack_command.rb +7 -5
  26. data/lib/rubygems/commands/update_command.rb +2 -4
  27. data/lib/rubygems/commands/which_command.rb +5 -9
  28. data/lib/rubygems/config_file.rb +9 -7
  29. data/lib/rubygems/custom_require.rb +6 -4
  30. data/lib/rubygems/defaults.rb +30 -14
  31. data/lib/rubygems/dependency.rb +44 -1
  32. data/lib/rubygems/dependency_installer.rb +37 -41
  33. data/lib/rubygems/dependency_list.rb +20 -9
  34. data/lib/rubygems/deprecate.rb +3 -3
  35. data/lib/rubygems/doc_manager.rb +10 -11
  36. data/lib/rubygems/ext/rake_builder.rb +1 -1
  37. data/lib/rubygems/gem_path_searcher.rb +19 -4
  38. data/lib/rubygems/gem_runner.rb +1 -1
  39. data/lib/rubygems/indexer.rb +117 -123
  40. data/lib/rubygems/installer.rb +101 -94
  41. data/lib/rubygems/installer_test_case.rb +28 -30
  42. data/lib/rubygems/local_remote_options.rb +1 -1
  43. data/lib/rubygems/mock_gem_ui.rb +10 -3
  44. data/lib/rubygems/package.rb +0 -26
  45. data/lib/rubygems/package/tar_input.rb +5 -6
  46. data/lib/rubygems/package_task.rb +1 -1
  47. data/lib/rubygems/path_support.rb +72 -0
  48. data/lib/rubygems/platform.rb +12 -2
  49. data/lib/rubygems/remote_fetcher.rb +7 -6
  50. data/lib/rubygems/requirement.rb +3 -0
  51. data/lib/rubygems/security.rb +1 -1
  52. data/lib/rubygems/server.rb +67 -67
  53. data/lib/rubygems/source_index.rb +58 -29
  54. data/lib/rubygems/spec_fetcher.rb +5 -1
  55. data/lib/rubygems/specification.rb +1422 -877
  56. data/lib/rubygems/test_case.rb +114 -64
  57. data/lib/rubygems/test_utilities.rb +4 -3
  58. data/lib/rubygems/text.rb +1 -1
  59. data/lib/rubygems/uninstaller.rb +37 -44
  60. data/test/rubygems/test_gem.rb +131 -102
  61. data/test/rubygems/test_gem_builder.rb +18 -1
  62. data/test/rubygems/test_gem_command_manager.rb +2 -0
  63. data/test/rubygems/test_gem_commands_build_command.rb +31 -3
  64. data/test/rubygems/test_gem_commands_cleanup_command.rb +51 -0
  65. data/test/rubygems/test_gem_commands_dependency_command.rb +1 -10
  66. data/test/rubygems/test_gem_commands_fetch_command.rb +5 -4
  67. data/test/rubygems/test_gem_commands_help_command.rb +58 -0
  68. data/test/rubygems/test_gem_commands_install_command.rb +25 -24
  69. data/test/rubygems/test_gem_commands_list_command.rb +1 -4
  70. data/test/rubygems/test_gem_commands_outdated_command.rb +10 -9
  71. data/test/rubygems/test_gem_commands_pristine_command.rb +63 -22
  72. data/test/rubygems/test_gem_commands_push_command.rb +1 -1
  73. data/test/rubygems/test_gem_commands_query_command.rb +15 -82
  74. data/test/rubygems/test_gem_commands_sources_command.rb +8 -9
  75. data/test/rubygems/test_gem_commands_specification_command.rb +10 -6
  76. data/test/rubygems/test_gem_commands_stale_command.rb +4 -4
  77. data/test/rubygems/test_gem_commands_unpack_command.rb +20 -21
  78. data/test/rubygems/test_gem_commands_update_command.rb +19 -23
  79. data/test/rubygems/test_gem_commands_which_command.rb +7 -4
  80. data/test/rubygems/test_gem_dependency.rb +14 -8
  81. data/test/rubygems/test_gem_dependency_installer.rb +87 -33
  82. data/test/rubygems/test_gem_dependency_list.rb +7 -3
  83. data/test/rubygems/test_gem_doc_manager.rb +3 -3
  84. data/test/rubygems/test_gem_format.rb +1 -1
  85. data/test/rubygems/test_gem_gem_path_searcher.rb +45 -29
  86. data/test/rubygems/test_gem_indexer.rb +48 -47
  87. data/test/rubygems/test_gem_install_update_options.rb +6 -5
  88. data/test/rubygems/test_gem_installer.rb +61 -37
  89. data/test/rubygems/test_gem_path_support.rb +58 -0
  90. data/test/rubygems/test_gem_platform.rb +5 -5
  91. data/test/rubygems/test_gem_remote_fetcher.rb +18 -21
  92. data/test/rubygems/test_gem_server.rb +23 -15
  93. data/test/rubygems/test_gem_source_index.rb +165 -127
  94. data/test/rubygems/test_gem_spec_fetcher.rb +42 -49
  95. data/test/rubygems/test_gem_specification.rb +104 -74
  96. data/test/rubygems/test_gem_text.rb +15 -0
  97. data/test/rubygems/test_gem_uninstaller.rb +15 -26
  98. data/test/rubygems/test_kernel.rb +1 -2
  99. metadata +64 -14
  100. metadata.gz.sig +0 -0
  101. data/GPL.txt +0 -340
  102. data/pkgs/sources/lib/sources.rb +0 -3
  103. data/pkgs/sources/sources.gemspec +0 -14
  104. data/test/rubygems/functional.rb +0 -92
@@ -38,7 +38,7 @@ class Gem::Builder
38
38
  @signer = sign
39
39
  write_package
40
40
  say success if Gem.configuration.verbose
41
- @spec.file_name
41
+ File.basename @spec.cache_file
42
42
  end
43
43
 
44
44
  def success
@@ -46,7 +46,7 @@ class Gem::Builder
46
46
  Successfully built RubyGem
47
47
  Name: #{@spec.name}
48
48
  Version: #{@spec.version}
49
- File: #{@spec.file_name}
49
+ File: #{File.basename @spec.cache_file}
50
50
  EOM
51
51
  end
52
52
 
@@ -73,16 +73,17 @@ EOM
73
73
  end
74
74
 
75
75
  def write_package
76
- open @spec.file_name, 'wb' do |gem_io|
76
+ file_name = File.basename @spec.cache_file
77
+ open file_name, 'wb' do |gem_io|
77
78
  Gem::Package.open gem_io, 'w', @signer do |pkg|
78
79
  yaml = @spec.to_yaml
79
80
  pkg.metadata = yaml
80
81
 
81
82
  @spec.files.each do |file|
82
- next if File.directory? file
83
- next if file == @spec.file_name # Don't add gem onto itself
83
+ next if File.directory?(file)
84
+ next if file == file_name # Don't add gem onto itself
84
85
 
85
- stat = File.stat file
86
+ stat = File.stat(file)
86
87
  mode = stat.mode & 0777
87
88
  size = stat.size
88
89
 
@@ -37,6 +37,13 @@ class Gem::CommandManager
37
37
  @command_manager ||= new
38
38
  end
39
39
 
40
+ ##
41
+ # Reset the authoritative instance of the command manager.
42
+
43
+ def self.reset
44
+ @command_manager = nil
45
+ end
46
+
40
47
  ##
41
48
  # Register all the subcommands supported by the gem command.
42
49
 
@@ -80,6 +87,13 @@ class Gem::CommandManager
80
87
  @commands[command] = false
81
88
  end
82
89
 
90
+ ##
91
+ # Unregister the Symbol +command+ as a gem command.
92
+
93
+ def unregister_command(command)
94
+ @commands.delete command
95
+ end
96
+
83
97
  ##
84
98
  # Return the registered command from the command name.
85
99
 
@@ -160,7 +174,7 @@ class Gem::CommandManager
160
174
  retried = false
161
175
 
162
176
  begin
163
- commands.const_get const_name
177
+ commands.const_get(const_name).new
164
178
  rescue NameError
165
179
  raise if retried
166
180
 
@@ -173,7 +187,7 @@ class Gem::CommandManager
173
187
  Gem.configuration.backtrace
174
188
  end
175
189
  retry
176
- end.new
190
+ end
177
191
  end
178
192
 
179
193
  end
@@ -17,32 +17,34 @@ class Gem::Commands::BuildCommand < Gem::Command
17
17
 
18
18
  def execute
19
19
  gemspec = get_one_gem_name
20
- if File.exist?(gemspec)
21
- specs = load_gemspecs(gemspec)
22
- specs.each do |spec|
20
+
21
+ if File.exist? gemspec
22
+ spec = load_gemspec gemspec
23
+
24
+ if spec then
23
25
  Gem::Builder.new(spec).build
26
+ else
27
+ alert_error "Error loading gemspec. Aborting."
28
+ terminate_interaction 1
24
29
  end
25
30
  else
26
31
  alert_error "Gemspec file not found: #{gemspec}"
32
+ terminate_interaction 1
27
33
  end
28
34
  end
29
35
 
30
- def load_gemspecs(filename)
36
+ def load_gemspec filename
31
37
  if yaml?(filename)
32
- result = []
33
38
  open(filename) do |f|
34
39
  begin
35
- while not f.eof? and spec = Gem::Specification.from_yaml(f)
36
- result << spec
37
- end
40
+ Gem::Specification.from_yaml(f)
38
41
  rescue Gem::EndOfYAMLException
39
- # OK
42
+ nil
40
43
  end
41
44
  end
42
45
  else
43
- result = [Gem::Specification.load(filename)]
46
+ Gem::Specification.load(filename) # can return nil
44
47
  end
45
- result
46
48
  end
47
49
 
48
50
  def yaml?(filename)
@@ -50,7 +50,7 @@ class Gem::Commands::CertCommand < Gem::Command
50
50
  'Build private key and self-signed',
51
51
  'certificate for EMAIL_ADDR.') do |value, options|
52
52
  vals = Gem::Security.build_self_signed_cert(value)
53
- File.chmod 0600, vals[:key_path]
53
+ FileUtils.chmod 0600, vals[:key_path]
54
54
  say "Public Cert: #{vals[:cert_path]}"
55
55
  say "Private Key: #{vals[:key_path]}"
56
56
  say "Don't forget to move the key file to somewhere private..."
@@ -1,5 +1,4 @@
1
1
  require 'rubygems/command'
2
- require 'rubygems/source_index'
3
2
  require 'rubygems/dependency_list'
4
3
  require 'rubygems/uninstaller'
5
4
 
@@ -38,28 +37,20 @@ installed elsewhere in GEM_PATH the cleanup command won't touch it.
38
37
  say "Cleaning up installed gems..."
39
38
  primary_gems = {}
40
39
 
41
- Gem.source_index.each do |name, spec|
40
+ Gem::Specification.each do |spec|
42
41
  if primary_gems[spec.name].nil? or
43
42
  primary_gems[spec.name].version < spec.version then
44
43
  primary_gems[spec.name] = spec
45
44
  end
46
45
  end
47
46
 
48
- gems_to_cleanup = []
49
-
50
- unless options[:args].empty? then
51
- options[:args].each do |gem_name|
52
- dep = Gem::Dependency.new gem_name, Gem::Requirement.default
53
- specs = Gem.source_index.search dep
54
- specs.each do |spec|
55
- gems_to_cleanup << spec
56
- end
57
- end
58
- else
59
- Gem.source_index.each do |name, spec|
60
- gems_to_cleanup << spec
61
- end
62
- end
47
+ gems_to_cleanup = unless options[:args].empty? then
48
+ options[:args].map do |gem_name|
49
+ Gem::Specification.find_all_by_name gem_name
50
+ end.flatten
51
+ else
52
+ Gem::Specification.to_a
53
+ end
63
54
 
64
55
  gems_to_cleanup = gems_to_cleanup.select { |spec|
65
56
  primary_gems[spec.name].version != spec.version
@@ -83,8 +74,8 @@ installed elsewhere in GEM_PATH the cleanup command won't touch it.
83
74
  :version => "= #{spec.version}",
84
75
  }
85
76
 
86
- if Gem.user_dir == spec.installation_path then
87
- uninstall_options[:install_dir] = spec.installation_path
77
+ if Gem.user_dir == spec.base_dir then
78
+ uninstall_options[:install_dir] = spec.base_dir
88
79
  end
89
80
 
90
81
  uninstaller = Gem::Uninstaller.new spec.name, uninstall_options
@@ -52,22 +52,22 @@ class Gem::Commands::ContentsCommand < Gem::Command
52
52
  end.flatten
53
53
 
54
54
  path_kind = if spec_dirs.empty? then
55
- spec_dirs = Gem::SourceIndex.installed_spec_directories
55
+ spec_dirs = Gem::Specification.dirs
56
56
  "default gem paths"
57
57
  else
58
58
  "specified path"
59
59
  end
60
60
 
61
- si = Gem::SourceIndex.new spec_dirs
62
-
63
61
  gem_names = if options[:all] then
64
- si.map { |_, spec| spec.name }
62
+ Gem::Specification.map(&:name)
65
63
  else
66
64
  get_all_gem_names
67
65
  end
68
66
 
69
67
  gem_names.each do |name|
70
- spec = si.find_name(name, version).last
68
+ # HACK: find_by_name fails for some reason... ARGH
69
+ # How many places must we embed our resolve logic?
70
+ spec = Gem::Specification.find_all_by_name(name, version).last
71
71
 
72
72
  unless spec then
73
73
  say "Unable to find gem '#{name}' in #{path_kind}"
@@ -44,11 +44,6 @@ class Gem::Commands::DependencyCommand < Gem::Command
44
44
 
45
45
  def execute
46
46
  options[:args] << '' if options[:args].empty?
47
- specs = {}
48
-
49
- source_indexes = Hash.new do |h, source_uri|
50
- h[source_uri] = Gem::SourceIndex.new
51
- end
52
47
 
53
48
  pattern = if options[:args].length == 1 and
54
49
  options[:args].first =~ /\A\/(.*)\/(i)?\z/m then
@@ -58,7 +53,10 @@ class Gem::Commands::DependencyCommand < Gem::Command
58
53
  /\A#{Regexp.union(*options[:args])}/
59
54
  end
60
55
 
61
- dependency = Gem::Dependency.new pattern, options[:version]
56
+ # TODO: deprecate for real damnit
57
+ dependency = Deprecate.skip_during {
58
+ Gem::Dependency.new pattern, options[:version]
59
+ }
62
60
  dependency.prerelease = options[:prerelease]
63
61
 
64
62
  if options[:reverse_dependencies] and remote? and not local? then
@@ -66,26 +64,23 @@ class Gem::Commands::DependencyCommand < Gem::Command
66
64
  terminate_interaction 1
67
65
  end
68
66
 
69
- if local? then
70
- Gem.source_index.search(dependency).each do |spec|
71
- source_indexes[:local].add_spec spec
72
- end
73
- end
67
+ specs = []
68
+
69
+ specs.concat dependency.matching_specs if local?
74
70
 
75
71
  if remote? and not options[:reverse_dependencies] then
76
72
  fetcher = Gem::SpecFetcher.fetcher
77
73
 
74
+ # REFACTOR: fetcher.find_specs_matching => specs
78
75
  specs_and_sources = fetcher.find_matching(dependency, false, true,
79
76
  dependency.prerelease?)
80
77
 
81
- specs_and_sources.each do |spec_tuple, source_uri|
82
- spec = fetcher.fetch_spec spec_tuple, URI.parse(source_uri)
83
-
84
- source_indexes[source_uri].add_spec spec
85
- end
78
+ specs.concat specs_and_sources.map { |spec_tuple, source_uri|
79
+ fetcher.fetch_spec spec_tuple, URI.parse(source_uri)
80
+ }
86
81
  end
87
82
 
88
- if source_indexes.empty? then
83
+ if specs.empty? then
89
84
  patterns = options[:args].join ','
90
85
  say "No gems found matching #{patterns} (#{options[:version]})" if
91
86
  Gem.configuration.verbose
@@ -93,24 +88,18 @@ class Gem::Commands::DependencyCommand < Gem::Command
93
88
  terminate_interaction 1
94
89
  end
95
90
 
96
- specs = {}
97
-
98
- source_indexes.values.each do |source_index|
99
- source_index.gems.each do |name, spec|
100
- specs[spec.full_name] = [source_index, spec]
101
- end
102
- end
91
+ specs = specs.uniq.sort
103
92
 
104
93
  reverse = Hash.new { |h, k| h[k] = [] }
105
94
 
106
95
  if options[:reverse_dependencies] then
107
- specs.values.each do |_, spec|
96
+ specs.each do |spec|
108
97
  reverse[spec.full_name] = find_reverse_dependencies spec
109
98
  end
110
99
  end
111
100
 
112
101
  if options[:pipe_format] then
113
- specs.values.sort_by { |_, spec| spec }.each do |_, spec|
102
+ specs.each do |spec|
114
103
  unless spec.dependencies.empty?
115
104
  spec.dependencies.sort_by { |dep| dep.name }.each do |dep|
116
105
  say "#{dep.name} --version '#{dep.requirement}'"
@@ -120,7 +109,7 @@ class Gem::Commands::DependencyCommand < Gem::Command
120
109
  else
121
110
  response = ''
122
111
 
123
- specs.values.sort_by { |_, spec| spec }.each do |_, spec|
112
+ specs.each do |spec|
124
113
  response << print_dependencies(spec)
125
114
  unless reverse[spec.full_name].empty? then
126
115
  response << " Used by\n"
@@ -152,7 +141,7 @@ class Gem::Commands::DependencyCommand < Gem::Command
152
141
  def find_reverse_dependencies(spec)
153
142
  result = []
154
143
 
155
- Gem.source_index.each do |name, sp|
144
+ Gem::Specification.each do |sp|
156
145
  sp.dependencies.each do |dep|
157
146
  dep = Gem::Dependency.new(*dep) unless Gem::Dependency === dep
158
147
 
@@ -166,17 +155,5 @@ class Gem::Commands::DependencyCommand < Gem::Command
166
155
  result
167
156
  end
168
157
 
169
- def find_gems(name, source_index)
170
- specs = {}
171
-
172
- spec_list = source_index.search name, options[:version]
173
-
174
- spec_list.each do |spec|
175
- specs[spec.full_name] = [source_index, spec]
176
- end
177
-
178
- specs
179
- end
180
-
181
158
  end
182
159
 
@@ -59,7 +59,7 @@ class Gem::Commands::FetchCommand < Gem::Command
59
59
  end
60
60
 
61
61
  path = Gem::RemoteFetcher.fetcher.download spec, source_uri
62
- FileUtils.mv path, spec.file_name
62
+ FileUtils.mv path, File.basename(spec.cache_file)
63
63
 
64
64
  say "Downloaded #{spec.full_name}"
65
65
  end
@@ -114,7 +114,8 @@ to write the specification by hand. For example:
114
114
 
115
115
  get_all_gem_names.each do |gem_name|
116
116
  begin
117
- next if options[:conservative] && Gem.available?(gem_name, options[:version])
117
+ next if options[:conservative] and
118
+ not Gem::Dependency.new(gem_name, options[:version]).matching_specs.empty?
118
119
 
119
120
  inst = Gem::DependencyInstaller.new options
120
121
  inst.install gem_name, options[:version]
@@ -87,7 +87,7 @@ lock it down to the exact version.
87
87
 
88
88
  spec.runtime_dependencies.each do |dep|
89
89
  next if locked[dep.name]
90
- candidates = Gem.source_index.search dep
90
+ candidates = dep.matching_specs
91
91
 
92
92
  if candidates.empty? then
93
93
  complain "Unable to satisfy '#{dep}' from currently installed gems"
@@ -99,11 +99,11 @@ lock it down to the exact version.
99
99
  end
100
100
 
101
101
  def spec_path(gem_full_name)
102
- gemspecs = Gem.path.map do |path|
102
+ gemspecs = Gem.path.map { |path|
103
103
  File.join path, "specifications", "#{gem_full_name}.gemspec"
104
- end
104
+ }
105
105
 
106
- gemspecs.find { |gemspec| File.exist? gemspec }
106
+ gemspecs.find { |path| File.exist? path }
107
107
  end
108
108
 
109
109
  end
@@ -16,11 +16,8 @@ class Gem::Commands::OutdatedCommand < Gem::Command
16
16
  end
17
17
 
18
18
  def execute
19
- # FIX: this should be able to be Gem.source_index but our test fails :(
20
- locals = Gem::SourceIndex.new Gem::SourceIndex.installed_spec_directories
21
-
22
- locals.outdated.sort.each do |name|
23
- local = locals.find_name(name).last
19
+ outdated.sort.each do |name|
20
+ local = Gem::Specification.find_all_by_name(name).max
24
21
  dep = Gem::Dependency.new local.name, ">= #{local.version}"
25
22
  remotes = Gem::SpecFetcher.fetcher.fetch dep
26
23
 
@@ -31,5 +28,20 @@ class Gem::Commands::OutdatedCommand < Gem::Command
31
28
  end
32
29
  end
33
30
 
34
- end
31
+ def outdated
32
+ outdateds = []
33
+
34
+ fetcher = Gem::SpecFetcher.fetcher
35
+
36
+ Gem::Specification.latest_specs.each do |local|
37
+ dependency = Gem::Dependency.new local.name, ">= #{local.version}"
38
+ remotes = fetcher.find_matching dependency
39
+ remotes = remotes.map { |(_, version, _), _| version }
40
+ latest = remotes.sort.last
35
41
 
42
+ outdateds << local.name if latest and local.version < latest
43
+ end
44
+
45
+ outdateds
46
+ end
47
+ end
@@ -10,7 +10,8 @@ class Gem::Commands::PristineCommand < Gem::Command
10
10
  def initialize
11
11
  super 'pristine',
12
12
  'Restores installed gems to pristine condition from files located in the gem cache',
13
- :version => Gem::Requirement.default
13
+ :version => Gem::Requirement.default, :extensions => true,
14
+ :all => false
14
15
 
15
16
  add_option('--all',
16
17
  'Restore all installed gems to pristine',
@@ -18,6 +19,11 @@ class Gem::Commands::PristineCommand < Gem::Command
18
19
  options[:all] = value
19
20
  end
20
21
 
22
+ add_option('--[no-]extensions',
23
+ 'Restore gems with extensions') do |value, options|
24
+ options[:extensions] = value
25
+ end
26
+
21
27
  add_version_option('restore to', 'pristine condition')
22
28
  end
23
29
 
@@ -26,7 +32,7 @@ class Gem::Commands::PristineCommand < Gem::Command
26
32
  end
27
33
 
28
34
  def defaults_str # :nodoc:
29
- "--all"
35
+ "--all --extensions"
30
36
  end
31
37
 
32
38
  def description # :nodoc:
@@ -40,6 +46,9 @@ for the gem are regenerated.
40
46
 
41
47
  If the cached gem cannot be found, you will need to use `gem install` to
42
48
  revert the gem.
49
+
50
+ If --no-extensions is provided pristine will not attempt to restore gems with
51
+ extensions.
43
52
  EOF
44
53
  end
45
54
 
@@ -48,20 +57,17 @@ revert the gem.
48
57
  end
49
58
 
50
59
  def execute
51
- gem_name = nil
52
-
53
60
  specs = if options[:all] then
54
- Gem.source_index.map do |name, spec|
55
- spec
56
- end
61
+ Gem::Specification.map
57
62
  else
58
- gem_name = get_one_gem_name
59
- Gem.source_index.find_name(gem_name, options[:version])
63
+ get_all_gem_names.map do |gem_name|
64
+ Gem::Specification.find_all_by_name gem_name, options[:version]
65
+ end.flatten
60
66
  end
61
67
 
62
- if specs.empty? then
68
+ if specs.to_a.empty? then
63
69
  raise Gem::Exception,
64
- "Failed to find gem #{gem_name} #{options[:version]}"
70
+ "Failed to find gems #{options[:args]} #{options[:version]}"
65
71
  end
66
72
 
67
73
  install_dir = Gem.dir # TODO use installer option
@@ -69,18 +75,22 @@ revert the gem.
69
75
  raise Gem::FilePermissionError.new(install_dir) unless
70
76
  File.writable?(install_dir)
71
77
 
72
- say "Restoring gem(s) to pristine condition..."
78
+ say "Restoring gems to pristine condition..."
73
79
 
74
80
  specs.each do |spec|
75
- gem = spec.cache_gem
81
+ unless spec.extensions.empty? or options[:extensions] then
82
+ say "Skipped #{spec.full_name}, it needs to compile an extension"
83
+ next
84
+ end
85
+
86
+ gem = spec.cache_file
76
87
 
77
- if gem.nil? then
88
+ unless File.exist? gem then
78
89
  require 'rubygems/remote_fetcher'
79
90
 
80
91
  say "Cached gem for #{spec.full_name} not found, attempting to fetch..."
81
92
  dep = Gem::Dependency.new spec.name, spec.version
82
93
  Gem::RemoteFetcher.fetcher.download_to_cache dep
83
- gem = spec.cache_gem
84
94
  end
85
95
 
86
96
  # TODO use installer options