rubygems-update 1.6.2 → 1.7.0
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.tar.gz.sig +0 -0
- data/.autotest +0 -1
- data/History.txt +70 -4
- data/README.rdoc +3 -0
- data/Rakefile +76 -0
- data/lib/rubygems.rb +57 -27
- data/lib/rubygems/command.rb +6 -4
- data/lib/rubygems/commands/contents_command.rb +14 -11
- data/lib/rubygems/commands/fetch_command.rb +6 -3
- data/lib/rubygems/commands/outdated_command.rb +2 -1
- data/lib/rubygems/commands/pristine_command.rb +4 -3
- data/lib/rubygems/commands/unpack_command.rb +46 -4
- data/lib/rubygems/commands/update_command.rb +24 -10
- data/lib/rubygems/custom_require.rb +1 -2
- data/lib/rubygems/dependency_installer.rb +1 -1
- data/lib/rubygems/ext/rake_builder.rb +1 -1
- data/lib/rubygems/gem_runner.rb +1 -0
- data/lib/rubygems/mock_gem_ui.rb +2 -1
- data/lib/rubygems/package/tar_input.rb +1 -0
- data/lib/rubygems/remote_fetcher.rb +62 -39
- data/lib/rubygems/server.rb +1 -1
- data/lib/rubygems/source_index.rb +64 -43
- data/lib/rubygems/spec_fetcher.rb +5 -6
- data/lib/rubygems/specification.rb +375 -402
- data/lib/rubygems/test_case.rb +7 -8
- data/lib/rubygems/uninstaller.rb +2 -2
- data/lib/rubygems/user_interaction.rb +27 -31
- data/test/rubygems/test_gem.rb +2 -44
- data/test/rubygems/test_gem_commands_contents_command.rb +19 -30
- data/test/rubygems/test_gem_commands_unpack_command.rb +24 -0
- data/test/rubygems/test_gem_commands_update_command.rb +26 -1
- data/test/rubygems/test_gem_dependency_installer.rb +9 -5
- data/test/rubygems/test_gem_dependency_list.rb +2 -6
- data/test/rubygems/test_gem_gem_runner.rb +1 -4
- data/test/rubygems/test_gem_installer.rb +1 -2
- data/test/rubygems/test_gem_remote_fetcher.rb +131 -24
- data/test/rubygems/test_gem_source_index.rb +7 -192
- data/test/rubygems/test_gem_specification.rb +132 -103
- metadata +9 -9
- metadata.gz.sig +0 -0
@@ -35,19 +35,22 @@ class Gem::Commands::FetchCommand < Gem::Command
|
|
35
35
|
version = options[:version] || Gem::Requirement.default
|
36
36
|
all = Gem::Requirement.default != version
|
37
37
|
|
38
|
+
platform = Gem.platforms.last
|
38
39
|
gem_names = get_all_gem_names
|
39
40
|
|
40
41
|
gem_names.each do |gem_name|
|
41
42
|
dep = Gem::Dependency.new gem_name, version
|
42
43
|
dep.prerelease = options[:prerelease]
|
43
44
|
|
44
|
-
specs_and_sources = Gem::SpecFetcher.fetcher.fetch(dep, all, true,
|
45
|
-
dep.prerelease?)
|
46
|
-
|
47
45
|
specs_and_sources, errors =
|
48
46
|
Gem::SpecFetcher.fetcher.fetch_with_errors(dep, all, true,
|
49
47
|
dep.prerelease?)
|
50
48
|
|
49
|
+
if platform then
|
50
|
+
filtered = specs_and_sources.select { |s,| s.platform == platform }
|
51
|
+
specs_and_sources = filtered unless filtered.empty?
|
52
|
+
end
|
53
|
+
|
51
54
|
spec, source_uri = specs_and_sources.sort_by { |s,| s.version }.last
|
52
55
|
|
53
56
|
if spec.nil? then
|
@@ -16,7 +16,8 @@ class Gem::Commands::OutdatedCommand < Gem::Command
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def execute
|
19
|
-
|
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
|
20
21
|
|
21
22
|
locals.outdated.sort.each do |name|
|
22
23
|
local = locals.find_name(name).last
|
@@ -51,13 +51,12 @@ revert the gem.
|
|
51
51
|
gem_name = nil
|
52
52
|
|
53
53
|
specs = if options[:all] then
|
54
|
-
Gem
|
54
|
+
Gem.source_index.map do |name, spec|
|
55
55
|
spec
|
56
56
|
end
|
57
57
|
else
|
58
58
|
gem_name = get_one_gem_name
|
59
|
-
Gem
|
60
|
-
options[:version])
|
59
|
+
Gem.source_index.find_name(gem_name, options[:version])
|
61
60
|
end
|
62
61
|
|
63
62
|
if specs.empty? then
|
@@ -76,6 +75,8 @@ revert the gem.
|
|
76
75
|
gem = spec.cache_gem
|
77
76
|
|
78
77
|
if gem.nil? then
|
78
|
+
require 'rubygems/remote_fetcher'
|
79
|
+
|
79
80
|
say "Cached gem for #{spec.full_name} not found, attempting to fetch..."
|
80
81
|
dep = Gem::Dependency.new spec.name, spec.version
|
81
82
|
Gem::RemoteFetcher.fetcher.download_to_cache dep
|
@@ -19,6 +19,10 @@ class Gem::Commands::UnpackCommand < Gem::Command
|
|
19
19
|
options[:target] = value
|
20
20
|
end
|
21
21
|
|
22
|
+
add_option('--spec', 'unpack the gem specification') do |value, options|
|
23
|
+
options[:spec] = true
|
24
|
+
end
|
25
|
+
|
22
26
|
add_version_option
|
23
27
|
end
|
24
28
|
|
@@ -44,14 +48,28 @@ class Gem::Commands::UnpackCommand < Gem::Command
|
|
44
48
|
dependency = Gem::Dependency.new name, options[:version]
|
45
49
|
path = get_path dependency
|
46
50
|
|
47
|
-
|
51
|
+
unless path then
|
52
|
+
alert_error "Gem '#{name}' not installed nor fetchable."
|
53
|
+
next
|
54
|
+
end
|
55
|
+
|
56
|
+
if @options[:spec] then
|
57
|
+
spec, metadata = get_metadata path
|
58
|
+
|
59
|
+
if metadata.nil? then
|
60
|
+
alert_error "--spec is unsupported on '#{name}' (old format gem)"
|
61
|
+
next
|
62
|
+
end
|
63
|
+
|
64
|
+
open spec.spec_name, 'w' do |io|
|
65
|
+
io.write metadata
|
66
|
+
end
|
67
|
+
else
|
48
68
|
basename = File.basename path, '.gem'
|
49
69
|
target_dir = File.expand_path basename, options[:target]
|
50
70
|
FileUtils.mkdir_p target_dir
|
51
71
|
Gem::Installer.new(path, :unpack => true).unpack target_dir
|
52
72
|
say "Unpacked gem: '#{target_dir}'"
|
53
|
-
else
|
54
|
-
alert_error "Gem '#{name}' not installed."
|
55
73
|
end
|
56
74
|
end
|
57
75
|
end
|
@@ -64,7 +82,6 @@ class Gem::Commands::UnpackCommand < Gem::Command
|
|
64
82
|
# TODO: see comments in get_path() about general service.
|
65
83
|
|
66
84
|
def find_in_cache(filename)
|
67
|
-
|
68
85
|
Gem.path.each do |path|
|
69
86
|
this_path = Gem.cache_gem(filename, path)
|
70
87
|
return this_path if File.exist? this_path
|
@@ -112,5 +129,30 @@ class Gem::Commands::UnpackCommand < Gem::Command
|
|
112
129
|
path
|
113
130
|
end
|
114
131
|
|
132
|
+
##
|
133
|
+
# Extracts the Gem::Specification and raw metadata from the .gem file at
|
134
|
+
# +path+.
|
135
|
+
|
136
|
+
def get_metadata path
|
137
|
+
format = Gem::Format.from_file_by_path path
|
138
|
+
spec = format.spec
|
139
|
+
|
140
|
+
metadata = nil
|
141
|
+
|
142
|
+
open path, Gem.binary_mode do |io|
|
143
|
+
tar = Gem::Package::TarReader.new io
|
144
|
+
tar.each_entry do |entry|
|
145
|
+
case entry.full_name
|
146
|
+
when 'metadata' then
|
147
|
+
metadata = entry.read
|
148
|
+
when 'metadata.gz' then
|
149
|
+
metadata = Gem.gunzip entry.read
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
return spec, metadata
|
155
|
+
end
|
156
|
+
|
115
157
|
end
|
116
158
|
|
@@ -72,7 +72,7 @@ class Gem::Commands::UpdateCommand < Gem::Command
|
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
|
-
gems_to_update = which_to_update hig, options[:args]
|
75
|
+
gems_to_update = which_to_update hig, options[:args].uniq
|
76
76
|
|
77
77
|
updated = update_gems gems_to_update
|
78
78
|
|
@@ -117,8 +117,8 @@ class Gem::Commands::UpdateCommand < Gem::Command
|
|
117
117
|
end
|
118
118
|
|
119
119
|
def update_gems gems_to_update
|
120
|
-
gems_to_update.uniq.sort.each do |name|
|
121
|
-
update_gem name
|
120
|
+
gems_to_update.uniq.sort.each do |(name, version)|
|
121
|
+
update_gem name, version
|
122
122
|
end
|
123
123
|
|
124
124
|
@updated
|
@@ -135,6 +135,9 @@ class Gem::Commands::UpdateCommand < Gem::Command
|
|
135
135
|
|
136
136
|
options[:user_install] = false
|
137
137
|
|
138
|
+
# TODO: rename version and other variable name conflicts
|
139
|
+
# TODO: get rid of all this indirection on name and other BS
|
140
|
+
|
138
141
|
version = options[:system]
|
139
142
|
if version == true then
|
140
143
|
version = Gem::Version.new Gem::VERSION
|
@@ -152,14 +155,23 @@ class Gem::Commands::UpdateCommand < Gem::Command
|
|
152
155
|
'rubygems-update' => rubygems_update
|
153
156
|
}
|
154
157
|
|
155
|
-
gems_to_update = which_to_update hig, options[:args]
|
158
|
+
gems_to_update = which_to_update hig, options[:args], :system
|
159
|
+
name, up_ver = gems_to_update.first
|
160
|
+
current_ver = Gem::Version.new Gem::VERSION
|
161
|
+
|
162
|
+
target = if options[:system] == true then
|
163
|
+
up_ver
|
164
|
+
else
|
165
|
+
version
|
166
|
+
end
|
156
167
|
|
157
|
-
if
|
168
|
+
if current_ver == target then
|
169
|
+
# if options[:system] != true and version == current_ver then
|
158
170
|
say "Latest version currently installed. Aborting."
|
159
171
|
terminate_interaction
|
160
172
|
end
|
161
173
|
|
162
|
-
update_gem
|
174
|
+
update_gem name, target
|
163
175
|
|
164
176
|
Gem.source_index.refresh!
|
165
177
|
|
@@ -187,7 +199,7 @@ class Gem::Commands::UpdateCommand < Gem::Command
|
|
187
199
|
end
|
188
200
|
end
|
189
201
|
|
190
|
-
def which_to_update
|
202
|
+
def which_to_update highest_installed_gems, gem_names, system = false
|
191
203
|
result = []
|
192
204
|
|
193
205
|
highest_installed_gems.each do |l_name, l_spec|
|
@@ -207,9 +219,11 @@ class Gem::Commands::UpdateCommand < Gem::Command
|
|
207
219
|
version
|
208
220
|
end.last
|
209
221
|
|
210
|
-
|
211
|
-
|
212
|
-
|
222
|
+
highest_remote_gem ||= [[nil, Gem::Version.new(0), nil]] # "null" object
|
223
|
+
highest_remote_ver = highest_remote_gem.first[1]
|
224
|
+
|
225
|
+
if system or (l_spec.version < highest_remote_ver) then
|
226
|
+
result << [l_spec.name, [l_spec.version, highest_remote_ver].max]
|
213
227
|
end
|
214
228
|
end
|
215
229
|
|
@@ -46,7 +46,7 @@ class Gem::DependencyInstaller
|
|
46
46
|
def initialize(options = {})
|
47
47
|
if options[:install_dir] then
|
48
48
|
spec_dir = options[:install_dir], 'specifications'
|
49
|
-
@source_index = Gem::SourceIndex.
|
49
|
+
@source_index = Gem::SourceIndex.new [spec_dir]
|
50
50
|
else
|
51
51
|
@source_index = Gem.source_index
|
52
52
|
end
|
data/lib/rubygems/gem_runner.rb
CHANGED
@@ -25,6 +25,7 @@ Gem.load_env_plugins rescue nil
|
|
25
25
|
class Gem::GemRunner
|
26
26
|
|
27
27
|
def initialize(options={})
|
28
|
+
# TODO: nuke these options
|
28
29
|
@command_manager_class = options[:command_manager] || Gem::CommandManager
|
29
30
|
@config_file_class = options[:config_file] || Gem::ConfigFile
|
30
31
|
@doc_manager_class = options[:doc_manager] || Gem::DocManager
|
data/lib/rubygems/mock_gem_ui.rb
CHANGED
@@ -7,6 +7,7 @@ require 'rubygems/user_interaction'
|
|
7
7
|
|
8
8
|
class Gem::MockGemUi < Gem::StreamUI
|
9
9
|
class TermError < RuntimeError; end
|
10
|
+
class SystemExitException < RuntimeError; end
|
10
11
|
|
11
12
|
module TTY
|
12
13
|
|
@@ -56,7 +57,7 @@ class Gem::MockGemUi < Gem::StreamUI
|
|
56
57
|
@terminated = true
|
57
58
|
|
58
59
|
raise TermError unless status == 0
|
59
|
-
raise
|
60
|
+
raise SystemExitException, status
|
60
61
|
end
|
61
62
|
|
62
63
|
end
|
@@ -69,6 +69,7 @@ class Gem::RemoteFetcher
|
|
69
69
|
when URI::HTTP then proxy
|
70
70
|
else URI.parse(proxy)
|
71
71
|
end
|
72
|
+
@user_agent = user_agent
|
72
73
|
end
|
73
74
|
|
74
75
|
##
|
@@ -186,19 +187,55 @@ class Gem::RemoteFetcher
|
|
186
187
|
local_gem_path
|
187
188
|
end
|
188
189
|
|
190
|
+
##
|
191
|
+
# File Fetcher. Dispatched by +fetch_path+. Use it instead.
|
192
|
+
|
193
|
+
def fetch_file uri, *_
|
194
|
+
Gem.read_binary correct_for_windows_path uri.path
|
195
|
+
end
|
196
|
+
|
197
|
+
##
|
198
|
+
# HTTP Fetcher. Dispatched by +fetch_path+. Use it instead.
|
199
|
+
|
200
|
+
def fetch_http uri, last_modified = nil, head = false, depth = 0
|
201
|
+
fetch_type = head ? Net::HTTP::Head : Net::HTTP::Get
|
202
|
+
response = request uri, fetch_type, last_modified
|
203
|
+
|
204
|
+
case response
|
205
|
+
when Net::HTTPOK, Net::HTTPNotModified then
|
206
|
+
head ? response : response.body
|
207
|
+
when Net::HTTPMovedPermanently, Net::HTTPFound, Net::HTTPSeeOther,
|
208
|
+
Net::HTTPTemporaryRedirect then
|
209
|
+
raise FetchError.new('too many redirects', uri) if depth > 10
|
210
|
+
|
211
|
+
location = URI.parse response['Location']
|
212
|
+
fetch_http(location, last_modified, head, depth + 1)
|
213
|
+
else
|
214
|
+
raise FetchError.new("bad response #{response.message} #{response.code}", uri)
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
alias :fetch_https :fetch_http
|
219
|
+
|
189
220
|
##
|
190
221
|
# Downloads +uri+ and returns it as a String.
|
191
222
|
|
192
223
|
def fetch_path(uri, mtime = nil, head = false)
|
193
|
-
|
224
|
+
uri = URI.parse uri unless URI::Generic === uri
|
225
|
+
|
226
|
+
raise ArgumentError, "bad uri: #{uri}" unless uri
|
227
|
+
raise ArgumentError, "uri scheme is invalid: #{uri.scheme.inspect}" unless
|
228
|
+
uri.scheme
|
229
|
+
|
230
|
+
data = send "fetch_#{uri.scheme}", uri, mtime, head
|
194
231
|
data = Gem.gunzip data if data and not head and uri.to_s =~ /gz$/
|
195
232
|
data
|
196
233
|
rescue FetchError
|
197
234
|
raise
|
198
235
|
rescue Timeout::Error
|
199
|
-
raise FetchError.new('timed out', uri)
|
236
|
+
raise FetchError.new('timed out', uri.to_s)
|
200
237
|
rescue IOError, SocketError, SystemCallError => e
|
201
|
-
raise FetchError.new("#{e.class}: #{e}", uri)
|
238
|
+
raise FetchError.new("#{e.class}: #{e}", uri.to_s)
|
202
239
|
end
|
203
240
|
|
204
241
|
##
|
@@ -300,36 +337,8 @@ class Gem::RemoteFetcher
|
|
300
337
|
# read from the filesystem instead.
|
301
338
|
|
302
339
|
def open_uri_or_path(uri, last_modified = nil, head = false, depth = 0)
|
303
|
-
raise "
|
304
|
-
|
305
|
-
uri = URI.parse uri unless URI::Generic === uri
|
306
|
-
|
307
|
-
# This check is redundant unless Gem::RemoteFetcher is likely
|
308
|
-
# to be used directly, since the scheme is checked elsewhere.
|
309
|
-
# - Daniel Berger
|
310
|
-
unless ['http', 'https', 'file'].include?(uri.scheme)
|
311
|
-
raise ArgumentError, 'uri scheme is invalid'
|
312
|
-
end
|
313
|
-
|
314
|
-
if uri.scheme == 'file'
|
315
|
-
path = correct_for_windows_path(uri.path)
|
316
|
-
return Gem.read_binary(path)
|
317
|
-
end
|
318
|
-
|
319
|
-
fetch_type = head ? Net::HTTP::Head : Net::HTTP::Get
|
320
|
-
response = request uri, fetch_type, last_modified
|
321
|
-
|
322
|
-
case response
|
323
|
-
when Net::HTTPOK, Net::HTTPNotModified then
|
324
|
-
head ? response : response.body
|
325
|
-
when Net::HTTPMovedPermanently, Net::HTTPFound, Net::HTTPSeeOther,
|
326
|
-
Net::HTTPTemporaryRedirect then
|
327
|
-
raise FetchError.new('too many redirects', uri) if depth > 10
|
328
|
-
|
329
|
-
open_uri_or_path(response['Location'], last_modified, head, depth + 1)
|
330
|
-
else
|
331
|
-
raise FetchError.new("bad response #{response.message} #{response.code}", uri)
|
332
|
-
end
|
340
|
+
raise "NO: Use fetch_path instead"
|
341
|
+
# TODO: deprecate for fetch_path
|
333
342
|
end
|
334
343
|
|
335
344
|
##
|
@@ -344,12 +353,7 @@ class Gem::RemoteFetcher
|
|
344
353
|
request.basic_auth uri.user, uri.password
|
345
354
|
end
|
346
355
|
|
347
|
-
|
348
|
-
ua << " Ruby/#{RUBY_VERSION} (#{RUBY_RELEASE_DATE}"
|
349
|
-
ua << " patchlevel #{RUBY_PATCHLEVEL}" if defined? RUBY_PATCHLEVEL
|
350
|
-
ua << ")"
|
351
|
-
|
352
|
-
request.add_field 'User-Agent', ua
|
356
|
+
request.add_field 'User-Agent', @user_agent
|
353
357
|
request.add_field 'Connection', 'keep-alive'
|
354
358
|
request.add_field 'Keep-Alive', '30'
|
355
359
|
|
@@ -441,5 +445,24 @@ class Gem::RemoteFetcher
|
|
441
445
|
connection.start
|
442
446
|
end
|
443
447
|
|
448
|
+
def user_agent
|
449
|
+
ua = "RubyGems/#{Gem::VERSION} #{Gem::Platform.local}"
|
450
|
+
|
451
|
+
ruby_version = RUBY_VERSION
|
452
|
+
ruby_version += 'dev' if RUBY_PATCHLEVEL == -1
|
453
|
+
|
454
|
+
ua << " Ruby/#{ruby_version} (#{RUBY_RELEASE_DATE}"
|
455
|
+
if RUBY_PATCHLEVEL >= 0 then
|
456
|
+
ua << " patchlevel #{RUBY_PATCHLEVEL}"
|
457
|
+
elsif defined?(RUBY_REVISION) then
|
458
|
+
ua << " revision #{RUBY_REVISION}"
|
459
|
+
end
|
460
|
+
ua << ")"
|
461
|
+
|
462
|
+
ua << " #{RUBY_ENGINE}" if defined?(RUBY_ENGINE) and RUBY_ENGINE != 'ruby'
|
463
|
+
|
464
|
+
ua
|
465
|
+
end
|
466
|
+
|
444
467
|
end
|
445
468
|
|
data/lib/rubygems/server.rb
CHANGED
@@ -5,6 +5,7 @@
|
|
5
5
|
#++
|
6
6
|
|
7
7
|
require 'rubygems/specification'
|
8
|
+
require 'rubygems/deprecate'
|
8
9
|
|
9
10
|
##
|
10
11
|
# The SourceIndex object indexes all the gems available from a
|
@@ -28,53 +29,52 @@ class Gem::SourceIndex
|
|
28
29
|
|
29
30
|
attr_accessor :spec_dirs
|
30
31
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
end
|
32
|
+
##
|
33
|
+
# Factory method to construct a source index instance for a given
|
34
|
+
# path.
|
35
|
+
#
|
36
|
+
# deprecated::
|
37
|
+
# If supplied, from_installed_gems will act just like
|
38
|
+
# +from_gems_in+. This argument is deprecated and is provided
|
39
|
+
# just for backwards compatibility, and should not generally
|
40
|
+
# be used.
|
41
|
+
#
|
42
|
+
# return::
|
43
|
+
# SourceIndex instance
|
44
|
+
|
45
|
+
def self.from_installed_gems(*deprecated)
|
46
|
+
if deprecated.empty?
|
47
|
+
from_gems_in(*installed_spec_directories)
|
48
|
+
else
|
49
|
+
warn "NOTE: from_installed_gems(arg) is deprecated. From #{caller.first}"
|
50
|
+
from_gems_in(*deprecated) # HACK warn
|
51
51
|
end
|
52
|
+
end
|
52
53
|
|
53
|
-
|
54
|
-
|
54
|
+
##
|
55
|
+
# Returns a list of directories from Gem.path that contain specifications.
|
55
56
|
|
56
|
-
|
57
|
-
|
58
|
-
|
57
|
+
def self.installed_spec_directories
|
58
|
+
# TODO: move to Gem::Utils
|
59
|
+
Gem.path.collect { |dir| File.join(dir, "specifications") }
|
60
|
+
end
|
59
61
|
|
60
|
-
|
61
|
-
|
62
|
-
|
62
|
+
##
|
63
|
+
# Creates a new SourceIndex from the ruby format gem specifications in
|
64
|
+
# +spec_dirs+.
|
63
65
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
source_index.refresh!
|
68
|
-
end
|
66
|
+
def self.from_gems_in(*spec_dirs)
|
67
|
+
new spec_dirs
|
68
|
+
end
|
69
69
|
|
70
|
-
|
71
|
-
|
72
|
-
|
70
|
+
##
|
71
|
+
# Loads a ruby-format specification from +file_name+ and returns the
|
72
|
+
# loaded spec.
|
73
73
|
|
74
|
-
|
74
|
+
def self.load_specification(file_name)
|
75
|
+
Deprecate.skip_during do
|
75
76
|
Gem::Specification.load file_name
|
76
77
|
end
|
77
|
-
|
78
78
|
end
|
79
79
|
|
80
80
|
##
|
@@ -84,13 +84,23 @@ class Gem::SourceIndex
|
|
84
84
|
# TODO merge @gems and @prerelease_gems and provide a separate method
|
85
85
|
# #prerelease_gems
|
86
86
|
|
87
|
-
def initialize
|
87
|
+
def initialize specs_or_dirs = []
|
88
88
|
@gems = {}
|
89
|
-
specifications.each{ |full_name, spec| add_spec spec }
|
90
89
|
@spec_dirs = nil
|
90
|
+
|
91
|
+
case specs_or_dirs
|
92
|
+
when Hash then
|
93
|
+
warn "NOTE: SourceIndex.new(hash) is deprecated; From #{caller.first}."
|
94
|
+
specs_or_dirs.each{ |full_name, spec| add_spec spec }
|
95
|
+
when Array, String then
|
96
|
+
self.spec_dirs = Array(specs_or_dirs)
|
97
|
+
refresh!
|
98
|
+
else
|
99
|
+
arg = specs_or_dirs.inspect
|
100
|
+
warn "NOTE: SourceIndex.new(#{arg}) is deprecated; From #{caller.first}."
|
101
|
+
end
|
91
102
|
end
|
92
103
|
|
93
|
-
# TODO: remove method
|
94
104
|
def all_gems
|
95
105
|
@gems
|
96
106
|
end
|
@@ -113,7 +123,9 @@ class Gem::SourceIndex
|
|
113
123
|
spec_files = Dir.glob File.join(spec_dir, '*.gemspec')
|
114
124
|
|
115
125
|
spec_files.each do |spec_file|
|
116
|
-
gemspec =
|
126
|
+
gemspec = Deprecate.skip_during do
|
127
|
+
Gem::Specification.load spec_file
|
128
|
+
end
|
117
129
|
add_spec gemspec if gemspec
|
118
130
|
end
|
119
131
|
end
|
@@ -284,7 +296,7 @@ class Gem::SourceIndex
|
|
284
296
|
requirement = Gem::Requirement.create requirement
|
285
297
|
end
|
286
298
|
|
287
|
-
specs =
|
299
|
+
specs = @gems.values.select do |spec|
|
288
300
|
spec.name =~ gem_pattern and
|
289
301
|
requirement.satisfied_by? spec.version
|
290
302
|
end
|
@@ -338,6 +350,15 @@ class Gem::SourceIndex
|
|
338
350
|
Marshal.dump(self)
|
339
351
|
end
|
340
352
|
|
353
|
+
extend Deprecate
|
354
|
+
deprecate :all_gems, :none, 2011, 10
|
355
|
+
|
356
|
+
class << self
|
357
|
+
extend Deprecate
|
358
|
+
deprecate :from_installed_gems, :none, 2011, 10
|
359
|
+
deprecate :from_gems_in, :none, 2011, 10
|
360
|
+
deprecate :load_specification, :none, 2011, 10
|
361
|
+
end
|
341
362
|
end
|
342
363
|
|
343
364
|
# :stopdoc:
|