rubygems-update 1.7.2 → 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rubygems-update might be problematic. Click here for more details.
- data.tar.gz.sig +0 -0
- data/.autotest +5 -1
- data/History.txt +101 -4
- data/LICENSE.txt +42 -37
- data/MIT.txt +20 -0
- data/Manifest.txt +5 -4
- data/Rakefile +6 -7
- data/lib/rubygems.rb +175 -278
- data/lib/rubygems/builder.rb +7 -6
- data/lib/rubygems/command_manager.rb +16 -2
- data/lib/rubygems/commands/build_command.rb +13 -11
- data/lib/rubygems/commands/cert_command.rb +1 -1
- data/lib/rubygems/commands/cleanup_command.rb +10 -19
- data/lib/rubygems/commands/contents_command.rb +5 -5
- data/lib/rubygems/commands/dependency_command.rb +17 -40
- data/lib/rubygems/commands/fetch_command.rb +1 -1
- data/lib/rubygems/commands/install_command.rb +2 -1
- data/lib/rubygems/commands/lock_command.rb +4 -4
- data/lib/rubygems/commands/outdated_command.rb +18 -6
- data/lib/rubygems/commands/pristine_command.rb +25 -15
- data/lib/rubygems/commands/query_command.rb +9 -6
- data/lib/rubygems/commands/setup_command.rb +1 -1
- data/lib/rubygems/commands/specification_command.rb +8 -23
- data/lib/rubygems/commands/stale_command.rb +2 -1
- data/lib/rubygems/commands/unpack_command.rb +7 -5
- data/lib/rubygems/commands/update_command.rb +2 -4
- data/lib/rubygems/commands/which_command.rb +5 -9
- data/lib/rubygems/config_file.rb +9 -7
- data/lib/rubygems/custom_require.rb +6 -4
- data/lib/rubygems/defaults.rb +30 -14
- data/lib/rubygems/dependency.rb +44 -1
- data/lib/rubygems/dependency_installer.rb +37 -41
- data/lib/rubygems/dependency_list.rb +20 -9
- data/lib/rubygems/deprecate.rb +3 -3
- data/lib/rubygems/doc_manager.rb +10 -11
- data/lib/rubygems/ext/rake_builder.rb +1 -1
- data/lib/rubygems/gem_path_searcher.rb +19 -4
- data/lib/rubygems/gem_runner.rb +1 -1
- data/lib/rubygems/indexer.rb +117 -123
- data/lib/rubygems/installer.rb +101 -94
- data/lib/rubygems/installer_test_case.rb +28 -30
- data/lib/rubygems/local_remote_options.rb +1 -1
- data/lib/rubygems/mock_gem_ui.rb +10 -3
- data/lib/rubygems/package.rb +0 -26
- data/lib/rubygems/package/tar_input.rb +5 -6
- data/lib/rubygems/package_task.rb +1 -1
- data/lib/rubygems/path_support.rb +72 -0
- data/lib/rubygems/platform.rb +12 -2
- data/lib/rubygems/remote_fetcher.rb +7 -6
- data/lib/rubygems/requirement.rb +3 -0
- data/lib/rubygems/security.rb +1 -1
- data/lib/rubygems/server.rb +67 -67
- data/lib/rubygems/source_index.rb +58 -29
- data/lib/rubygems/spec_fetcher.rb +5 -1
- data/lib/rubygems/specification.rb +1422 -877
- data/lib/rubygems/test_case.rb +114 -64
- data/lib/rubygems/test_utilities.rb +4 -3
- data/lib/rubygems/text.rb +1 -1
- data/lib/rubygems/uninstaller.rb +37 -44
- data/test/rubygems/test_gem.rb +131 -102
- data/test/rubygems/test_gem_builder.rb +18 -1
- data/test/rubygems/test_gem_command_manager.rb +2 -0
- data/test/rubygems/test_gem_commands_build_command.rb +31 -3
- data/test/rubygems/test_gem_commands_cleanup_command.rb +51 -0
- data/test/rubygems/test_gem_commands_dependency_command.rb +1 -10
- data/test/rubygems/test_gem_commands_fetch_command.rb +5 -4
- data/test/rubygems/test_gem_commands_help_command.rb +58 -0
- data/test/rubygems/test_gem_commands_install_command.rb +25 -24
- data/test/rubygems/test_gem_commands_list_command.rb +1 -4
- data/test/rubygems/test_gem_commands_outdated_command.rb +10 -9
- data/test/rubygems/test_gem_commands_pristine_command.rb +63 -22
- data/test/rubygems/test_gem_commands_push_command.rb +1 -1
- data/test/rubygems/test_gem_commands_query_command.rb +15 -82
- data/test/rubygems/test_gem_commands_sources_command.rb +8 -9
- data/test/rubygems/test_gem_commands_specification_command.rb +10 -6
- data/test/rubygems/test_gem_commands_stale_command.rb +4 -4
- data/test/rubygems/test_gem_commands_unpack_command.rb +20 -21
- data/test/rubygems/test_gem_commands_update_command.rb +19 -23
- data/test/rubygems/test_gem_commands_which_command.rb +7 -4
- data/test/rubygems/test_gem_dependency.rb +14 -8
- data/test/rubygems/test_gem_dependency_installer.rb +87 -33
- data/test/rubygems/test_gem_dependency_list.rb +7 -3
- data/test/rubygems/test_gem_doc_manager.rb +3 -3
- data/test/rubygems/test_gem_format.rb +1 -1
- data/test/rubygems/test_gem_gem_path_searcher.rb +45 -29
- data/test/rubygems/test_gem_indexer.rb +48 -47
- data/test/rubygems/test_gem_install_update_options.rb +6 -5
- data/test/rubygems/test_gem_installer.rb +61 -37
- data/test/rubygems/test_gem_path_support.rb +58 -0
- data/test/rubygems/test_gem_platform.rb +5 -5
- data/test/rubygems/test_gem_remote_fetcher.rb +18 -21
- data/test/rubygems/test_gem_server.rb +23 -15
- data/test/rubygems/test_gem_source_index.rb +165 -127
- data/test/rubygems/test_gem_spec_fetcher.rb +42 -49
- data/test/rubygems/test_gem_specification.rb +104 -74
- data/test/rubygems/test_gem_text.rb +15 -0
- data/test/rubygems/test_gem_uninstaller.rb +15 -26
- data/test/rubygems/test_kernel.rb +1 -2
- metadata +64 -14
- metadata.gz.sig +0 -0
- data/GPL.txt +0 -340
- data/pkgs/sources/lib/sources.rb +0 -3
- data/pkgs/sources/sources.gemspec +0 -14
- data/test/rubygems/functional.rb +0 -92
@@ -74,10 +74,12 @@ class Gem::Commands::QueryCommand < Gem::Command
|
|
74
74
|
exit_code |= 1
|
75
75
|
end
|
76
76
|
|
77
|
-
|
77
|
+
terminate_interaction exit_code
|
78
78
|
end
|
79
79
|
|
80
|
-
|
80
|
+
req = Gem::Requirement.default
|
81
|
+
# TODO: deprecate for real
|
82
|
+
dep = Deprecate.skip_during { Gem::Dependency.new name, req }
|
81
83
|
|
82
84
|
if local? then
|
83
85
|
if prerelease and not both? then
|
@@ -90,7 +92,9 @@ class Gem::Commands::QueryCommand < Gem::Command
|
|
90
92
|
say
|
91
93
|
end
|
92
94
|
|
93
|
-
specs = Gem.
|
95
|
+
specs = Gem::Specification.find_all { |s|
|
96
|
+
s.name =~ name and req =~ s.version
|
97
|
+
}
|
94
98
|
|
95
99
|
spec_tuples = specs.map do |spec|
|
96
100
|
[[spec.name, spec.version, spec.original_platform, spec], :local]
|
@@ -123,9 +127,8 @@ class Gem::Commands::QueryCommand < Gem::Command
|
|
123
127
|
##
|
124
128
|
# Check if gem +name+ version +version+ is installed.
|
125
129
|
|
126
|
-
def installed?(name,
|
127
|
-
|
128
|
-
!Gem.source_index.search(dep).empty?
|
130
|
+
def installed?(name, req = Gem::Requirement.default)
|
131
|
+
Gem::Specification.any? { |s| s.name =~ name and req =~ s.version }
|
129
132
|
end
|
130
133
|
|
131
134
|
def output_query_results(spec_tuples)
|
@@ -332,7 +332,7 @@ abort "#{deprecation_message}"
|
|
332
332
|
args << '--main' << 'README.rdoc' << '--quiet'
|
333
333
|
args << '.'
|
334
334
|
args << 'README.rdoc' << 'UPGRADING.rdoc'
|
335
|
-
args << 'LICENSE.txt' << '
|
335
|
+
args << 'LICENSE.txt' << 'MIT.txt' << 'History.txt'
|
336
336
|
|
337
337
|
r = RDoc::RDoc.new
|
338
338
|
r.document args
|
@@ -66,18 +66,8 @@ FIELD name of gemspec field to show
|
|
66
66
|
|
67
67
|
field = get_one_optional_argument
|
68
68
|
|
69
|
-
|
70
|
-
field
|
71
|
-
|
72
|
-
if options[:format] == :ruby then
|
73
|
-
raise Gem::CommandLineError, "--ruby and FIELD are mutually exclusive"
|
74
|
-
end
|
75
|
-
|
76
|
-
unless Gem::Specification.attribute_names.include? field then
|
77
|
-
raise Gem::CommandLineError,
|
78
|
-
"no field %p on Gem::Specification" % field.to_s
|
79
|
-
end
|
80
|
-
end
|
69
|
+
raise Gem::CommandLineError, "--ruby and FIELD are mutually exclusive" if
|
70
|
+
field and options[:format] == :ruby
|
81
71
|
|
82
72
|
if local? then
|
83
73
|
if File.exist? gem then
|
@@ -85,7 +75,7 @@ FIELD name of gemspec field to show
|
|
85
75
|
end
|
86
76
|
|
87
77
|
if specs.empty? then
|
88
|
-
specs.push(*
|
78
|
+
specs.push(*dep.matching_specs)
|
89
79
|
end
|
90
80
|
end
|
91
81
|
|
@@ -100,7 +90,11 @@ FIELD name of gemspec field to show
|
|
100
90
|
terminate_interaction 1
|
101
91
|
end
|
102
92
|
|
103
|
-
|
93
|
+
unless options[:all] then
|
94
|
+
specs = [specs.sort_by { |s| s.version }.last]
|
95
|
+
end
|
96
|
+
|
97
|
+
specs.each do |s|
|
104
98
|
s = s.send field if field
|
105
99
|
|
106
100
|
say case options[:format]
|
@@ -111,14 +105,5 @@ FIELD name of gemspec field to show
|
|
111
105
|
|
112
106
|
say "\n"
|
113
107
|
end
|
114
|
-
|
115
|
-
if options[:all] then
|
116
|
-
specs.each(&output)
|
117
|
-
else
|
118
|
-
spec = specs.sort_by { |s| s.version }.last
|
119
|
-
output[spec]
|
120
|
-
end
|
121
108
|
end
|
122
|
-
|
123
109
|
end
|
124
|
-
|
@@ -11,7 +11,8 @@ class Gem::Commands::StaleCommand < Gem::Command
|
|
11
11
|
|
12
12
|
def execute
|
13
13
|
gem_to_atime = {}
|
14
|
-
Gem.
|
14
|
+
Gem::Specification.each do |spec|
|
15
|
+
name = spec.full_name
|
15
16
|
Dir["#{spec.full_gem_path}/**/*.*"].each do |file|
|
16
17
|
next if File.directory?(file)
|
17
18
|
stat = File.stat(file)
|
@@ -61,7 +61,9 @@ class Gem::Commands::UnpackCommand < Gem::Command
|
|
61
61
|
next
|
62
62
|
end
|
63
63
|
|
64
|
-
|
64
|
+
spec_file = File.basename spec.spec_file
|
65
|
+
|
66
|
+
open spec_file, 'w' do |io|
|
65
67
|
io.write metadata
|
66
68
|
end
|
67
69
|
else
|
@@ -83,7 +85,7 @@ class Gem::Commands::UnpackCommand < Gem::Command
|
|
83
85
|
|
84
86
|
def find_in_cache(filename)
|
85
87
|
Gem.path.each do |path|
|
86
|
-
this_path =
|
88
|
+
this_path = File.join(path, "cache", filename)
|
87
89
|
return this_path if File.exist? this_path
|
88
90
|
end
|
89
91
|
|
@@ -110,9 +112,9 @@ class Gem::Commands::UnpackCommand < Gem::Command
|
|
110
112
|
def get_path dependency
|
111
113
|
return dependency.name if dependency.name =~ /\.gem$/i
|
112
114
|
|
113
|
-
specs =
|
115
|
+
specs = dependency.matching_specs
|
114
116
|
|
115
|
-
selected = specs.sort_by { |s| s.version }.last
|
117
|
+
selected = specs.sort_by { |s| s.version }.last # HACK: hunt last down
|
116
118
|
|
117
119
|
return Gem::RemoteFetcher.fetcher.download_to_cache(dependency) unless
|
118
120
|
selected
|
@@ -122,7 +124,7 @@ class Gem::Commands::UnpackCommand < Gem::Command
|
|
122
124
|
# We expect to find (basename).gem in the 'cache' directory. Furthermore,
|
123
125
|
# the name match must be exact (ignoring case).
|
124
126
|
|
125
|
-
path = find_in_cache selected.
|
127
|
+
path = find_in_cache File.basename selected.cache_file
|
126
128
|
|
127
129
|
return Gem::RemoteFetcher.fetcher.download_to_cache(dependency) unless path
|
128
130
|
|
@@ -65,7 +65,7 @@ class Gem::Commands::UpdateCommand < Gem::Command
|
|
65
65
|
|
66
66
|
hig = {} # highest installed gems
|
67
67
|
|
68
|
-
Gem.
|
68
|
+
Gem::Specification.each do |spec|
|
69
69
|
if hig[spec.name].nil? or hig[spec.name].version < spec.version then
|
70
70
|
hig[spec.name] = spec
|
71
71
|
end
|
@@ -173,9 +173,7 @@ class Gem::Commands::UpdateCommand < Gem::Command
|
|
173
173
|
|
174
174
|
update_gem name, target
|
175
175
|
|
176
|
-
Gem.
|
177
|
-
|
178
|
-
installed_gems = Gem.source_index.find_name 'rubygems-update', requirement
|
176
|
+
installed_gems = Gem::Specification.find_all_by_name 'rubygems-update', requirement
|
179
177
|
version = installed_gems.last.version
|
180
178
|
|
181
179
|
args = []
|
@@ -1,10 +1,6 @@
|
|
1
1
|
require 'rubygems/command'
|
2
|
-
require 'rubygems/gem_path_searcher'
|
3
2
|
|
4
3
|
class Gem::Commands::WhichCommand < Gem::Command
|
5
|
-
|
6
|
-
EXT = %w[.rb .rbw .so .dll .bundle] # HACK
|
7
|
-
|
8
4
|
def initialize
|
9
5
|
super 'which', 'Find the location of a library file you can require',
|
10
6
|
:search_gems_first => false, :show_all => false
|
@@ -28,14 +24,13 @@ class Gem::Commands::WhichCommand < Gem::Command
|
|
28
24
|
end
|
29
25
|
|
30
26
|
def execute
|
31
|
-
searcher = Gem::GemPathSearcher.new
|
32
|
-
|
33
27
|
found = false
|
34
28
|
|
35
29
|
options[:args].each do |arg|
|
36
|
-
arg = arg.sub(/#{Regexp.union(*
|
30
|
+
arg = arg.sub(/#{Regexp.union(*Gem.suffixes)}$/, '')
|
37
31
|
dirs = $LOAD_PATH
|
38
|
-
|
32
|
+
|
33
|
+
spec = Gem::Specification.find_by_path arg
|
39
34
|
|
40
35
|
if spec then
|
41
36
|
if options[:search_gems_first] then
|
@@ -45,6 +40,7 @@ class Gem::Commands::WhichCommand < Gem::Command
|
|
45
40
|
end
|
46
41
|
end
|
47
42
|
|
43
|
+
# TODO: this is totally redundant and stupid
|
48
44
|
paths = find_paths arg, dirs
|
49
45
|
|
50
46
|
if paths.empty? then
|
@@ -62,7 +58,7 @@ class Gem::Commands::WhichCommand < Gem::Command
|
|
62
58
|
result = []
|
63
59
|
|
64
60
|
dirs.each do |dir|
|
65
|
-
|
61
|
+
Gem.suffixes.each do |ext|
|
66
62
|
full_path = File.join dir, "#{package_name}#{ext}"
|
67
63
|
if File.exist? full_path then
|
68
64
|
result << full_path
|
data/lib/rubygems/config_file.rb
CHANGED
@@ -201,11 +201,15 @@ class Gem::ConfigFile
|
|
201
201
|
# Location of RubyGems.org credentials
|
202
202
|
|
203
203
|
def credentials_path
|
204
|
-
File.join
|
204
|
+
File.join Gem.user_home, '.gem', 'credentials'
|
205
205
|
end
|
206
206
|
|
207
207
|
def load_api_keys
|
208
|
-
@api_keys = File.
|
208
|
+
@api_keys = if File.exist? credentials_path then
|
209
|
+
load_file(credentials_path)
|
210
|
+
else
|
211
|
+
@hash
|
212
|
+
end
|
209
213
|
if @api_keys.key? :rubygems_api_key then
|
210
214
|
@rubygems_api_key = @api_keys[:rubygems_api_key]
|
211
215
|
@api_keys[:rubygems] = @api_keys.delete :rubygems_api_key unless @api_keys.key? :rubygems
|
@@ -215,8 +219,8 @@ class Gem::ConfigFile
|
|
215
219
|
def rubygems_api_key=(api_key)
|
216
220
|
config = load_file(credentials_path).merge(:rubygems_api_key => api_key)
|
217
221
|
|
218
|
-
dirname = File.dirname
|
219
|
-
Dir.mkdir(dirname) unless File.
|
222
|
+
dirname = File.dirname credentials_path
|
223
|
+
Dir.mkdir(dirname) unless File.exist? dirname
|
220
224
|
|
221
225
|
Gem.load_yaml
|
222
226
|
|
@@ -230,7 +234,7 @@ class Gem::ConfigFile
|
|
230
234
|
def load_file(filename)
|
231
235
|
Gem.load_yaml
|
232
236
|
|
233
|
-
return {} unless filename and File.
|
237
|
+
return {} unless filename and File.exist? filename
|
234
238
|
begin
|
235
239
|
YAML.load(File.read(filename))
|
236
240
|
rescue ArgumentError
|
@@ -354,6 +358,4 @@ class Gem::ConfigFile
|
|
354
358
|
protected
|
355
359
|
|
356
360
|
attr_reader :hash
|
357
|
-
|
358
361
|
end
|
359
|
-
|
@@ -35,18 +35,20 @@ module Kernel
|
|
35
35
|
if Gem.unresolved_deps.empty? or Gem.loaded_path? path then
|
36
36
|
gem_original_require path
|
37
37
|
else
|
38
|
-
spec = Gem.
|
38
|
+
spec = Gem::Specification.find { |s|
|
39
|
+
s.activated? and s.contains_requirable_file? path
|
40
|
+
}
|
39
41
|
|
40
42
|
unless spec then
|
41
|
-
found_specs = Gem.
|
43
|
+
found_specs = Gem::Specification.find_in_unresolved path
|
42
44
|
unless found_specs.empty? then
|
43
45
|
found_specs = [found_specs.last]
|
44
46
|
else
|
45
|
-
found_specs = Gem.
|
47
|
+
found_specs = Gem::Specification.find_in_unresolved_tree path
|
46
48
|
end
|
47
49
|
|
48
50
|
found_specs.each do |found_spec|
|
49
|
-
|
51
|
+
found_spec.activate
|
50
52
|
end
|
51
53
|
end
|
52
54
|
|
data/lib/rubygems/defaults.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
module Gem
|
2
2
|
|
3
|
+
# TODO: move this whole file back into rubygems.rb
|
4
|
+
|
3
5
|
@post_install_hooks ||= []
|
4
6
|
@post_uninstall_hooks ||= []
|
5
7
|
@pre_uninstall_hooks ||= []
|
@@ -17,16 +19,28 @@ module Gem
|
|
17
19
|
# specified in the environment
|
18
20
|
|
19
21
|
def self.default_dir
|
20
|
-
if defined? RUBY_FRAMEWORK_VERSION then
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
22
|
+
path = if defined? RUBY_FRAMEWORK_VERSION then
|
23
|
+
[
|
24
|
+
File.dirname(ConfigMap[:sitedir]),
|
25
|
+
'Gems',
|
26
|
+
ConfigMap[:ruby_version]
|
27
|
+
]
|
28
|
+
elsif ConfigMap[:rubylibprefix] then
|
29
|
+
[
|
30
|
+
ConfigMap[:rubylibprefix],
|
31
|
+
'gems',
|
32
|
+
ConfigMap[:ruby_version]
|
33
|
+
]
|
34
|
+
else
|
35
|
+
[
|
36
|
+
ConfigMap[:libdir],
|
37
|
+
ruby_engine,
|
38
|
+
'gems',
|
39
|
+
ConfigMap[:ruby_version]
|
40
|
+
]
|
41
|
+
end
|
42
|
+
|
43
|
+
@default_dir ||= File.join(*path)
|
30
44
|
end
|
31
45
|
|
32
46
|
##
|
@@ -76,14 +90,18 @@ module Gem
|
|
76
90
|
# The default system-wide source info cache directory
|
77
91
|
|
78
92
|
def self.default_system_source_cache_dir
|
79
|
-
File.join
|
93
|
+
File.join(Gem.dir, 'source_cache')
|
80
94
|
end
|
81
95
|
|
82
96
|
##
|
83
97
|
# The default user-specific source info cache directory
|
84
98
|
|
85
99
|
def self.default_user_source_cache_dir
|
86
|
-
|
100
|
+
#
|
101
|
+
# NOTE Probably an argument for moving this to per-ruby supported dirs like
|
102
|
+
# user_dir
|
103
|
+
#
|
104
|
+
File.join(Gem.user_home, '.gem', 'source_cache')
|
87
105
|
end
|
88
106
|
|
89
107
|
##
|
@@ -96,6 +114,4 @@ module Gem
|
|
96
114
|
'ruby'
|
97
115
|
end
|
98
116
|
end
|
99
|
-
|
100
117
|
end
|
101
|
-
|
data/lib/rubygems/dependency.rb
CHANGED
@@ -32,6 +32,12 @@ class Gem::Dependency
|
|
32
32
|
# <tt>:runtime</tt>.
|
33
33
|
|
34
34
|
def initialize name, *requirements
|
35
|
+
if Regexp === name then
|
36
|
+
msg = ["NOTE: Dependency.new w/ a regexp is deprecated.",
|
37
|
+
"Dependency.new called from #{Gem.location_of_caller.join(":")}"]
|
38
|
+
warn msg.join("\n") unless Deprecate.skip
|
39
|
+
end
|
40
|
+
|
35
41
|
type = Symbol === requirements.last ? requirements.pop : :runtime
|
36
42
|
requirements = requirements.first if 1 == requirements.length # unpack
|
37
43
|
|
@@ -206,5 +212,42 @@ class Gem::Dependency
|
|
206
212
|
self.class.new name, self_req.as_list.concat(other_req.as_list)
|
207
213
|
end
|
208
214
|
|
209
|
-
|
215
|
+
def matching_specs platform_only = false
|
216
|
+
matches = Gem::Specification.find_all { |spec|
|
217
|
+
self.name === spec.name and # TODO: == instead of ===
|
218
|
+
requirement.satisfied_by? spec.version
|
219
|
+
}
|
220
|
+
|
221
|
+
if platform_only
|
222
|
+
matches.reject! { |spec|
|
223
|
+
not Gem::Platform.match spec.platform
|
224
|
+
}
|
225
|
+
end
|
226
|
+
|
227
|
+
matches = matches.sort_by { |s| s.sort_obj } # HACK: shouldn't be needed
|
228
|
+
end
|
229
|
+
|
230
|
+
def to_specs
|
231
|
+
matches = matching_specs true
|
232
|
+
|
233
|
+
# TODO: check Gem.activated_spec[self.name] in case matches falls outside
|
210
234
|
|
235
|
+
if matches.empty? then
|
236
|
+
specs = Gem::Specification.map(&:full_name).join ", "
|
237
|
+
error = Gem::LoadError.new "Could not find #{name} (#{requirement}) amongst [#{specs}]"
|
238
|
+
error.name = self.name
|
239
|
+
error.requirement = self.requirement
|
240
|
+
raise error
|
241
|
+
end
|
242
|
+
|
243
|
+
# TODO: any other resolver validations should go here
|
244
|
+
|
245
|
+
matches
|
246
|
+
end
|
247
|
+
|
248
|
+
def to_spec
|
249
|
+
matches = self.to_specs
|
250
|
+
|
251
|
+
matches.find { |spec| spec.activated? } or matches.last
|
252
|
+
end
|
253
|
+
end
|
@@ -15,14 +15,14 @@ class Gem::DependencyInstaller
|
|
15
15
|
attr_reader :installed_gems
|
16
16
|
|
17
17
|
DEFAULT_OPTIONS = {
|
18
|
-
:env_shebang
|
19
|
-
:domain
|
20
|
-
:force
|
21
|
-
:format_executable
|
18
|
+
:env_shebang => false,
|
19
|
+
:domain => :both, # HACK dup
|
20
|
+
:force => false,
|
21
|
+
:format_executable => false, # HACK dup
|
22
22
|
:ignore_dependencies => false,
|
23
|
-
:prerelease
|
24
|
-
:security_policy
|
25
|
-
:wrappers
|
23
|
+
:prerelease => false,
|
24
|
+
:security_policy => nil, # HACK NoSecurity requires OpenSSL. AlmostNo? Low?
|
25
|
+
:wrappers => true,
|
26
26
|
}
|
27
27
|
|
28
28
|
##
|
@@ -45,25 +45,26 @@ class Gem::DependencyInstaller
|
|
45
45
|
|
46
46
|
def initialize(options = {})
|
47
47
|
if options[:install_dir] then
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
48
|
+
@gem_home = options[:install_dir]
|
49
|
+
|
50
|
+
Gem::Specification.dirs = @gem_home
|
51
|
+
Gem.ensure_gem_subdirectories @gem_home
|
52
|
+
options[:install_dir] = @gem_home # FIX: because we suck and reuse below
|
52
53
|
end
|
53
54
|
|
54
55
|
options = DEFAULT_OPTIONS.merge options
|
55
56
|
|
56
|
-
@bin_dir
|
57
|
-
@development
|
58
|
-
@domain
|
59
|
-
@env_shebang
|
60
|
-
@force
|
61
|
-
@format_executable
|
57
|
+
@bin_dir = options[:bin_dir]
|
58
|
+
@development = options[:development]
|
59
|
+
@domain = options[:domain]
|
60
|
+
@env_shebang = options[:env_shebang]
|
61
|
+
@force = options[:force]
|
62
|
+
@format_executable = options[:format_executable]
|
62
63
|
@ignore_dependencies = options[:ignore_dependencies]
|
63
|
-
@prerelease
|
64
|
-
@security_policy
|
65
|
-
@user_install
|
66
|
-
@wrappers
|
64
|
+
@prerelease = options[:prerelease]
|
65
|
+
@security_policy = options[:security_policy]
|
66
|
+
@user_install = options[:user_install]
|
67
|
+
@wrappers = options[:wrappers]
|
67
68
|
|
68
69
|
@installed_gems = []
|
69
70
|
|
@@ -95,6 +96,7 @@ class Gem::DependencyInstaller
|
|
95
96
|
|
96
97
|
if @domain == :both or @domain == :remote then
|
97
98
|
begin
|
99
|
+
# REFACTOR: all = dep.requirement.needs_all?
|
98
100
|
requirements = dep.requirement.requirements.map do |req, ver|
|
99
101
|
req
|
100
102
|
end
|
@@ -140,8 +142,8 @@ class Gem::DependencyInstaller
|
|
140
142
|
add_found_dependencies to_do, dependency_list unless @ignore_dependencies
|
141
143
|
|
142
144
|
dependency_list.specs.reject! { |spec|
|
143
|
-
|
144
|
-
|
145
|
+
not keep_names.include?(spec.full_name) and
|
146
|
+
Gem::Specification.include?(spec)
|
145
147
|
}
|
146
148
|
|
147
149
|
unless dependency_list.ok? or @ignore_dependencies or @force then
|
@@ -175,7 +177,7 @@ class Gem::DependencyInstaller
|
|
175
177
|
to_do.push dep_spec
|
176
178
|
|
177
179
|
# already locally installed
|
178
|
-
|
180
|
+
Gem::Specification.any? do |installed_spec|
|
179
181
|
dep.name == installed_spec.name and
|
180
182
|
dep.requirement.satisfied_by? installed_spec.version
|
181
183
|
end
|
@@ -210,23 +212,20 @@ class Gem::DependencyInstaller
|
|
210
212
|
|
211
213
|
local_gems = Dir["#{glob}*"].sort.reverse
|
212
214
|
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
rescue SystemCallError, Gem::Package::FormatError
|
221
|
-
end
|
215
|
+
local_gems.each do |gem_file|
|
216
|
+
next unless gem_file =~ /gem$/
|
217
|
+
begin
|
218
|
+
spec = Gem::Format.from_file_by_path(gem_file).spec
|
219
|
+
spec_and_source = [spec, gem_file]
|
220
|
+
break
|
221
|
+
rescue SystemCallError, Gem::Package::FormatError
|
222
222
|
end
|
223
223
|
end
|
224
224
|
|
225
|
-
|
225
|
+
unless spec_and_source then
|
226
226
|
dep = Gem::Dependency.new gem_name, version
|
227
227
|
dep.prerelease = true if prerelease
|
228
228
|
spec_and_sources = find_gems_with_sources(dep).reverse
|
229
|
-
|
230
229
|
spec_and_source = spec_and_sources.find { |spec, source|
|
231
230
|
Gem::Platform.match spec.platform
|
232
231
|
}
|
@@ -267,9 +266,9 @@ class Gem::DependencyInstaller
|
|
267
266
|
|
268
267
|
gather_dependencies
|
269
268
|
|
270
|
-
@gems_to_install.
|
271
|
-
|
272
|
-
next if
|
269
|
+
last = @gems_to_install.size - 1
|
270
|
+
@gems_to_install.each_with_index do |spec, index|
|
271
|
+
next if Gem::Specification.include?(spec) and index != last
|
273
272
|
|
274
273
|
# TODO: make this sorta_verbose so other users can benefit from it
|
275
274
|
say "Installing gem #{spec.full_name}" if Gem.configuration.really_verbose
|
@@ -292,7 +291,6 @@ class Gem::DependencyInstaller
|
|
292
291
|
:ignore_dependencies => @ignore_dependencies,
|
293
292
|
:install_dir => @install_dir,
|
294
293
|
:security_policy => @security_policy,
|
295
|
-
:source_index => @source_index,
|
296
294
|
:user_install => @user_install,
|
297
295
|
:wrappers => @wrappers
|
298
296
|
|
@@ -303,6 +301,4 @@ class Gem::DependencyInstaller
|
|
303
301
|
|
304
302
|
@installed_gems
|
305
303
|
end
|
306
|
-
|
307
304
|
end
|
308
|
-
|