rubygems-update 2.4.8 → 2.5.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 (125) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/CODE_OF_CONDUCT.md +40 -0
  5. data/CVE-2015-3900.txt +40 -0
  6. data/History.txt +173 -2
  7. data/Manifest.txt +14 -1
  8. data/Rakefile +36 -1
  9. data/lib/rubygems.rb +32 -14
  10. data/lib/rubygems/basic_specification.rb +31 -9
  11. data/lib/rubygems/commands/dependency_command.rb +25 -15
  12. data/lib/rubygems/commands/environment_command.rb +2 -0
  13. data/lib/rubygems/commands/help_command.rb +0 -10
  14. data/lib/rubygems/commands/install_command.rb +1 -1
  15. data/lib/rubygems/commands/list_command.rb +1 -1
  16. data/lib/rubygems/commands/pristine_command.rb +11 -1
  17. data/lib/rubygems/commands/query_command.rb +1 -1
  18. data/lib/rubygems/commands/sources_command.rb +1 -1
  19. data/lib/rubygems/commands/update_command.rb +2 -2
  20. data/lib/rubygems/config_file.rb +4 -4
  21. data/lib/rubygems/core_ext/kernel_require.rb +2 -2
  22. data/lib/rubygems/dependency.rb +9 -6
  23. data/lib/rubygems/dependency_list.rb +3 -0
  24. data/lib/rubygems/ext/builder.rb +2 -0
  25. data/lib/rubygems/ext/ext_conf_builder.rb +6 -1
  26. data/lib/rubygems/indexer.rb +26 -91
  27. data/lib/rubygems/installer.rb +58 -26
  28. data/lib/rubygems/installer_test_case.rb +2 -2
  29. data/lib/rubygems/package.rb +18 -6
  30. data/lib/rubygems/package/old.rb +2 -2
  31. data/lib/rubygems/package/tar_reader/entry.rb +7 -1
  32. data/lib/rubygems/package/tar_test_case.rb +12 -3
  33. data/lib/rubygems/package/tar_writer.rb +19 -1
  34. data/lib/rubygems/platform.rb +3 -2
  35. data/lib/rubygems/rdoc.rb +1 -2
  36. data/lib/rubygems/remote_fetcher.rb +25 -6
  37. data/lib/rubygems/request/connection_pools.rb +8 -4
  38. data/lib/rubygems/request_set.rb +3 -4
  39. data/lib/rubygems/request_set/gem_dependency_api.rb +2 -2
  40. data/lib/rubygems/request_set/lockfile.rb +1 -1
  41. data/lib/rubygems/request_set/lockfile/parser.rb +54 -43
  42. data/lib/rubygems/request_set/lockfile/tokenizer.rb +16 -13
  43. data/lib/rubygems/resolver.rb +47 -242
  44. data/lib/rubygems/resolver/activation_request.rb +2 -1
  45. data/lib/rubygems/resolver/conflict.rb +0 -1
  46. data/lib/rubygems/resolver/dependency_request.rb +4 -1
  47. data/lib/rubygems/resolver/git_specification.rb +1 -2
  48. data/lib/rubygems/resolver/molinillo.rb +1 -0
  49. data/lib/rubygems/resolver/molinillo/lib/molinillo.rb +5 -0
  50. data/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph.rb +266 -0
  51. data/lib/rubygems/resolver/molinillo/lib/molinillo/errors.rb +69 -0
  52. data/lib/rubygems/resolver/molinillo/lib/molinillo/gem_metadata.rb +3 -0
  53. data/lib/rubygems/resolver/molinillo/lib/molinillo/modules/specification_provider.rb +99 -0
  54. data/lib/rubygems/resolver/molinillo/lib/molinillo/modules/ui.rb +63 -0
  55. data/lib/rubygems/resolver/molinillo/lib/molinillo/resolution.rb +430 -0
  56. data/lib/rubygems/resolver/molinillo/lib/molinillo/resolver.rb +43 -0
  57. data/lib/rubygems/resolver/molinillo/lib/molinillo/state.rb +51 -0
  58. data/lib/rubygems/resolver/specification.rb +1 -1
  59. data/lib/rubygems/specification.rb +256 -86
  60. data/lib/rubygems/stub_specification.rb +37 -29
  61. data/lib/rubygems/test_case.rb +65 -28
  62. data/lib/rubygems/test_utilities.rb +18 -18
  63. data/lib/rubygems/text.rb +0 -2
  64. data/lib/rubygems/uninstaller.rb +1 -1
  65. data/lib/rubygems/util.rb +4 -4
  66. data/lib/rubygems/util/licenses.rb +309 -0
  67. data/lib/rubygems/util/list.rb +9 -21
  68. data/lib/rubygems/version.rb +24 -14
  69. data/test/rubygems/simple_gem.rb +1 -1
  70. data/test/rubygems/test_config.rb +10 -1
  71. data/test/rubygems/test_gem.rb +58 -11
  72. data/test/rubygems/test_gem_available_set.rb +2 -1
  73. data/test/rubygems/test_gem_commands_cleanup_command.rb +6 -5
  74. data/test/rubygems/test_gem_commands_dependency_command.rb +9 -1
  75. data/test/rubygems/test_gem_commands_install_command.rb +17 -28
  76. data/test/rubygems/test_gem_commands_mirror.rb +0 -13
  77. data/test/rubygems/test_gem_commands_outdated_command.rb +2 -3
  78. data/test/rubygems/test_gem_commands_pristine_command.rb +33 -5
  79. data/test/rubygems/test_gem_commands_query_command.rb +123 -158
  80. data/test/rubygems/test_gem_commands_server_command.rb +2 -2
  81. data/test/rubygems/test_gem_commands_specification_command.rb +4 -4
  82. data/test/rubygems/test_gem_commands_stale_command.rb +2 -0
  83. data/test/rubygems/test_gem_commands_uninstall_command.rb +5 -4
  84. data/test/rubygems/test_gem_commands_unpack_command.rb +4 -6
  85. data/test/rubygems/test_gem_commands_update_command.rb +22 -52
  86. data/test/rubygems/test_gem_commands_which_command.rb +1 -0
  87. data/test/rubygems/test_gem_config_file.rb +1 -1
  88. data/test/rubygems/test_gem_dependency.rb +7 -3
  89. data/test/rubygems/test_gem_dependency_installer.rb +5 -5
  90. data/test/rubygems/test_gem_doctor.rb +1 -1
  91. data/test/rubygems/test_gem_ext_builder.rb +2 -0
  92. data/test/rubygems/test_gem_ext_configure_builder.rb +8 -4
  93. data/test/rubygems/test_gem_ext_ext_conf_builder.rb +25 -21
  94. data/test/rubygems/test_gem_indexer.rb +4 -4
  95. data/test/rubygems/test_gem_install_update_options.rb +2 -2
  96. data/test/rubygems/test_gem_installer.rb +32 -26
  97. data/test/rubygems/test_gem_package.rb +46 -1
  98. data/test/rubygems/test_gem_package_tar_reader_entry.rb +8 -1
  99. data/test/rubygems/test_gem_package_tar_writer.rb +10 -1
  100. data/test/rubygems/test_gem_package_task.rb +5 -2
  101. data/test/rubygems/test_gem_platform.rb +11 -0
  102. data/test/rubygems/test_gem_remote_fetcher.rb +64 -3
  103. data/test/rubygems/test_gem_request.rb +1 -1
  104. data/test/rubygems/test_gem_request_connection_pools.rb +10 -1
  105. data/test/rubygems/test_gem_request_set.rb +5 -8
  106. data/test/rubygems/test_gem_request_set_lockfile.rb +2 -4
  107. data/test/rubygems/test_gem_request_set_lockfile_tokenizer.rb +1 -1
  108. data/test/rubygems/test_gem_resolver.rb +12 -31
  109. data/test/rubygems/test_gem_resolver_git_specification.rb +1 -0
  110. data/test/rubygems/test_gem_resolver_installer_set.rb +7 -11
  111. data/test/rubygems/test_gem_resolver_lock_specification.rb +3 -2
  112. data/test/rubygems/test_gem_security_trust_dir.rb +2 -0
  113. data/test/rubygems/test_gem_server.rb +4 -0
  114. data/test/rubygems/test_gem_specification.rb +344 -61
  115. data/test/rubygems/test_gem_stream_ui.rb +6 -6
  116. data/test/rubygems/test_gem_stub_specification.rb +21 -6
  117. data/test/rubygems/test_gem_text.rb +2 -0
  118. data/test/rubygems/test_gem_uninstaller.rb +2 -1
  119. data/test/rubygems/test_gem_util.rb +8 -0
  120. data/test/rubygems/test_require.rb +156 -125
  121. data/util/generate_spdx_license_list.rb +21 -0
  122. data/util/update_bundled_ca_certificates.rb +2 -1
  123. metadata +42 -6
  124. metadata.gz.sig +0 -0
  125. data/lib/rubygems/util/stringio.rb +0 -34
