rubygems-update 0.8.10 → 0.8.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of rubygems-update might be problematic. Click here for more details.
- data/ChangeLog +66 -0
- data/README +17 -3
- data/Rakefile +29 -11
- data/bin/gem_mirror +67 -0
- data/examples/application/an-app.gemspec +2 -0
- data/lib/rubygems.rb +18 -3
- data/lib/rubygems/builder.rb +14 -1
- data/lib/rubygems/cmd_manager.rb +2 -0
- data/lib/rubygems/command.rb +26 -2
- data/lib/rubygems/custom_require.rb +30 -21
- data/lib/rubygems/format.rb +4 -4
- data/lib/rubygems/gem_commands.rb +161 -9
- data/lib/rubygems/gem_openssl.rb +34 -0
- data/lib/rubygems/gem_runner.rb +5 -1
- data/lib/rubygems/installer.rb +117 -38
- data/lib/rubygems/package.rb +135 -25
- data/lib/rubygems/remote_installer.rb +59 -29
- data/lib/rubygems/rubygems_version.rb +1 -1
- data/lib/rubygems/security.rb +478 -0
- data/lib/rubygems/specification.rb +48 -28
- data/post-install.rb +2 -1
- data/scripts/gemdoc.rb +2 -2
- data/scripts/specdoc.rb +25 -24
- data/scripts/upload_gemdoc.rb +134 -0
- data/setup.rb +1 -1
- data/test/data/a-0.0.1.gem +0 -0
- data/test/data/a-0.0.2.gem +0 -0
- data/test/data/b-0.0.2.gem +0 -0
- data/test/data/c-1.2.gem +0 -0
- data/test/data/gemhome/cache/a-0.0.1.gem +0 -0
- data/test/data/gemhome/cache/a-0.0.2.gem +0 -0
- data/test/data/gemhome/cache/b-0.0.2.gem +0 -0
- data/test/data/gemhome/cache/c-1.2.gem +0 -0
- data/test/data/gemhome/specifications/a-0.0.1.gemspec +1 -1
- data/test/data/gemhome/specifications/a-0.0.2.gemspec +1 -1
- data/test/data/gemhome/specifications/b-0.0.2.gemspec +1 -1
- data/test/data/gemhome/specifications/c-1.2.gemspec +1 -1
- data/test/data/one/one-0.0.1.gem +0 -0
- data/test/fake_certlib/openssl.rb +1 -0
- data/test/functional.rb +49 -14
- data/test/gemutilities.rb +69 -5
- data/test/test_cached_fetcher.rb +5 -7
- data/test/test_file_list.rb +96 -0
- data/test/test_gempaths.rb +36 -34
- data/test/test_installer.rb +214 -0
- data/test/test_local_cache.rb +45 -102
- data/test/test_parse_commands.rb +3 -1
- data/test/test_remote_installer.rb +24 -5
- data/test/test_specific_extras.rb +40 -0
- data/test/test_specification.rb +106 -16
- metadata +14 -3
data/ChangeLog
CHANGED
@@ -1,5 +1,71 @@
|
|
1
|
+
2005-07-08 Jim Weirich <jim@weirichhouse.org>
|
2
|
+
|
3
|
+
* Preparing for release 0.8.11.
|
4
|
+
|
5
|
+
2005-06-12 Jim Weirich <jim@weirichhouse.org>
|
6
|
+
|
7
|
+
* lib/rubygems/installer.rb
|
8
|
+
(Gem::Installer::installation_satisfies_dependency): Refactored
|
9
|
+
dependency check into ensure_dependency! and
|
10
|
+
installation_satisfies_dependency?.
|
11
|
+
|
12
|
+
2005-06-12 Chad Fowler <chad@chadfowler.com>
|
13
|
+
* lib/rubygems.rb,lib/rubygems/installer.rb: Applied Mark Hubbart's
|
14
|
+
* lib/rubygems/remote_installer.rb: Applied David Glasser's install-
|
15
|
+
* Applied Paul Duncan's incredibly complete gem signing patch.
|
16
|
+
Thanks, Paul!
|
17
|
+
* lib/rubygems/installer.rb: Fixed bug in installer that caused
|
18
|
+
dependency installation not to work.
|
19
|
+
|
20
|
+
2005-06-06 Chad Fowler <chad@chadfowler.com>
|
21
|
+
* lib/rubygems/specification.rb: Fixed Erik hatcher's reported bug
|
22
|
+
of gem directories having "-" at the end of their names (e.g.
|
23
|
+
"BlueCloth-1.0.0-".
|
24
|
+
|
25
|
+
2005-06-01 Jim Weirich <jim@weirichhouse.org>
|
26
|
+
|
27
|
+
* scripts/specdoc.rb (_resolve_links): Updated to generate hieraki
|
28
|
+
format so it can be included in the docs.rubygems.org site.
|
29
|
+
|
30
|
+
* test/test_specification.rb (TestSpecification::test_to_ruby):
|
31
|
+
Fixed test on date that hard-coded a specific date.
|
32
|
+
|
33
|
+
2005-05-29 Jim Weirich <jim@weirichhouse.org>
|
34
|
+
|
35
|
+
* Changes from the Seattle Code fest: (1) Package list command
|
36
|
+
(e.g. gem inspect GEM). (2) .gemrc settings now allow cvsrc like
|
37
|
+
options to set defaults per subcommand. (3) The autorequire spec
|
38
|
+
attribute will now accept a list. (4) Binwrappers vs symlinks
|
39
|
+
(more info to follow). (5) Substituted Time for Date in specs,
|
40
|
+
increasing performance dramatically in an important area.
|
41
|
+
|
42
|
+
2005-05-04 Jim Weirich <jim@weirichhouse.org>
|
43
|
+
|
44
|
+
* lib/rubygems.rb (Gem::Exception::find_home): Changed rescue
|
45
|
+
clause from Exception to StandardError. Exception doesn't seem to
|
46
|
+
catch everything ... I'm not sure I understand why.
|
47
|
+
|
48
|
+
2005-04-29 Chad Fowler <chad@chadfowler.com>
|
49
|
+
* lib/rubygems/specifiation.rb: Marcel Molina's patch to discover
|
50
|
+
which attributes in the spec are Array attributes.
|
51
|
+
|
52
|
+
2005-04-27 Chad Fowler <chad@chadfowler.com>
|
53
|
+
* lib/rubygems/gem_commands.rb: -y is now a synonym for
|
54
|
+
--include-dependencies
|
55
|
+
|
56
|
+
2005-04-21 Chad Fowler <chad@chadfowler.com>
|
57
|
+
* lib/rubygems/installer.rb: Added non-require_gem dependency check
|
58
|
+
for installation.
|
59
|
+
|
60
|
+
2005-04-03 Chad Fowler <chad@chadfowler.com>
|
61
|
+
|
62
|
+
* pre-install.rb: Added version check to RubyGems installation.
|
63
|
+
|
1
64
|
2005-03-25 Jim Weirich <jim@weirichhouse.org>
|
2
65
|
|
66
|
+
* lib/rubygems/rubygems_version.rb (Gem): Created release for
|
67
|
+
0.8.10.
|
68
|
+
|
3
69
|
* lib/rubygems/gem_commands.rb
|
4
70
|
(Gem::UpdateCommand::do_rubygems_update): Update --system now runs
|
5
71
|
the ruby command directly rather than trying to load teh
|
data/README
CHANGED
@@ -2,10 +2,19 @@
|
|
2
2
|
|
3
3
|
(See Releases for release-specific information)
|
4
4
|
|
5
|
-
==
|
5
|
+
== Installation
|
6
6
|
|
7
|
-
|
8
|
-
|
7
|
+
Get it from RubyForge (http://rubygems.rubyforge.org) and run (as root, if appropriate and necessary)
|
8
|
+
|
9
|
+
ruby setup.rb
|
10
|
+
|
11
|
+
For more details and other options, see:
|
12
|
+
|
13
|
+
* {User Guide/Installation}[http://docs.rubygems.org/read/chapter/3]
|
14
|
+
|
15
|
+
== For User Documentation, see
|
16
|
+
|
17
|
+
* {RubyGems User Guide}[http://docs.rubygems.org/read/book/1]
|
9
18
|
|
10
19
|
== For developer docs see
|
11
20
|
|
@@ -43,8 +52,13 @@ RubyGems was originally developed at RubyConf 2003 by:
|
|
43
52
|
* Dick Davies -- rasputnik(at)hellooperator.net
|
44
53
|
* Mauricio Fernandez -- batsman.geo(at)yahoo.com
|
45
54
|
* Simon Strandgaard -- neoneye(at)adslhome.dk
|
55
|
+
* Dave Glasser -- glasser(at)mit.edu
|
56
|
+
* Paul Duncan -- pabs(at)pablotron.org
|
46
57
|
* Ville Aine -- vaine(at)cs.helsinki.fi
|
47
58
|
|
59
|
+
|
60
|
+
(If your name is missing, PLEASE let us know!)
|
61
|
+
|
48
62
|
== Feedback
|
49
63
|
|
50
64
|
Please provide us feedback at http://rubyforge.org/projects/rubygems
|
data/Rakefile
CHANGED
@@ -30,12 +30,13 @@ CLOBBER.include(
|
|
30
30
|
"test/temp",
|
31
31
|
'test/data/gemhome',
|
32
32
|
'test/data/*.gem',
|
33
|
-
'scripts/*.
|
33
|
+
'scripts/*.hieraki',
|
34
34
|
'data__',
|
35
35
|
'html',
|
36
36
|
'pkgs/sources/sources*.gem',
|
37
37
|
'.config',
|
38
|
-
'**/debug.log'
|
38
|
+
'**/debug.log',
|
39
|
+
'logs'
|
39
40
|
)
|
40
41
|
|
41
42
|
task :default => [:test]
|
@@ -71,9 +72,9 @@ task :build_tests do
|
|
71
72
|
end
|
72
73
|
|
73
74
|
# Shortcuts for test targets
|
74
|
-
task :
|
75
|
-
task :
|
76
|
-
task :
|
75
|
+
task :tf => [:functional]
|
76
|
+
task :tu => [:test]
|
77
|
+
task :ta => [:alltests]
|
77
78
|
|
78
79
|
task :gemtest do
|
79
80
|
ruby %{-Ilib -rscripts/runtest -e 'run_tests("test/test_gempaths.rb", true)'}
|
@@ -190,19 +191,26 @@ end
|
|
190
191
|
|
191
192
|
# Wiki Doc Targets
|
192
193
|
|
193
|
-
desc "
|
194
|
-
task :
|
194
|
+
desc "Upload the Hieraki Data"
|
195
|
+
task :upload => [:upload_gemdoc]
|
195
196
|
|
196
|
-
|
197
|
+
task :upload_gemdoc => ['scripts/gemdoc.hieraki'] do
|
198
|
+
ruby %{scripts/upload_gemdoc.rb}
|
199
|
+
end
|
200
|
+
|
201
|
+
desc "Build the Hieraki documentation"
|
202
|
+
task :hieraki => ['scripts/gemdoc.hieraki', 'scripts/specdoc.hieraki']
|
203
|
+
|
204
|
+
file 'scripts/gemdoc.hieraki' => ['scripts/gemdoc.rb', 'scripts/gemdoc.data'] do
|
197
205
|
chdir('scripts') do
|
198
|
-
ruby %{-I../lib gemdoc.rb <gemdoc.data >gemdoc.
|
206
|
+
ruby %{-I../lib gemdoc.rb <gemdoc.data >gemdoc.hieraki}
|
199
207
|
end
|
200
208
|
end
|
201
209
|
|
202
|
-
file 'scripts/specdoc.
|
210
|
+
file 'scripts/specdoc.hieraki' =>
|
203
211
|
['scripts/specdoc.rb', 'scripts/specdoc.data', 'scripts/specdoc.yaml'] do
|
204
212
|
chdir('scripts') do
|
205
|
-
ruby %{-I../lib specdoc.rb >specdoc.
|
213
|
+
ruby %{-I../lib specdoc.rb >specdoc.hieraki}
|
206
214
|
end
|
207
215
|
end
|
208
216
|
|
@@ -248,6 +256,16 @@ installation of RubyGems before this update can be applied.
|
|
248
256
|
s.rubyforge_project = "rubygems"
|
249
257
|
s.bindir = "bin" # Use these for applications.
|
250
258
|
s.executables = ["update_rubygems"]
|
259
|
+
certdir = ENV['CERT_DIR']
|
260
|
+
if certdir
|
261
|
+
s.signing_key = File.join(certdir, 'gem-private_key.pem')
|
262
|
+
s.cert_chain = [File.join(certdir, 'gem-public_cert.pem')]
|
263
|
+
end
|
264
|
+
end
|
265
|
+
|
266
|
+
# Add console output about signing the Gem
|
267
|
+
file "pkg/#{Spec.full_name}.gem" do
|
268
|
+
puts "Signed with certificates in '#{ENV['CERT_DIR']}'" if ENV['CERT_DIR']
|
251
269
|
end
|
252
270
|
|
253
271
|
Rake::GemPackageTask.new(Spec) do |p| end
|
data/bin/gem_mirror
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
#! /usr/bin/ruby
|
2
|
+
|
3
|
+
# sample ~/.gemmirrorc:
|
4
|
+
#---
|
5
|
+
#-
|
6
|
+
# from: http://gems.rubyforge.org/
|
7
|
+
# to: /Users/glasser/MyGEMS/gems.rubyforge.org
|
8
|
+
|
9
|
+
require 'yaml'
|
10
|
+
require 'rubygems'
|
11
|
+
require 'open-uri'
|
12
|
+
|
13
|
+
config_file = File.join(Gem.user_home, '.gemmirrorrc')
|
14
|
+
|
15
|
+
raise "Config file #{config_file} not found" unless File.exist?(config_file)
|
16
|
+
|
17
|
+
mirrors = YAML.load_file(config_file)
|
18
|
+
|
19
|
+
mirrors.each do |mir|
|
20
|
+
raise "mirror missing 'from' field" unless mir.has_key?('from')
|
21
|
+
raise "mirror missing 'to' field" unless mir.has_key?('to')
|
22
|
+
|
23
|
+
get_from = mir['from']
|
24
|
+
save_to = mir['to']
|
25
|
+
|
26
|
+
raise "Directory not found: #{save_to}" unless File.exist?(save_to)
|
27
|
+
raise "Not a directory: #{save_to}" unless File.directory?(save_to)
|
28
|
+
|
29
|
+
gems_dir = save_to + "/gems"
|
30
|
+
if File.exist?(gems_dir)
|
31
|
+
raise "Not a directory: #{gems_dir}" unless File.directory?(gems_dir)
|
32
|
+
else
|
33
|
+
Dir.mkdir(gems_dir)
|
34
|
+
end
|
35
|
+
|
36
|
+
sourceindex_text = ''
|
37
|
+
|
38
|
+
open(get_from + "/yaml", "r") do |y|
|
39
|
+
sourceindex_text = y.read
|
40
|
+
open(save_to + "/yaml", "wb") do |out|
|
41
|
+
out.write(sourceindex_text)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
sourceindex = YAML.load(sourceindex_text)
|
46
|
+
|
47
|
+
sourceindex.each do |fullname, gem|
|
48
|
+
gem_file = fullname + '.gem'
|
49
|
+
unless File.exists?(gems_dir + "/" + gem_file)
|
50
|
+
puts "fetching: " + gem_file
|
51
|
+
|
52
|
+
begin
|
53
|
+
open(get_from + "/gems/" + gem_file, "r") do |g|
|
54
|
+
contents = g.read
|
55
|
+
open(gems_dir + "/" + gem_file, "wb") do |out|
|
56
|
+
out.write(contents)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
rescue
|
60
|
+
old_gf = gem_file
|
61
|
+
gem_file = gem_file.downcase
|
62
|
+
retry if old_gf != gem_file
|
63
|
+
puts $!
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -17,6 +17,8 @@ spec = Gem::Specification.new do |s|
|
|
17
17
|
#s.extra_rdoc_files = ["README", "Changes.rdoc"]
|
18
18
|
#s.default_executable = "myapp"
|
19
19
|
s.bindir = "bin"
|
20
|
+
s.signing_key = '/Users/chadfowler/cvs/rubygems/gem-private_key.pem'
|
21
|
+
s.cert_chain = ['/Users/chadfowler/cvs/rubygems/gem-public_cert.pem']
|
20
22
|
end
|
21
23
|
|
22
24
|
if $0==__FILE__
|
data/lib/rubygems.rb
CHANGED
@@ -114,6 +114,11 @@ module Gem
|
|
114
114
|
File.join(Gem.user_home, '.gemrc')
|
115
115
|
end
|
116
116
|
|
117
|
+
# Return the Ruby command to use to execute the Ruby interpreter.
|
118
|
+
def ruby
|
119
|
+
"ruby"
|
120
|
+
end
|
121
|
+
|
117
122
|
##
|
118
123
|
# Activate a gem (i.e. add it to the Ruby load path). The gem
|
119
124
|
# must satisfy all the specified version constraints. If
|
@@ -172,7 +177,12 @@ module Gem
|
|
172
177
|
$:.unshift File.join(spec.full_gem_path, path)
|
173
178
|
end
|
174
179
|
|
175
|
-
|
180
|
+
if autorequire && spec.autorequire then
|
181
|
+
Array(spec.autorequire).each do |a_lib|
|
182
|
+
require a_lib
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
176
186
|
return true
|
177
187
|
end
|
178
188
|
|
@@ -327,7 +337,7 @@ module Gem
|
|
327
337
|
end
|
328
338
|
begin
|
329
339
|
File.expand_path("~")
|
330
|
-
rescue
|
340
|
+
rescue StandardError => ex
|
331
341
|
if File::ALT_SEPARATOR
|
332
342
|
"C:/"
|
333
343
|
else
|
@@ -357,7 +367,11 @@ module Gem
|
|
357
367
|
# fundamental RubyGems dependency, so it might as well be up the
|
358
368
|
# top. -- Gavin Sinclair, 2004-12-12
|
359
369
|
#
|
360
|
-
|
370
|
+
if defined? RUBY_FRAMEWORK_VERSION
|
371
|
+
return File.join(File.dirname(Config::CONFIG["sitedir"]), "Gems")
|
372
|
+
else
|
373
|
+
File.join(Config::CONFIG['libdir'], 'ruby', 'gems', Config::CONFIG['ruby_version'])
|
374
|
+
end
|
361
375
|
end
|
362
376
|
|
363
377
|
private
|
@@ -380,6 +394,7 @@ end
|
|
380
394
|
|
381
395
|
require 'rubygems/source_index'
|
382
396
|
require 'rubygems/specification'
|
397
|
+
require 'rubygems/security'
|
383
398
|
require 'rubygems/version'
|
384
399
|
#require 'rubygems/loadpath_manager' # custom_require replaces this
|
385
400
|
require 'rubygems/custom_require'
|
data/lib/rubygems/builder.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
require "rubygems/package"
|
2
|
+
require "rubygems/security"
|
2
3
|
require "yaml"
|
4
|
+
require 'rubygems/gem_openssl'
|
3
5
|
|
4
6
|
module Gem
|
5
7
|
|
@@ -26,9 +28,20 @@ module Gem
|
|
26
28
|
@spec.mark_version
|
27
29
|
@spec.validate
|
28
30
|
|
31
|
+
# if the signing key was specified, then load the file, and swap
|
32
|
+
# to the public key (TODO: we should probably just omit the
|
33
|
+
# signing key in favor of the signing certificate, but that's for
|
34
|
+
# the future, also the signature algorihtm should be configurable)
|
35
|
+
signer = nil
|
36
|
+
if @spec.respond_to?(:signing_key) && @spec.signing_key
|
37
|
+
signer = Gem::Security::Signer.new(@spec.signing_key, @spec.cert_chain)
|
38
|
+
@spec.signing_key = nil
|
39
|
+
@spec.cert_chain = signer.cert_chain.map { |cert| cert.to_s }
|
40
|
+
end
|
41
|
+
|
29
42
|
file_name = @spec.full_name+".gem"
|
30
43
|
|
31
|
-
Package.open(file_name, "w") do |pkg|
|
44
|
+
Package.open(file_name, "w", signer) do |pkg|
|
32
45
|
pkg.metadata = @spec.to_yaml
|
33
46
|
@spec.files.each do |file|
|
34
47
|
next if File.directory? file
|
data/lib/rubygems/cmd_manager.rb
CHANGED
data/lib/rubygems/command.rb
CHANGED
@@ -76,7 +76,7 @@ module Gem
|
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
79
|
-
private
|
79
|
+
private
|
80
80
|
|
81
81
|
def command_manager
|
82
82
|
Gem::CommandManager.instance
|
@@ -91,7 +91,8 @@ module Gem
|
|
91
91
|
|
92
92
|
def add_extra_args(args)
|
93
93
|
result = []
|
94
|
-
|
94
|
+
s_extra = Command.specific_extra_args(@command)
|
95
|
+
extra = Command.extra_args + s_extra
|
95
96
|
while ! extra.empty?
|
96
97
|
ex = []
|
97
98
|
ex << extra.shift
|
@@ -172,6 +173,29 @@ module Gem
|
|
172
173
|
@extra_args = value.split
|
173
174
|
end
|
174
175
|
end
|
176
|
+
|
177
|
+
def specific_extra_args(cmd)
|
178
|
+
@specific_extra_args ||= Hash.new do |h,k|
|
179
|
+
h[k] = Array.new
|
180
|
+
end
|
181
|
+
|
182
|
+
r = @specific_extra_args[cmd]
|
183
|
+
return r
|
184
|
+
end
|
185
|
+
|
186
|
+
def add_specific_extra_args(cmd,args)
|
187
|
+
# Access @specific_extra_args so that the hash is
|
188
|
+
# created for sure.
|
189
|
+
#
|
190
|
+
specific_extra_args(cmd)
|
191
|
+
|
192
|
+
if args.kind_of? String
|
193
|
+
args = args.split(/\s+/)
|
194
|
+
end
|
195
|
+
|
196
|
+
@specific_extra_args[cmd] = args
|
197
|
+
end
|
198
|
+
|
175
199
|
end
|
176
200
|
|
177
201
|
add_common_option('--source URL', 'Use URL as the remote source for gems') do |value, options|
|
@@ -4,15 +4,18 @@ module Kernel
|
|
4
4
|
alias require__ require
|
5
5
|
|
6
6
|
#
|
7
|
-
# We replace Ruby's require with our own, which is capable of
|
7
|
+
# We replace Ruby's require with our own, which is capable of
|
8
|
+
# loading gems on demand.
|
8
9
|
#
|
9
10
|
# When you call <tt>require 'x'</tt>, this is what happens:
|
10
|
-
# * If the file can be loaded from the existing Ruby loadpath, it
|
11
|
-
#
|
12
|
-
#
|
11
|
+
# * If the file can be loaded from the existing Ruby loadpath, it
|
12
|
+
# is.
|
13
|
+
# * Otherwise, installed gems are searched for a file that matches.
|
14
|
+
# If it's found in gem 'y', that gem is activated (added to the
|
15
|
+
# loadpath).
|
13
16
|
#
|
14
|
-
# The normal <tt>require</tt> functionality of returning false if
|
15
|
-
# loaded is preserved.
|
17
|
+
# The normal <tt>require</tt> functionality of returning false if
|
18
|
+
# that file has already been loaded is preserved.
|
16
19
|
#
|
17
20
|
def require(path)
|
18
21
|
require__ path
|
@@ -33,8 +36,8 @@ end # module Kernel
|
|
33
36
|
module Gem
|
34
37
|
|
35
38
|
#
|
36
|
-
# GemPathSearcher has the capability to find loadable files inside
|
37
|
-
# up front to speed up searches later.
|
39
|
+
# GemPathSearcher has the capability to find loadable files inside
|
40
|
+
# gems. It generates data up front to speed up searches later.
|
38
41
|
#
|
39
42
|
class GemPathSearcher
|
40
43
|
|
@@ -42,10 +45,11 @@ module Gem
|
|
42
45
|
# Initialise the data we need to make searches later.
|
43
46
|
#
|
44
47
|
def initialize
|
45
|
-
# We want a record of all the installed gemspecs, in the order
|
48
|
+
# We want a record of all the installed gemspecs, in the order
|
49
|
+
# we wish to examine them.
|
46
50
|
@gemspecs = init_gemspecs
|
47
|
-
# Map gem spec to glob of full require_path directories.
|
48
|
-
# speed up searches later.
|
51
|
+
# Map gem spec to glob of full require_path directories.
|
52
|
+
# Preparing this information may speed up searches later.
|
49
53
|
@lib_dirs = {}
|
50
54
|
@gemspecs.each do |spec|
|
51
55
|
@lib_dirs[spec.object_id] = lib_dirs(spec)
|
@@ -53,10 +57,12 @@ module Gem
|
|
53
57
|
end
|
54
58
|
|
55
59
|
#
|
56
|
-
# Look in all the installed gems until a matching _path_ is found.
|
57
|
-
# of the gem where it was found. If no match
|
60
|
+
# Look in all the installed gems until a matching _path_ is found.
|
61
|
+
# Return the _gemspec_ of the gem where it was found. If no match
|
62
|
+
# is found, return nil.
|
58
63
|
#
|
59
|
-
# The gems are searched in alphabetical order, and in reverse
|
64
|
+
# The gems are searched in alphabetical order, and in reverse
|
65
|
+
# version order.
|
60
66
|
#
|
61
67
|
# For example:
|
62
68
|
#
|
@@ -65,9 +71,10 @@ module Gem
|
|
65
71
|
# find('rake/rdoctask') # -> (rake-0.4.12 spec)
|
66
72
|
# find('foobarbaz') # -> nil
|
67
73
|
#
|
68
|
-
# Matching paths can have various suffixes ('.rb', '.so', and
|
69
|
-
# not already be attached to _file_.
|
70
|
-
#
|
74
|
+
# Matching paths can have various suffixes ('.rb', '.so', and
|
75
|
+
# others), which may or may not already be attached to _file_.
|
76
|
+
# This method doesn't care about the full filename that matches;
|
77
|
+
# only that there is a match.
|
71
78
|
#
|
72
79
|
def find(path)
|
73
80
|
@gemspecs.each do |spec|
|
@@ -81,17 +88,19 @@ module Gem
|
|
81
88
|
SUFFIX_PATTERN = "{,.rb,.so,.bundle,.dll,.sl}"
|
82
89
|
|
83
90
|
#
|
84
|
-
# Attempts to find a matching path using the require_paths of the
|
91
|
+
# Attempts to find a matching path using the require_paths of the
|
92
|
+
# given _spec_.
|
85
93
|
#
|
86
|
-
# Some of the intermediate results are cached in @lib_dirs for
|
94
|
+
# Some of the intermediate results are cached in @lib_dirs for
|
95
|
+
# speed.
|
87
96
|
#
|
88
97
|
def matching_file(spec, path) # :doc:
|
89
98
|
glob = "#{@lib_dirs[spec.object_id]}/#{path}#{SUFFIX_PATTERN}"
|
90
99
|
return true unless Dir[glob].select { |f| File.file?(f) }.empty?
|
91
100
|
end
|
92
101
|
|
93
|
-
# Return a list of all installed gemspecs, sorted by alphabetical
|
94
|
-
# version order.
|
102
|
+
# Return a list of all installed gemspecs, sorted by alphabetical
|
103
|
+
# order and in reverse version order.
|
95
104
|
def init_gemspecs
|
96
105
|
Gem.source_index.map { |_, spec| spec }.sort { |a,b|
|
97
106
|
(a.name <=> b.name).nonzero? || (b.version <=> a.version)
|