rubygems-update 1.3.7 → 1.4.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 (96) hide show
  1. data.tar.gz.sig +0 -0
  2. data/.autotest +4 -1
  3. data/ChangeLog +23 -0
  4. data/History.txt +30 -1
  5. data/Manifest.txt +1 -1
  6. data/{README → README.rdoc} +4 -4
  7. data/Rakefile +7 -56
  8. data/lib/rbconfig/datadir.rb +6 -13
  9. data/lib/rubygems.rb +144 -89
  10. data/lib/rubygems/builder.rb +15 -5
  11. data/lib/rubygems/command.rb +12 -4
  12. data/lib/rubygems/command_manager.rb +1 -1
  13. data/lib/rubygems/commands/build_command.rb +1 -1
  14. data/lib/rubygems/commands/cert_command.rb +4 -4
  15. data/lib/rubygems/commands/check_command.rb +1 -1
  16. data/lib/rubygems/commands/fetch_command.rb +1 -1
  17. data/lib/rubygems/commands/install_command.rb +4 -16
  18. data/lib/rubygems/commands/lock_command.rb +1 -1
  19. data/lib/rubygems/commands/mirror_command.rb +4 -4
  20. data/lib/rubygems/commands/pristine_command.rb +0 -1
  21. data/lib/rubygems/commands/push_command.rb +13 -2
  22. data/lib/rubygems/commands/query_command.rb +4 -4
  23. data/lib/rubygems/commands/server_command.rb +9 -1
  24. data/lib/rubygems/commands/setup_command.rb +3 -3
  25. data/lib/rubygems/commands/sources_command.rb +2 -1
  26. data/lib/rubygems/commands/specification_command.rb +2 -1
  27. data/lib/rubygems/commands/unpack_command.rb +2 -1
  28. data/lib/rubygems/commands/update_command.rb +2 -2
  29. data/lib/rubygems/commands/which_command.rb +1 -0
  30. data/lib/rubygems/custom_require.rb +0 -2
  31. data/lib/rubygems/dependency.rb +15 -20
  32. data/lib/rubygems/dependency_installer.rb +31 -24
  33. data/lib/rubygems/dependency_list.rb +2 -7
  34. data/lib/rubygems/doc_manager.rb +2 -2
  35. data/lib/rubygems/ext/rake_builder.rb +1 -1
  36. data/lib/rubygems/format.rb +0 -4
  37. data/lib/rubygems/gem_openssl.rb +1 -3
  38. data/lib/rubygems/gem_path_searcher.rb +17 -0
  39. data/lib/rubygems/gem_runner.rb +6 -0
  40. data/lib/rubygems/gemcutter_utilities.rb +3 -3
  41. data/lib/rubygems/indexer.rb +4 -4
  42. data/lib/rubygems/install_update_options.rb +6 -0
  43. data/lib/rubygems/installer.rb +13 -6
  44. data/lib/rubygems/local_remote_options.rb +18 -5
  45. data/lib/rubygems/old_format.rb +4 -4
  46. data/lib/rubygems/package.rb +1 -6
  47. data/lib/rubygems/package/tar_input.rb +3 -0
  48. data/lib/rubygems/package_task.rb +6 -6
  49. data/lib/rubygems/platform.rb +1 -1
  50. data/lib/rubygems/remote_fetcher.rb +39 -8
  51. data/lib/rubygems/requirement.rb +1 -1
  52. data/lib/rubygems/security.rb +145 -106
  53. data/lib/rubygems/server.rb +16 -2
  54. data/lib/rubygems/source_index.rb +14 -45
  55. data/lib/rubygems/source_info_cache.rb +1 -2
  56. data/lib/rubygems/spec_fetcher.rb +32 -3
  57. data/lib/rubygems/specification.rb +34 -16
  58. data/lib/rubygems/text.rb +35 -0
  59. data/lib/rubygems/uninstaller.rb +1 -1
  60. data/lib/rubygems/user_interaction.rb +70 -0
  61. data/lib/rubygems/validator.rb +5 -3
  62. data/lib/rubygems/version.rb +36 -25
  63. data/test/gem_package_tar_test_case.rb +3 -1
  64. data/test/gemutilities.rb +26 -4
  65. data/test/test_config.rb +6 -2
  66. data/test/test_gem.rb +87 -29
  67. data/test/test_gem_command_manager.rb +3 -6
  68. data/test/test_gem_commands_cert_command.rb +2 -2
  69. data/test/test_gem_commands_install_command.rb +55 -0
  70. data/test/test_gem_commands_outdated_command.rb +2 -2
  71. data/test/test_gem_commands_owner_command.rb +6 -6
  72. data/test/test_gem_commands_push_command.rb +27 -7
  73. data/test/test_gem_commands_query_command.rb +0 -6
  74. data/test/test_gem_commands_specification_command.rb +4 -4
  75. data/test/test_gem_config_file.rb +0 -2
  76. data/test/test_gem_dependency_installer.rb +21 -23
  77. data/test/test_gem_ext_ext_conf_builder.rb +0 -9
  78. data/test/test_gem_ext_rake_builder.rb +0 -15
  79. data/test/test_gem_gemcutter_utilities.rb +1 -1
  80. data/test/test_gem_installer.rb +0 -5
  81. data/test/test_gem_local_remote_options.rb +18 -1
  82. data/test/test_gem_package_task.rb +1 -1
  83. data/test/test_gem_platform.rb +0 -1
  84. data/test/test_gem_remote_fetcher.rb +5 -3
  85. data/test/test_gem_requirement.rb +2 -2
  86. data/test/test_gem_security.rb +90 -0
  87. data/test/test_gem_server.rb +6 -6
  88. data/test/test_gem_source_index.rb +7 -13
  89. data/test/test_gem_specification.rb +3 -18
  90. data/test/test_gem_stream_ui.rb +69 -5
  91. data/test/test_gem_text.rb +43 -0
  92. data/test/test_gem_version.rb +14 -7
  93. data/test/test_kernel.rb +1 -1
  94. data/util/gem_prelude.rb +8 -8
  95. metadata +15 -10
  96. metadata.gz.sig +0 -0