@@ -22,13 +22,17 @@ class Gem::BasicSpecification
22
22
  ##
23
23
  # The path this gemspec was loaded from. This attribute is not persisted.
24
24
 
25
- attr_reader :loaded_from
25
+ attr_accessor :loaded_from
26
26
 
27
27
  ##
28
28
  # Allows correct activation of git: and path: gems.
29
29
 
30
30
  attr_writer :full_gem_path # :nodoc:
31
31
 
32
+ def initialize
33
+ internal_init
34
+ end
35
+
32
36
  def self.default_specifications_dir
33
37
  File.join(Gem.default_dir, "specifications", "default")
34
38
  end
@@ -141,7 +145,7 @@ class Gem::BasicSpecification
141
145
  @full_require_paths ||=
142
146
  begin
143
147
  full_paths = raw_require_paths.map do |path|
144
- File.join full_gem_path, path
148
+ File.join full_gem_path, path.untaint
145
149
  end
146
150
 
147
151
  full_paths << extension_dir unless @extensions.nil? || @extensions.empty?
@@ -189,13 +193,7 @@ class Gem::BasicSpecification
189
193
  @gems_dir ||= File.join(loaded_from && base_dir || Gem.dir, "gems")
190
194
  end
191
195
 
192
- ##
193
- # Set the path the Specification was loaded from. +path+ is converted to a
194
- # String.
195
-
196
- def loaded_from= path
197
- @loaded_from = path && path.to_s
198
-
196
+ def internal_init # :nodoc:
199
197
  @extension_dir = nil
200
198
  @extensions_dir = nil
201
199
  @full_gem_path = nil
@@ -263,6 +261,30 @@ class Gem::BasicSpecification
263
261
  paths.uniq
264
262
  end
265
263
 
264
+ ##
265
+ # Return all files in this gem that match for +glob+.
266
+
267
+ def matches_for_glob glob # TODO: rename?
268
+ # TODO: do we need these?? Kill it
269
+ glob = File.join(self.lib_dirs_glob, glob)
270
+
271
+ Dir[glob].map { |f| f.untaint } # FIX our tests are broken, run w/ SAFE=1
272
+ end
273
+
274
+ ##
275
+ # Returns a string usable in Dir.glob to match all requirable paths
276
+ # for this spec.
277
+
278
+ def lib_dirs_glob
279
+ dirs = if self.require_paths.size > 1 then
280
+ "{#{self.require_paths.join(',')}}"
281
+ else
282
+ self.require_paths.first
283
+ end
284
+
285
+ "#{self.full_gem_path}/#{dirs}".untaint
286
+ end
287
+
266
288
  ##
267
289
  # Return a Gem::Specification from this gem
268
290
 
@@ -61,10 +61,16 @@ use with other commands.
61
61
  ss.map { |spec, _| spec }
62
62
  end
63
63
 