data.tar.gz.sig CHANGED
Binary file
data/.autotest CHANGED
@@ -4,8 +4,9 @@ require 'autotest/restart'
4
4
 
5
5
  Autotest.add_hook :initialize do |at|
6
6
  at.order = :natural # I am a bad person - Eric Hodel
7
- at.testlib = 'minitest/unit' if at.respond_to? :testlib=
7
+ at.testlib = 'minitest/autorun'
8
8
 
9
+ at.add_exception %r%/\.git/%
9
10
  at.add_exception %r%/\.svn/%
10
11
  at.add_exception %r%\.rbc$%
11
12
  at.add_exception %r%test/rubygems%
@@ -28,4 +29,6 @@ Autotest.add_hook :initialize do |at|
28
29
  # at.add_mapping %r%^test/support/(.*).rb$% do |_, m|
29
30
  # files_matching %r%^test/test_(.*)\.rb%%
30
31
  # end
32
+
33
+ at.find_directories = ARGV unless ARGV.empty?
31
34
  end
data/ChangeLog CHANGED
@@ -1,5 +1,28 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
+ 2010-12-29 Luis Lavena <luislavena@gmail.com>
4
+
5
+ * lib/rubygems/user_interaction.rb: Implemented SimpleDownloadReporter
6
+ and VerboseDownloadReporter to provide a progress indicator during
7
+ gem installation. Idea and patch by Ryan Melt (Pull #2)
8
+
9
+ 2010-12-10 Luis Lavena <luislavena@gmail.com>
10
+
11
+ * lib/rubygems/commands/server_command.rb: Added --launch option to
12
+ automatically launch a browser window. Pull Request #11 by Gordon
13
+ Thiesfeld.
14
+ * lib/rubygems/server.rb: ditto.
15
+
16
+ 2010-12-01 Eric Hodel <drbrain@segment7.net>
17
+
18
+ * lib/rubygems/security.rb: Fixed indent, described how to manually
19
+ verify signed gems.
20
+
21
+ 2010-07-10 Luis Lavena <luislavena@gmail.com>
22
+
23
+ * lib/rubygems.rb: Expand Windows user home canditates for Ruby 1.8
24
+ Bug #28371
25
+
3
26
  2010-05-13 Eric Hodel <drbrain@segment7.net>
4
27
 
5
28
  * lib/rubygems.rb: 1.3.7.
@@ -1,4 +1,33 @@
1
- === 1.3.7 / 2010-05-13
1
+ === 1.4.0 / 2010-12-31
2
+
3
+ NOTE: In order to better maintain rubygems and to get it in sync with
4
+ the world (eg, 1.9's 1.3.7 is different from our 1.3.7), rubygems is
5
+ switching to a 4-6 week release schedule. This release is the
6
+ precursor to that process and as such may be a bit on the wild side!
7
+ You have been warned!
8
+
9
+ NOTE: We've switched to git/github. See README.rdoc for details.
10
+
11
+ New features:
12
+
13
+ * Added --launch option to `gem server`. (gthiesfeld)
14
+ * Added fuzzy name matching on install failures. (gstark/presidentbeef)
15
+ * Allow searching w/ file extensions: gem which fileutils.rb
16
+ * Progress indicator during download (Ryan Melton)
17
+ * Speed up Gem::Version#<=> by 2-3x in common cases. (raggi)
18
+
19
+ Bug fixes:
20
+
21
+ * Dependency "~>"s now respect lower-bound prerelease versions.
22
+ * Ensure the gem directories exist on download.
23
+ * Expand Windows user home candidates for Ruby 1.8. Bug #28371 & #28494
24
+ * Fix find_files to order by version.
25
+ * Fix ivar typo. [Josh Peek]
26
+ * Normalized requires and made many of them lazy.
27
+ Do not depend on rubygems to require stdlib stuff for you. (raggi/tmm1)
28
+ * Treat 1.0.a10 like 1.0.a.10 for sorting, etc. Fixes #27903. (dchelimsky)
29
+
30
+ === 1.3.7 / 2010-05-13
2
31
 
3
32
  NOTE:
4
33
 
@@ -5,7 +5,7 @@ GPL.txt
5
5
  History.txt
6
6
  LICENSE.txt
7
7
  Manifest.txt
8
- README
8
+ README.rdoc
9
9
  Rakefile
10
10
  bin/gem
11
11
  bin/update_rubygems
@@ -1,9 +1,9 @@
1
1
  = RubyGems
2
2
 
3
- * http://rubygems.org/
4
- * http://docs.rubygems.org/
5
- * http://rubygems.rubyforge.org/
6
- * http://rubyforge.org/projects/rubygems
3
+ * http://rubygems.org
4
+ * http://docs.rubygems.org
5
+ * http://help.rubygems.org
6
+ * http://github.com/rubygems
7
7
 
8
8
  == DESCRIPTION
9
9
 
data/Rakefile CHANGED
@@ -7,13 +7,15 @@ require 'rubygems/package_task'
7
7
 
8
8
  require 'hoe'
9
9
 
10
+ Hoe::RUBY_FLAGS << " --disable-gems" if RUBY_VERSION > "1.9"
11
+
10
12
  Hoe.plugin :minitest
11
13
 
12
14
  hoe = Hoe.spec 'rubygems-update' do
13
15
  self.rubyforge_name = 'rubygems'
14
16
  self.author = ['Jim Weirich', 'Chad Fowler', 'Eric Hodel']
15
17
  self.email = %w[rubygems-developers@rubyforge.org]
16
- self.readme_file = 'README'
18
+ self.readme_file = 'README.rdoc'
17
19
  self.need_zip = false
18
20
  self.need_tar = false
19
21
 
@@ -36,6 +38,8 @@ hoe = Hoe.spec 'rubygems-update' do
36
38
  extra_dev_deps << ['minitest', '~> 1.4']
37
39
  extra_dev_deps << ['session', '~> 2.4']
38
40
 
41
+ self.extra_rdoc_files = Dir["*.rdoc"]
42
+
39
43
  spec_extras['rdoc_options'] = proc do |rdoc_options|
40
44
  rdoc_options << "--title=RubyGems #{self.version} Documentation"
41
45
  end
@@ -68,21 +72,9 @@ task :prerelease => [:clobber, :sanity_check, :test, :test_functional]
68
72
 
69
73
  task :postrelease => [:tag, :publish_docs]
70
74
 
71
- Rake::Task[:release_to_rubyforge].clear_actions
72
-
73
- task :release_to_rubyforge do
74
- files = Dir["pkg/rubygems-update*.gem"]
75
- rf = RubyForge.new.configure
76
- rf.login
77
- rf.add_file hoe.rubyforge_name, hoe.rubyforge_name, hoe.version, files.first
78
- end
79
-
80
75
  pkg_dir_path = "pkg/rubygems-update-#{hoe.version}"
81
- task pkg_dir_path do
76
+ task :package do
82
77
  mv pkg_dir_path, "pkg/rubygems-#{hoe.version}"
83
- end
84
-
85
- task :package => [pkg_dir_path] do
86
78
  Dir.chdir 'pkg' do
87
79
  sh "tar -czf rubygems-#{hoe.version}.tgz rubygems-#{hoe.version}"
88
80
  sh "zip -q -r rubygems-#{hoe.version}.zip rubygems-#{hoe.version}"
@@ -94,52 +86,11 @@ task :sanity_check do
94
86
  end
95
87
 
96
88
  task :tag => :sanity_check do
97
- reltag = "REL_#{Gem::VERSION.gsub(/\./, '_')}"
98
- svn_url = "svn+ssh://rubyforge.org/var/svn/rubygems"
99
- sh %{svn copy #{svn_url}/trunk #{svn_url}/tags/#{reltag}}
89
+ raise "need a git version of rake tag written"
100
90
  end
101
91
 
102
92
  # Misc Tasks ---------------------------------------------------------
103
93
 
104
- # Git mirror support. You probably don't need to care about
105
- # these. Don't run 'em unless you have a John-style git-svn setup
106
- # pointed at a valid, pushable Git remote called "origin".
107
-
108
- namespace :git do
109
- namespace :svn do
110
- task(:fetch) { sh "git svn fetch" }
111
- end
112
-
113
- task :sync => %w(svn:fetch sync:branches sync:tags)
114
-
115
- namespace :sync do
116
- task :branches do
117
- {
118
- "trunk" => "master",
119
- }.each do |svn, git|
120
- sh "git push origin svn/#{svn}:#{git}"
121
- end
122
- end
123
-
124
- task :tags do
125
- old = `git tag`
126
- tags = `git for-each-ref refs/remotes/svn/tags`.split "\n"
127
- tagged = false
128
-
129
- tags.each do |tag|
130
- next unless /(REL_.*)$/ =~ tag
131
- name, sha, _, sym = $1, *tag.split(/\s/)
132
-
133
- next if /#{name}/ =~ old
134
- sh "git tag -f '#{name}' #{sha}"
135
- tagged = true
136
- end
137
-
138
- sh "git push --tags" if tagged
139
- end
140
- end
141
- end
142
-
143
94
  # These tasks expect to have the following directory structure:
144
95
  #
145
96
  # git/git.rubini.us/code # Rubinius git HEAD checkout
@@ -4,17 +4,10 @@
4
4
  # See LICENSE.txt for permissions.
5
5
  #++
6
6
 
7
- module RbConfig
8
-
9
- ##
10
- # Return the path to the data directory associated with the given package
11
- # name. Normally this is just
12
- # "#{RbConfig::CONFIG['datadir']}/#{package_name}", but may be modified by
13
- # packages like RubyGems to handle versioned data directories.
14
-
15
- def self.datadir(package_name)
16
- File.join(CONFIG['datadir'], package_name)
17
- end unless RbConfig.respond_to?(:datadir)
18
-
19
- end
7
+ # N.B. This file is used by Config.datadir in rubygems.rb, and must not be
8
+ # removed before that require is removed. I require to avoid warning more than
9
+ # once.
20
10
 
11
+ warn 'rbconfig/datadir.rb and {Rb}Config.datadir is being deprecated from '\
12
+ 'RubyGems. It will be removed completely on or after January 2011. If you '\
13
+ 'wish to rely on a datadir, please use Gem.datadir.'
@@ -8,8 +8,8 @@
8
8
  gem_disabled = !defined? Gem
9
9
 
10
10
  require 'rubygems/defaults'
11
- require 'thread'
12
- require 'etc'
11
+ require 'rbconfig'
12
+ require 'thread' # HACK: remove me for 1.5 - this is here just for rails
13
13
 
14
14
  ##
15
15
  # RubyGems is the Ruby standard for publishing and managing third party
@@ -100,7 +100,7 @@ require 'etc'
100
100
  # -The RubyGems Team
101
101
 
102
102
  module Gem
103
- RubyGemsVersion = VERSION = '1.3.7'
103
+ RubyGemsVersion = VERSION = '1.4.0'
104
104
 
105
105
  ##
106
106
  # Raised when RubyGems is unable to load or activate a gem. Contains the
@@ -112,40 +112,49 @@ module Gem
112
112
  attr_accessor :name
113
113
 
114
114
  # Version requirement of gem
115
- attr_accessor :version_requirement
116
- end
115
+ attr_accessor :requirement
117
116
 
118
- ##
119
- # Configuration settings from ::RbConfig
117
+ def version_requirement
118
+ warn "#{Gem.location_of_caller.join ':'}:Warning: " \
119
+ "Gem::LoadError#version_requirement is deprecated " \
120
+ "and will be removed on or after January 2011. " \
121
+ "Use #requirement."
120
122
 
121
- ConfigMap = {} unless defined?(ConfigMap)
123
+ requirement
124
+ end
122
125
 
123
- require 'rbconfig'
126
+ def version_requirement= requirement
127
+ warn "#{Gem.location_of_caller.join ':'}:Warning: " \
128
+ "Gem::LoadError#version_requirement= is deprecated " \
129
+ "and will be removed on or after January 2011. " \
130
+ "Use #requirement."
124
131
 
125
- ConfigMap.merge!(
126
- :EXEEXT => RbConfig::CONFIG["EXEEXT"],
127
- :RUBY_SO_NAME => RbConfig::CONFIG["RUBY_SO_NAME"],
128
- :arch => RbConfig::CONFIG["arch"],
129
- :bindir => RbConfig::CONFIG["bindir"],
130
- :datadir => RbConfig::CONFIG["datadir"],
131
- :libdir => RbConfig::CONFIG["libdir"],
132
- :ruby_install_name => RbConfig::CONFIG["ruby_install_name"],
133
- :ruby_version => RbConfig::CONFIG["ruby_version"],
134
- :rubylibprefix => RbConfig::CONFIG["rubylibprefix"],
135
- :sitedir => RbConfig::CONFIG["sitedir"],
136
- :sitelibdir => RbConfig::CONFIG["sitelibdir"],
137
- :vendordir => RbConfig::CONFIG["vendordir"] ,
138
- :vendorlibdir => RbConfig::CONFIG["vendorlibdir"]
139
- )
132
+ self.requirement = requirement
133
+ end
134
+ end
135
+
136
+ RbConfigPriorities = %w[
137
+ EXEEXT RUBY_SO_NAME arch bindir datadir libdir ruby_install_name
138
+ ruby_version rubylibprefix sitedir sitelibdir vendordir vendorlibdir
139
+ ]
140
+
141
+ unless defined?(ConfigMap)
142
+ ##
143
+ # Configuration settings from ::RbConfig
144
+ ConfigMap = Hash.new do |cm, key|
145
+ cm[key] = RbConfig::CONFIG[key.to_s]
146
+ end
147
+ else
148
+ RbConfigPriorities.each do |key|
149
+ ConfigMap[key.to_sym] = RbConfig::CONFIG[key]
150
+ end
151
+ end
140
152
 
141
153
  ##
142
154
  # Default directories in a gem repository
143
155
 
144
156
  DIRECTORIES = %w[cache doc gems specifications] unless defined?(DIRECTORIES)
145
157
 
146
- # :stopdoc:
147
- MUTEX = Mutex.new
148
-
149
158
  RubyGemsPackageVersion = VERSION
150
159
  # :startdoc:
151
160
 
@@ -178,7 +187,7 @@ module Gem
178
187
 
179
188
  ##
180
189
  # Activates an installed gem matching +gem+. The gem must satisfy
181
- # +version_requirements+.
190
+ # +requirements+.
182
191
  #
183
192
  # Returns true if the gem is activated, false if it is already
184
193
  # loaded, or an exception otherwise.
@@ -192,22 +201,22 @@ module Gem
192
201
  # More information on version requirements can be found in the
193
202
  # Gem::Requirement and Gem::Version documentation.
194
203
 
195
- def self.activate(gem, *version_requirements)
196
- if version_requirements.last.is_a?(Hash)
197
- options = version_requirements.pop
204
+ def self.activate(gem, *requirements)
205
+ if requirements.last.is_a?(Hash)
206
+ options = requirements.pop
198
207
  else
199
208
  options = {}
200
209
  end
201
210
 
202
211
  sources = options[:sources] || []
203
212
 
204
- if version_requirements.empty? then
205
- version_requirements = Gem::Requirement.default
213
+ if requirements.empty? then
214
+ requirements = Gem::Requirement.default
206
215
  end
207
216
 
208
217
  unless gem.respond_to?(:name) and
209
218
  gem.respond_to?(:requirement) then
210
- gem = Gem::Dependency.new(gem, version_requirements)
219
+ gem = Gem::Dependency.new(gem, requirements)
211
220
  end
212
221
 
213
222
  matches = Gem.source_index.find_name(gem.name, gem.requirement)
@@ -228,7 +237,7 @@ module Gem
228
237
 
229
238
  e = Gem::LoadError.new msg
230
239
  e.name = gem.name
231
- e.version_requirement = gem.requirement
240
+ e.requirement = gem.requirement
232
241
 
233
242
  raise e
234
243
  end
@@ -312,26 +321,30 @@ module Gem
312
321
  ##
313
322
  # Find the full path to the executable for gem +name+. If the +exec_name+
314
323
  # is not given, the gem's default_executable is chosen, otherwise the
315
- # specified executable's path is returned. +version_requirements+ allows
324
+ # specified executable's path is returned. +requirements+ allows
316
325
  # you to specify specific gem versions.
317
326
 
318
- def self.bin_path(name, exec_name = nil, *version_requirements)
319
- version_requirements = Gem::Requirement.default if
320
- version_requirements.empty?
321
- spec = Gem.source_index.find_name(name, version_requirements).last
327
+ def self.bin_path(name, exec_name = nil, *requirements)
328
+ requirements = Gem::Requirement.default if
329
+ requirements.empty?
330
+ specs = Gem.source_index.find_name(name, requirements)
322
331
 
323
332
  raise Gem::GemNotFoundException,
324
- "can't find gem #{name} (#{version_requirements})" unless spec
333
+ "can't find gem #{name} (#{requirements})" if specs.empty?
325
334
 
326
- exec_name ||= spec.default_executable
335
+ specs = specs.find_all do |spec|
336
+ spec.executables.include?(exec_name)
337
+ end if exec_name
327
338
 
328
- unless exec_name
329
- msg = "no default executable for #{spec.full_name}"
330
- raise Gem::Exception, msg
339
+ unless spec = specs.last
340
+ msg = "can't find gem #{name} (#{requirements}) with executable #{exec_name}"
341
+ raise Gem::GemNotFoundException, msg
331
342
  end
332
343
 
333
- unless spec.executables.include? exec_name
334
- msg = "can't find executable #{exec_name} for #{spec.full_name}"
344
+ exec_name ||= spec.default_executable
345
+
346
+ unless exec_name
347
+ msg = "no default executable for #{spec.full_name} and none given"
335
348
  raise Gem::Exception, msg
336
349
  end
337
350
 
@@ -366,9 +379,7 @@ module Gem
366
379
 
367
380
  @@source_index = nil
368
381
 
369
- MUTEX.synchronize do
370
- @searcher = nil
371
- end
382
+ @searcher = nil
372
383
  end
373
384
 
374
385
  ##
@@ -462,27 +473,36 @@ module Gem
462
473
  #
463
474
  # Gem.find_files('rdoc/discover').each do |path| load path end
464
475
  #
465
- # find_files search $LOAD_PATH for files as well as gems.
476
+ # if +check_load_path+ is true (the default), then find_files also searches
477
+ # $LOAD_PATH for files as well as gems.
466
478
  #
467
479
  # Note that find_files will return all files even if they are from different
468
480
  # versions of the same gem.
469
481
 
470
- def self.find_files(path)
471
- load_path_files = $LOAD_PATH.map do |load_path|
472
- files = Dir["#{File.expand_path path, load_path}#{Gem.suffix_pattern}"]
482
+ def self.find_files(path, check_load_path=true)
483
+ files = []
473
484
 
474
- files.select do |load_path_file|
475
- File.file? load_path_file.untaint
485
+ if check_load_path
486
+ $LOAD_PATH.each do |load_path|
487
+ globbed = Dir["#{File.expand_path path, load_path}#{Gem.suffix_pattern}"]
488
+
489
+ globbed.each do |load_path_file|
490
+ files << load_path_file if File.file?(load_path_file.untaint)
491
+ end
476
492
  end
477
- end.flatten
493
+ end
478
494
 
479
- specs = searcher.find_all path
495
+ specs = searcher.find_all_dot_rb path
480
496
 
481
- specs_files = specs.map do |spec|
482
- searcher.matching_files spec, path
483
- end.flatten
497
+ specs.each do |spec|
498
+ files.concat searcher.matching_files(spec, path)
499
+ end
500
+
501
+ # $LOAD_PATH might contain duplicate entries or reference
502
+ # the spec dirs directly, so we prune.
503
+ files.uniq! if check_load_path
484
504
 
485
- (load_path_files + specs_files).flatten.uniq
505
+ return files
486
506
  end
487
507
 
488
508
  ##
@@ -499,18 +519,19 @@ module Gem
499
519
  def self.find_home
500
520
  unless RUBY_VERSION > '1.9' then
501
521
  ['HOME', 'USERPROFILE'].each do |homekey|
502
- return ENV[homekey] if ENV[homekey]
522
+ return File.expand_path(ENV[homekey]) if ENV[homekey]
503
523
  end
504
524
 
505
525
  if ENV['HOMEDRIVE'] && ENV['HOMEPATH'] then
506
- return "#{ENV['HOMEDRIVE']}#{ENV['HOMEPATH']}"
526
+ return File.expand_path("#{ENV['HOMEDRIVE']}#{ENV['HOMEPATH']}")
507
527
  end
508
528
  end
509
529
 
510
530
  File.expand_path "~"
511
531
  rescue
512
532
  if File::ALT_SEPARATOR then
513
- "C:/"
533
+ drive = ENV['HOMEDRIVE'] || ENV['SystemDrive']
534
+ File.join(drive.to_s, '/')
514
535
  else
515
536
  "/"
516
537
  end
@@ -550,6 +571,20 @@ module Gem
550
571
  Zlib::Inflate.inflate data
551
572
  end
552
573
 
574
+ ##
575
+ # Get the default RubyGems API host. This is normally
576
+ # <tt>https://rubygems.org</tt>.
577
+
578
+ def self.host
579
+ @host ||= "https://rubygems.org"
580
+ end
581
+
582
+ ## Set the default RubyGems API host.
583
+
584
+ def self.host= host
585
+ @host = host
586
+ end
587
+
553
588
  ##
554
589
  # Return a list of all possible load paths for the latest version for all
555
590
  # gems in the Gem installation.
@@ -745,9 +780,7 @@ module Gem
745
780
  def self.refresh
746
781
  source_index.refresh!
747
782
 
748
- MUTEX.synchronize do
749
- @searcher = nil
750
- end
783
+ @searcher = nil
751
784
  end
752
785
 
753
786
  ##
@@ -775,7 +808,7 @@ module Gem
775
808
  end
776
809
 
777
810
  error.name = gem.name
778
- error.version_requirement = gem.requirement
811
+ error.requirement = gem.requirement
779
812
  raise error
780
813
  end
781
814
 
@@ -837,9 +870,7 @@ module Gem
837
870
  # The GemPathSearcher object used to search for matching installed gems.
838
871
 
839
872
  def self.searcher
840
- MUTEX.synchronize do
841
- @searcher ||= Gem::GemPathSearcher.new
842
- end
873
+ @searcher ||= Gem::GemPathSearcher.new
843
874
  end
844
875
 
845
876
  ##
@@ -977,11 +1008,9 @@ module Gem
977
1008
  end
978
1009
 
979
1010
  ##
980
- # Find all 'rubygems_plugin' files and load them
981
-
982
- def self.load_plugins
983
- plugins = Gem.find_files 'rubygems_plugin'
1011
+ # Load +plugins+ as ruby files
984
1012
 
1013
+ def self.load_plugin_files(plugins)
985
1014
  plugins.each do |plugin|
986
1015
 
987
1016
  # Skip older versions of the GemCutter plugin: Its commands are in
@@ -998,6 +1027,31 @@ module Gem
998
1027
  end
999
1028
  end
1000
1029
 
1030
+ ##
1031
+ # Find all 'rubygems_plugin' files in installed gems and load them
1032
+
1033
+ def self.load_plugins
1034
+ load_plugin_files find_files('rubygems_plugin', false)
1035
+ end
1036
+
1037
+ ##
1038
+ # Find all 'rubygems_plugin' files in $LOAD_PATH and load them
1039
+
1040
+ def self.load_env_plugins
1041
+ path = "rubygems_plugin"
1042
+
1043
+ files = []
1044
+ $LOAD_PATH.each do |load_path|
1045
+ globbed = Dir["#{File.expand_path path, load_path}#{Gem.suffix_pattern}"]
1046
+
1047
+ globbed.each do |load_path_file|
1048
+ files << load_path_file if File.file?(load_path_file.untaint)
1049
+ end
1050
+ end
1051
+
1052
+ load_plugin_files files
1053
+ end
1054
+
1001
1055
  class << self
1002
1056
 
1003
1057
  ##
@@ -1044,6 +1098,16 @@ module Gem
1044
1098
 
1045
1099
  YAML_SPEC_DIR = 'quick/'
1046
1100
 
1101
+ autoload :Version, 'rubygems/version'
1102
+ autoload :Requirement, 'rubygems/requirement'
1103
+ autoload :Dependency, 'rubygems/dependency'
1104
+ autoload :GemPathSearcher, 'rubygems/gem_path_searcher'
1105
+ autoload :SpecFetcher, 'rubygems/spec_fetcher'
1106
+ autoload :Specification, 'rubygems/specification'
1107
+ autoload :Cache, 'rubygems/source_index'
1108
+ autoload :SourceIndex, 'rubygems/source_index'
1109
+ autoload :Platform, 'rubygems/platform'
1110
+ autoload :Builder, 'rubygems/builder'
1047
1111
  end
1048
1112
 
1049
1113
  module Kernel
@@ -1053,7 +1117,7 @@ module Kernel
1053
1117
  ##
1054
1118
  # Use Kernel#gem to activate a specific version of +gem_name+.
1055
1119
  #
1056
- # +version_requirements+ is a list of version requirements that the
1120
+ # +requirements+ is a list of version requirements that the
1057
1121
  # specified gem must match, most commonly "= example.version.number". See
1058
1122
  # Gem::Requirement for how to specify a version requirement.
1059
1123
  #
@@ -1076,10 +1140,10 @@ module Kernel
1076
1140
  #
1077
1141
  # GEM_SKIP=libA:libB ruby -I../libA -I../libB ./mycode.rb
1078
1142
 
1079
- def gem(gem_name, *version_requirements) # :doc:
1143
+ def gem(gem_name, *requirements) # :doc:
1080
1144
  skip_list = (ENV['GEM_SKIP'] || "").split(/:/)
1081
1145
  raise Gem::LoadError, "skipping #{gem_name}" if skip_list.include? gem_name
1082
- Gem.activate(gem_name, *version_requirements)
1146
+ Gem.activate(gem_name, *requirements)
1083
1147
  end
1084
1148
 
1085
1149
  private :gem
@@ -1093,18 +1157,12 @@ end
1093
1157
  # "#{ConfigMap[:datadir]}/#{package_name}".
1094
1158
 
1095
1159
  def RbConfig.datadir(package_name)
1160
+ require 'rbconfig/datadir' # TODO Deprecate after January 2010.
1096
1161
  Gem.datadir(package_name) ||
1097
1162
  File.join(Gem::ConfigMap[:datadir], package_name)
1098
1163
  end
1099
1164
 
1100
1165
  require 'rubygems/exceptions'
1101
- require 'rubygems/version'
1102
- require 'rubygems/requirement'
1103
- require 'rubygems/dependency'
1104
- require 'rubygems/gem_path_searcher' # Needed for Kernel#gem
1105
- require 'rubygems/source_index' # Needed for Kernel#gem
1106
- require 'rubygems/platform'
1107
- require 'rubygems/builder' # HACK: Needed for rake's package task.
1108
1166
 
1109
1167
  begin
1110
1168
  ##
@@ -1135,6 +1193,3 @@ require 'rubygems/config_file'
1135
1193
  require 'rubygems/custom_require' if gem_disabled or RUBY_VERSION < '1.9'
1136
1194
 
1137
1195
  Gem.clear_paths
1138
-
1139
- Gem.load_plugins
1140
-