64
- def fetch_specs dependency # :nodoc:
64
+ def fetch_specs name_pattern, dependency # :nodoc:
65
65
  specs = []
66
66
 
67
- specs.concat dependency.matching_specs if local?
67
+ if local?
68
+ specs.concat Gem::Specification.stubs.find_all { |spec|
69
+ name_pattern =~ spec.name and
70
+ dependency.requirement.satisfied_by? spec.version
71
+ }.map(&:to_spec)
72
+ end
73
+
68
74
  specs.concat fetch_remote_specs dependency if remote?
69
75
 
70
76
  ensure_specs specs
@@ -72,16 +78,7 @@ use with other commands.
72
78
  specs.uniq.sort
73
79
  end
74
80
 
75
- def gem_dependency args, version, prerelease # :nodoc:
76
- args << '' if args.empty?
77
-
78
- pattern = if args.length == 1 and args.first =~ /\A\/(.*)\/(i)?\z/m then
79
- flags = $2 ? Regexp::IGNORECASE : nil
80
- Regexp.new $1, flags
81
- else
82
- /\A#{Regexp.union(*args)}/
83
- end
84
-
81
+ def gem_dependency pattern, version, prerelease # :nodoc:
85
82
  dependency = Gem::Deprecate.skip_during {
86
83
  Gem::Dependency.new pattern, version
87
84
  }
@@ -121,10 +118,12 @@ use with other commands.
121
118
  def execute
122
119
  ensure_local_only_reverse_dependencies
123
120
 
121
+ pattern = name_pattern options[:args]
122
+
124
123
  dependency =
125
- gem_dependency options[:args], options[:version], options[:prerelease]
124
+ gem_dependency pattern, options[:version], options[:prerelease]
126
125
 
127
- specs = fetch_specs dependency
126
+ specs = fetch_specs pattern, dependency
128
127
 
129
128
  reverse = reverse_dependencies specs
130
129
 
@@ -203,5 +202,16 @@ use with other commands.
203
202
  result
204
203
  end
205
204
 
206
- end
205
+ private
207
206
 
207
+ def name_pattern args
208
+ args << '' if args.empty?
209
+
210
+ if args.length == 1 and args.first =~ /\A\/(.*)\/(i)?\z/m then
211
+ flags = $2 ? Regexp::IGNORECASE : nil
212
+ Regexp.new $1, flags
213
+ else
214
+ /\A#{Regexp.union(*args)}/
215
+ end
216
+ end
217
+ end
@@ -113,6 +113,8 @@ lib/rubygems/defaults/operating_system.rb
113
113
 
114
114
  out << " - INSTALLATION DIRECTORY: #{Gem.dir}\n"
115
115
 
116
+ out << " - USER INSTALLATION DIRECTORY: #{Gem.user_dir}\n"
117
+
116
118
  out << " - RUBYGEMS PREFIX: #{Gem.prefix}\n" unless Gem.prefix.nil?
117
119
 
118
120
  out << " - RUBY EXECUTABLE: #{Gem.ruby}\n"
@@ -370,15 +370,5 @@ platform.
370
370
  end
371
371
  end
372
372
 
373
- def show_help # :nodoc:
374
- command = @command_manager[options[:help]]
375
- if command then
376
- # help with provided command
377
- command.invoke("--help")
378
- else
379
- alert_error "Unknown command #{options[:help]}. Try 'gem help commands'"
380
- end
381
- end
382
-
383
373
  end
384
374
 
@@ -275,7 +275,7 @@ to write the specification by hand. For example:
275
275
  gem = fetcher.download_to_cache dependency
276
276
  end
277
277
 
278
- inst = Gem::Installer.new gem, options
278
+ inst = Gem::Installer.at gem, options
279
279
  inst.install
280
280
 
281
281
  require 'rubygems/dependency_installer'
@@ -33,7 +33,7 @@ To search for remote gems use the search command.
33
33
  end
34
34
 
35
35
  def usage # :nodoc:
36
- "#{program_name} [STRING ...]"
36
+ "#{program_name} [REGEXP ...]"
37
37
  end
38
38
 
39
39
  end
@@ -21,6 +21,11 @@ class Gem::Commands::PristineCommand < Gem::Command
21
21
  options[:all] = value
22
22
  end
23
23
 
24
+ add_option('--skip=gem_name',
25
+ 'used on --all, skip if name == gem_name') do |value, options|
26
+ options[:skip] = value
27
+ end
28
+
24
29
  add_option('--[no-]extensions',
25
30
  'Restore gems with extensions',
26
31
  'in addition to regular gems') do |value, options|
@@ -109,6 +114,11 @@ extensions will be restored.
109
114
  next
110
115
  end
111
116
 
117
+ if spec.name == options[:skip]
118
+ say "Skipped #{spec.full_name}, it was given through options"
119
+ next
120
+ end
121
+
112
122
  if spec.bundled_gem_in_old_ruby?
113
123
  say "Skipped #{spec.full_name}, it is bundled with old Ruby"
114
124
  next
@@ -146,7 +156,7 @@ extensions will be restored.
146
156
  install_defaults.to_s['--env-shebang']
147
157
  end
148
158
 
149
- installer = Gem::Installer.new(gem,
159
+ installer = Gem::Installer.at(gem,
150
160
  :wrappers => true,
151
161
  :force => true,
152
162
  :install_dir => spec.base_dir,
@@ -227,7 +227,7 @@ is too hard to use.
227
227
 
228
228
  name_tuple, spec = detail_tuple
229
229
 
230
- spec = spec.fetch_spec name_tuple unless Gem::Specification === spec
230
+ spec = spec.fetch_spec name_tuple if spec.respond_to? :fetch_spec
231
231
 
232
232
  entry << "\n"
233
233
 
@@ -102,7 +102,7 @@ Do you want to add this insecure source?
102
102
  RubyGems fetches gems from the sources you have configured (stored in your
103
103
  ~/.gemrc).
104
104
 
105
- The default source is https://rubygems.org, but you may have older sources
105
+ The default source is https://rubygems.org, but you may have other sources
106
106
  configured. This guide will help you update your sources or configure
107
107
  yourself to use your own gem server.
108
108
 
@@ -47,7 +47,7 @@ class Gem::Commands::UpdateCommand < Gem::Command
47
47
  end
48
48
 
49
49
  def arguments # :nodoc:
50
- "REGEXP regexp to search for in gem name"
50
+ "GEMNAME name of gem to update"
51
51
  end
52
52
 
53
53
  def defaults_str # :nodoc:
@@ -64,7 +64,7 @@ command to remove old versions.
64
64
  end
65
65
 
66
66
  def usage # :nodoc:
67
- "#{program_name} REGEXP [REGEXP ...]"
67
+ "#{program_name} GEMNAME [GEMNAME ...]"
68
68
  end
69
69
 
70
70
  def check_latest_rubygems version # :nodoc:
@@ -321,12 +321,12 @@ if you believe they were disclosed to a third party.
321
321
  @rubygems_api_key = api_key
322
322
  end
323
323
 
324
- YAMLErrors = [ArgumentError]
325
- YAMLErrors << Psych::SyntaxError if defined?(Psych::SyntaxError)
326
-
327
324
  def load_file(filename)
328
325
  Gem.load_yaml
329
326
 
327
+ yaml_errors = [ArgumentError]
328
+ yaml_errors << Psych::SyntaxError if defined?(Psych::SyntaxError)
329
+
330
330
  return {} unless filename and File.exist? filename
331
331
 
332
332
  begin
@@ -336,7 +336,7 @@ if you believe they were disclosed to a third party.
336
336
  return {}
337
337
  end
338
338
  return content
339
- rescue *YAMLErrors => e
339
+ rescue *yaml_errors => e
340
340
  warn "Failed to load #{filename}, #{e}"
341
341
  rescue Errno::EACCES
342
342
  warn "Failed to load #{filename} due to permissions problem."
@@ -66,7 +66,7 @@ module Kernel
66
66
 
67
67
  begin
68
68
  RUBYGEMS_ACTIVATION_MONITOR.exit
69
- return gem_original_require(spec.to_fullpath(path) || path)
69
+ return gem_original_require(path)
70
70
  end if spec
71
71
 
72
72
  # Attempt to find +path+ in any unresolved gems...
@@ -105,7 +105,7 @@ module Kernel
105
105
 
106
106
  # Ok, now find a gem that has no conflicts, starting
107
107
  # at the highest version.
108
- valid = found_specs.select { |s| s.conflicts.empty? }.last
108
+ valid = found_specs.reject { |s| s.has_conflicts? }.last
109
109
 
110
110
  unless valid then
111
111
  le = Gem::LoadError.new "unable to find a version of '#{names.first}' to activate"
@@ -164,6 +164,10 @@ class Gem::Dependency
164
164
  @type ||= :runtime
165
165
  end
166
166
 
167
+ def runtime?
168
+ @type == :runtime || !@type
169
+ end
170
+
167
171
  def == other # :nodoc:
168
172
  Gem::Dependency === other &&
169
173
  self.name == other.name &&
@@ -270,14 +274,13 @@ class Gem::Dependency
270
274
  end
271
275
 
272
276
  def matching_specs platform_only = false
273
- matches = Gem::Specification.stubs.find_all { |spec|
274
- self.name === spec.name and # TODO: == instead of ===
275
- requirement.satisfied_by? spec.version
277
+ matches = Gem::Specification.stubs_for(name).find_all { |spec|
278
+ requirement.satisfied_by? spec.version
276
279
  }.map(&:to_spec)
277
280
 
278
281
  if platform_only
279
282
  matches.reject! { |spec|
280
- not Gem::Platform.match spec.platform
283
+ spec.nil? || !Gem::Platform.match(spec.platform)
281
284
  }
282
285
  end
283
286
 
@@ -323,11 +326,11 @@ class Gem::Dependency
323
326
  def to_spec
324
327
  matches = self.to_specs
325
328
 
326
- active = matches.find { |spec| spec.activated? }
329
+ active = matches.find { |spec| spec && spec.activated? }
327
330
 
328
331
  return active if active
329
332
 
330
- matches.delete_if { |spec| spec.version.prerelease? } unless prerelease?
333
+ matches.delete_if { |spec| spec.nil? || spec.version.prerelease? } unless prerelease?
331
334
 
332
335
  matches.last
333
336
  end
@@ -141,6 +141,9 @@ class Gem::DependencyList
141
141
  def ok_to_remove?(full_name, check_dev=true)
142
142
  gem_to_remove = find_name full_name
143
143
 
144
+ # If the state is inconsistent, at least don't crash
145
+ return true unless gem_to_remove
146
+
144
147
  siblings = @specs.find_all { |s|
145
148
  s.name == gem_to_remove.name &&
146
149
  s.full_name != gem_to_remove.full_name
@@ -66,9 +66,11 @@ class Gem::Ext::Builder
66
66
  # TODO use Process.spawn when ruby 1.8 support is dropped.
67
67
  rubygems_gemdeps, ENV['RUBYGEMS_GEMDEPS'] = ENV['RUBYGEMS_GEMDEPS'], nil
68
68
  if verbose
69
+ puts("current directory: #{Dir.pwd}")
69
70
  puts(command)
70
71
  system(command)
71
72
  else
73
+ results << "current directory: #{Dir.pwd}"
72
74
  results << command
73
75
  results << `#{command} #{redirector}`
74
76
  end
@@ -35,7 +35,12 @@ class Gem::Ext::ExtConfBuilder < Gem::Ext::Builder
35
35
  begin
36
36
  run cmd, results
37
37
  ensure
38
- FileUtils.mv 'mkmf.log', dest_path if File.exist? 'mkmf.log'
38
+ if File.exist? 'mkmf.log'
39
+ results << "To see why this extension failed to compile, please check" \
40
+ " the mkmf.log which can be found here:\n"
41
+ results << " " + File.join(dest_path, 'mkmf.log') + "\n"
42
+ FileUtils.mv 'mkmf.log', dest_path
43
+ end
39
44
  siteconf.unlink
40
45
  end
41
46
 
@@ -93,40 +93,22 @@ class Gem::Indexer
93
93
  end
94
94
 
95
95
  ##
96
- # Abbreviate the spec for downloading. Abbreviated specs are only used for
97
- # searching, downloading and related activities and do not need deployment
98
- # specific information (e.g. list of files). So we abbreviate the spec,
99
- # making it much smaller for quicker downloads.
100
- #--
101
- # TODO move to Gem::Specification
102
-
103
- def abbreviate(spec)
104
- spec.files = []
105
- spec.test_files = []
106
- spec.rdoc_options = []
107
- spec.extra_rdoc_files = []
108
- spec.cert_chain = []
109
- spec
110
- end
111
-
112
- ##
113
- # Build various indicies
114
-
115
- def build_indicies
116
- Gem::Specification.dirs = []
117
- Gem::Specification.add_specs(*map_gems_to_specs(gem_file_list))
96
+ # Build various indices
118
97
 
119
- build_marshal_gemspecs
120
- build_modern_indicies if @build_modern
98
+ def build_indices
99
+ specs = map_gems_to_specs gem_file_list
100
+ Gem::Specification._resort! specs
101
+ build_marshal_gemspecs specs
102
+ build_modern_indices specs if @build_modern
121
103
 
122
- compress_indicies
104
+ compress_indices
123
105
  end
124
106
 
125
107
  ##
126
108
  # Builds Marshal quick index gemspecs.
127
109
 
128
- def build_marshal_gemspecs
129
- count = Gem::Specification.count { |s| not s.default_gem? }
110
+ def build_marshal_gemspecs specs
111
+ count = specs.count
130
112
  progress = ui.progress_reporter count,
131
113
  "Generating Marshal quick index gemspecs for #{count} gems",
132
114
  "Complete"
@@ -134,7 +116,7 @@ class Gem::Indexer
134
116
  files = []
135
117
 
136
118
  Gem.time 'Generated Marshal quick index gemspecs' do
137
- Gem::Specification.each do |spec|
119
+ specs.each do |spec|
138
120
  next if spec.default_gem?
139
121
  spec_file_name = "#{spec.original_name}.gemspec.rz"
140
122
  marshal_name = File.join @quick_marshal_dir, spec_file_name
@@ -186,16 +168,14 @@ class Gem::Indexer
186
168
  end
187
169
 
188
170
  ##
189
- # Builds indicies for RubyGems 1.2 and newer. Handles full, latest, prerelease
190
-
191
- def build_modern_indicies
192
- specs = Gem::Specification.reject { |s| s.default_gem? }
171
+ # Builds indices for RubyGems 1.2 and newer. Handles full, latest, prerelease
193
172
 
173
+ def build_modern_indices specs
194
174
  prerelease, released = specs.partition { |s|
195
175
  s.version.prerelease?
196
176
  }
197
177
  latest_specs =
198
- Gem::Specification.latest_specs.reject { |s| s.default_gem? }
178
+ Gem::Specification._latest_specs specs
199
179
 
200
180
  build_modern_index(released.sort, @specs_index, 'specs')
201
181
  build_modern_index(latest_specs.sort, @latest_specs_index, 'latest specs')
@@ -221,18 +201,8 @@ class Gem::Indexer
221
201
  spec = Gem::Package.new(gemfile).spec
222
202
  spec.loaded_from = gemfile
223
203
 
224
- # HACK: fuck this shit - borks all tests that use pl1
225
- # if File.basename(gemfile, ".gem") != spec.original_name then
226
- # exp = spec.full_name
227
- # exp << " (#{spec.original_name})" if
228
- # spec.original_name != spec.full_name
229
- # msg = "Skipping misnamed gem: #{gemfile} should be named #{exp}"
230
- # alert_warning msg
231
- # next
232
- # end
233
-
234
- abbreviate spec
235
- sanitize spec
204
+ spec.abbreviate
205
+ spec.sanitize
236
206
 
237
207
  spec
238
208
  rescue SignalException
@@ -248,14 +218,14 @@ class Gem::Indexer
248
218
  end
249
219
 
250
220
  ##
251
- # Compresses indicies on disk
221
+ # Compresses indices on disk
252
222
  #--
253
223
  # All future files should be compressed using gzip, not deflate
254
224
 
255
- def compress_indicies
256
- say "Compressing indicies"
225
+ def compress_indices
226
+ say "Compressing indices"
257
227
 
258
- Gem.time 'Compressed indicies' do
228
+ Gem.time 'Compressed indices' do
259
229
  if @build_modern then
260
230
  gzip @specs_index
261
231
  gzip @latest_specs_index
@@ -303,12 +273,12 @@ class Gem::Indexer
303
273
  end
304
274
 
305
275
  ##
306
- # Builds and installs indicies.
276
+ # Builds and installs indices.
307
277
 
308
278
  def generate_index
309
279
  make_temp_directories
310
- build_indicies
311
- install_indicies
280
+ build_indices
281
+ install_indices
312
282
  rescue SignalException
313
283
  ensure
314
284
  FileUtils.rm_rf @directory
@@ -324,9 +294,9 @@ class Gem::Indexer
324
294
  end
325
295
 
326
296
  ##
327
- # Install generated indicies into the destination directory.
297
+ # Install generated indices into the destination directory.
328
298
 
329
- def install_indicies
299
+ def install_indices
330
300
  verbose = Gem.configuration.really_verbose
331
301
 
332
302
  say "Moving index into production dir #{@dest_directory}" if verbose
@@ -380,38 +350,6 @@ class Gem::Indexer
380
350
  end
381
351
  end
382
352
 
383
- ##
384
- # Sanitize the descriptive fields in the spec. Sometimes non-ASCII
385
- # characters will garble the site index. Non-ASCII characters will
386
- # be replaced by their XML entity equivalent.
387
-
388
- def sanitize(spec)
389
- spec.summary = sanitize_string(spec.summary)
390
- spec.description = sanitize_string(spec.description)
391
- spec.post_install_message = sanitize_string(spec.post_install_message)
392
- spec.authors = spec.authors.collect { |a| sanitize_string(a) }
393
-
394
- spec
395
- end
396
-
397
- ##
398
- # Sanitize a single string.
399
-
400
- def sanitize_string(string)
401
- return string unless string
402
-
403
- # HACK the #to_s is in here because RSpec has an Array of Arrays of
404
- # Strings for authors. Need a way to disallow bad values on gemspec
405
- # generation. (Probably won't happen.)
406
- string = string.to_s
407
-
408
- begin
409
- Builder::XChar.encode string
410
- rescue NameError, NoMethodError
411
- string.to_xs
412
- end
413
- end
414
-
415
353
  ##
416
354
  # Perform an in-place update of the repository from newly added gems.
417
355
 
@@ -435,10 +373,7 @@ class Gem::Indexer
435
373
  specs = map_gems_to_specs updated_gems
436
374
  prerelease, released = specs.partition { |s| s.version.prerelease? }
437
375
 
438
- Gem::Specification.dirs = []
439
- Gem::Specification.add_specs(*specs)
440
-
441
- files = build_marshal_gemspecs
376
+ files = build_marshal_gemspecs specs
442
377
 
443
378
  Gem.time 'Updated indexes' do
444
379
  update_specs_index released, @dest_specs_index, @specs_index
@@ -448,7 +383,7 @@ class Gem::Indexer
448
383
  @prerelease_specs_index)
449
384
  end
450
385
 
451
- compress_indicies
386
+ compress_indices
452
387
 
453
388
  verbose = Gem.configuration.really_verbose
454
389