rubygems-update 1.1.1 → 1.2.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/ChangeLog +267 -1
- data/Rakefile +13 -7
- data/doc/release_notes/rel_1_2_0.rdoc +105 -0
- data/lib/rubygems.rb +82 -14
- data/lib/rubygems/command.rb +1 -1
- data/lib/rubygems/command_manager.rb +3 -2
- data/lib/rubygems/commands/cert_command.rb +1 -1
- data/lib/rubygems/commands/dependency_command.rb +57 -19
- data/lib/rubygems/commands/environment_command.rb +2 -0
- data/lib/rubygems/commands/fetch_command.rb +3 -1
- data/lib/rubygems/commands/install_command.rb +3 -3
- data/lib/rubygems/commands/list_command.rb +30 -28
- data/lib/rubygems/commands/lock_command.rb +1 -1
- data/lib/rubygems/commands/outdated_command.rb +5 -2
- data/lib/rubygems/commands/pristine_command.rb +3 -44
- data/lib/rubygems/commands/query_command.rb +80 -21
- data/lib/rubygems/commands/sources_command.rb +56 -28
- data/lib/rubygems/commands/specification_command.rb +4 -3
- data/lib/rubygems/commands/stale_command.rb +27 -0
- data/lib/rubygems/commands/update_command.rb +35 -22
- data/lib/rubygems/config_file.rb +29 -12
- data/lib/rubygems/custom_require.rb +1 -1
- data/lib/rubygems/defaults.rb +1 -1
- data/lib/rubygems/dependency.rb +63 -9
- data/lib/rubygems/dependency_installer.rb +60 -23
- data/lib/rubygems/dependency_list.rb +1 -1
- data/lib/rubygems/doc_manager.rb +5 -5
- data/lib/rubygems/gem_openssl.rb +1 -1
- data/lib/rubygems/indexer.rb +269 -84
- data/lib/rubygems/install_update_options.rb +6 -0
- data/lib/rubygems/installer.rb +35 -12
- data/lib/rubygems/local_remote_options.rb +26 -5
- data/lib/rubygems/platform.rb +15 -1
- data/lib/rubygems/remote_fetcher.rb +158 -90
- data/lib/rubygems/requirement.rb +16 -12
- data/lib/rubygems/rubygems_version.rb +1 -1
- data/lib/rubygems/security.rb +2 -2
- data/lib/rubygems/server.rb +239 -110
- data/lib/rubygems/source_index.rb +44 -18
- data/lib/rubygems/source_info_cache.rb +1 -1
- data/lib/rubygems/spec_fetcher.rb +251 -0
- data/lib/rubygems/specification.rb +120 -38
- data/lib/rubygems/test_utilities.rb +120 -0
- data/lib/rubygems/uninstaller.rb +11 -10
- data/lib/rubygems/user_interaction.rb +149 -74
- data/lib/rubygems/validator.rb +3 -3
- data/lib/rubygems/version.rb +23 -21
- data/setup.rb +105 -100
- data/test/gemutilities.rb +63 -86
- data/test/test_config.rb +0 -5
- data/test/test_gem.rb +22 -2
- data/test/test_gem_command_manager.rb +1 -1
- data/test/test_gem_commands_dependency_command.rb +125 -6
- data/test/test_gem_commands_environment_command.rb +1 -0
- data/test/test_gem_commands_fetch_command.rb +24 -4
- data/test/test_gem_commands_install_command.rb +6 -8
- data/test/{test_gem_outdated_command.rb → test_gem_commands_outdated_command.rb} +5 -2
- data/test/test_gem_commands_pristine_command.rb +13 -4
- data/test/test_gem_commands_query_command.rb +113 -37
- data/test/test_gem_commands_sources_command.rb +101 -31
- data/test/test_gem_commands_specification_command.rb +4 -1
- data/test/test_gem_commands_stale_command.rb +39 -0
- data/test/test_gem_commands_update_command.rb +17 -27
- data/test/test_gem_config_file.rb +38 -1
- data/test/test_gem_dependency.rb +51 -0
- data/test/test_gem_dependency_installer.rb +133 -25
- data/test/test_gem_gem_path_searcher.rb +4 -1
- data/test/test_gem_indexer.rb +124 -19
- data/test/test_gem_installer.rb +32 -2
- data/test/test_gem_local_remote_options.rb +6 -5
- data/test/test_gem_remote_fetcher.rb +14 -9
- data/test/test_gem_server.rb +207 -21
- data/test/test_gem_source_index.rb +203 -63
- data/test/test_gem_source_info_cache.rb +8 -6
- data/test/test_gem_source_info_cache_entry.rb +11 -9
- data/test/test_gem_spec_fetcher.rb +303 -0
- data/test/test_gem_specification.rb +91 -7
- data/test/test_gem_uninstaller.rb +21 -0
- data/test/test_gem_version.rb +14 -5
- data/test/test_kernel.rb +1 -1
- metadata +10 -73
- metadata.gz.sig +0 -0
- data/lib/rubygems/indexer/abstract_index_builder.rb +0 -88
- data/lib/rubygems/indexer/latest_index_builder.rb +0 -35
- data/lib/rubygems/indexer/marshal_index_builder.rb +0 -17
- data/lib/rubygems/indexer/master_index_builder.rb +0 -54
- data/lib/rubygems/indexer/quick_index_builder.rb +0 -50
- data/test/gem_installer_test_case.rbc +0 -0
- data/test/gem_package_tar_test_case.rbc +0 -0
- data/test/gemutilities.rbc +0 -0
- data/test/mockgemui.rbc +0 -0
- data/test/simple_gem.rbc +0 -0
- data/test/test_config.rbc +0 -0
- data/test/test_gem.rbc +0 -0
- data/test/test_gem_builder.rbc +0 -0
- data/test/test_gem_command.rbc +0 -0
- data/test/test_gem_command_manager.rbc +0 -0
- data/test/test_gem_commands_build_command.rbc +0 -0
- data/test/test_gem_commands_cert_command.rbc +0 -0
- data/test/test_gem_commands_check_command.rbc +0 -0
- data/test/test_gem_commands_contents_command.rbc +0 -0
- data/test/test_gem_commands_dependency_command.rbc +0 -0
- data/test/test_gem_commands_environment_command.rbc +0 -0
- data/test/test_gem_commands_fetch_command.rbc +0 -0
- data/test/test_gem_commands_generate_index_command.rbc +0 -0
- data/test/test_gem_commands_install_command.rbc +0 -0
- data/test/test_gem_commands_mirror_command.rbc +0 -0
- data/test/test_gem_commands_pristine_command.rbc +0 -0
- data/test/test_gem_commands_query_command.rbc +0 -0
- data/test/test_gem_commands_server_command.rbc +0 -0
- data/test/test_gem_commands_sources_command.rbc +0 -0
- data/test/test_gem_commands_specification_command.rbc +0 -0
- data/test/test_gem_commands_unpack_command.rbc +0 -0
- data/test/test_gem_commands_update_command.rbc +0 -0
- data/test/test_gem_config_file.rbc +0 -0
- data/test/test_gem_dependency.rbc +0 -0
- data/test/test_gem_dependency_installer.rbc +0 -0
- data/test/test_gem_dependency_list.rbc +0 -0
- data/test/test_gem_digest.rbc +0 -0
- data/test/test_gem_doc_manager.rbc +0 -0
- data/test/test_gem_ext_configure_builder.rbc +0 -0
- data/test/test_gem_ext_ext_conf_builder.rbc +0 -0
- data/test/test_gem_ext_rake_builder.rbc +0 -0
- data/test/test_gem_format.rbc +0 -0
- data/test/test_gem_gem_path_searcher.rbc +0 -0
- data/test/test_gem_gem_runner.rbc +0 -0
- data/test/test_gem_indexer.rbc +0 -0
- data/test/test_gem_install_update_options.rbc +0 -0
- data/test/test_gem_installer.rbc +0 -0
- data/test/test_gem_local_remote_options.rbc +0 -0
- data/test/test_gem_outdated_command.rbc +0 -0
- data/test/test_gem_package_tar_header.rbc +0 -0
- data/test/test_gem_package_tar_input.rbc +0 -0
- data/test/test_gem_package_tar_output.rbc +0 -0
- data/test/test_gem_package_tar_reader.rbc +0 -0
- data/test/test_gem_package_tar_reader_entry.rbc +0 -0
- data/test/test_gem_package_tar_writer.rbc +0 -0
- data/test/test_gem_platform.rbc +0 -0
- data/test/test_gem_remote_fetcher.rbc +0 -0
- data/test/test_gem_requirement.rbc +0 -0
- data/test/test_gem_server.rbc +0 -0
- data/test/test_gem_source_index.rbc +0 -0
- data/test/test_gem_source_info_cache.rbc +0 -0
- data/test/test_gem_source_info_cache_entry.rbc +0 -0
- data/test/test_gem_specification.rbc +0 -0
- data/test/test_gem_stream_ui.rbc +0 -0
- data/test/test_gem_uninstaller.rbc +0 -0
- data/test/test_gem_validator.rbc +0 -0
- data/test/test_gem_version.rbc +0 -0
- data/test/test_gem_version_option.rbc +0 -0
- data/test/test_kernel.rbc +0 -0
@@ -1,7 +1,8 @@
|
|
1
|
+
require 'fileutils'
|
1
2
|
require 'rubygems/command'
|
2
3
|
require 'rubygems/remote_fetcher'
|
3
4
|
require 'rubygems/source_info_cache'
|
4
|
-
require 'rubygems/
|
5
|
+
require 'rubygems/spec_fetcher'
|
5
6
|
|
6
7
|
class Gem::Commands::SourcesCommand < Gem::Command
|
7
8
|
|
@@ -21,14 +22,14 @@ class Gem::Commands::SourcesCommand < Gem::Command
|
|
21
22
|
options[:remove] = value
|
22
23
|
end
|
23
24
|
|
24
|
-
add_option '-u', '--update', 'Update source cache' do |value, options|
|
25
|
-
options[:update] = value
|
26
|
-
end
|
27
|
-
|
28
25
|
add_option '-c', '--clear-all',
|
29
26
|
'Remove all sources (clear the cache)' do |value, options|
|
30
27
|
options[:clear_all] = value
|
31
28
|
end
|
29
|
+
|
30
|
+
add_option '-u', '--update', 'Update source cache' do |value, options|
|
31
|
+
options[:update] = value
|
32
|
+
end
|
32
33
|
end
|
33
34
|
|
34
35
|
def defaults_str
|
@@ -36,9 +37,23 @@ class Gem::Commands::SourcesCommand < Gem::Command
|
|
36
37
|
end
|
37
38
|
|
38
39
|
def execute
|
39
|
-
options[:list] = !(options[:add] ||
|
40
|
+
options[:list] = !(options[:add] ||
|
41
|
+
options[:clear_all] ||
|
42
|
+
options[:remove] ||
|
43
|
+
options[:update])
|
40
44
|
|
41
45
|
if options[:clear_all] then
|
46
|
+
path = Gem::SpecFetcher.fetcher.dir
|
47
|
+
FileUtils.rm_rf path
|
48
|
+
|
49
|
+
if not File.exist?(path) then
|
50
|
+
say "*** Removed specs cache ***"
|
51
|
+
elsif not File.writable?(path) then
|
52
|
+
say "*** Unable to remove source cache (write protected) ***"
|
53
|
+
else
|
54
|
+
say "*** Unable to remove source cache ***"
|
55
|
+
end
|
56
|
+
|
42
57
|
sic = Gem::SourceInfoCache
|
43
58
|
remove_cache_file 'user', sic.user_cache_file
|
44
59
|
remove_cache_file 'latest user', sic.latest_user_cache_file
|
@@ -48,15 +63,10 @@ class Gem::Commands::SourcesCommand < Gem::Command
|
|
48
63
|
|
49
64
|
if options[:add] then
|
50
65
|
source_uri = options[:add]
|
66
|
+
uri = URI.parse source_uri
|
51
67
|
|
52
|
-
sice = Gem::SourceInfoCacheEntry.new nil, nil
|
53
68
|
begin
|
54
|
-
|
55
|
-
|
56
|
-
Gem::SourceInfoCache.cache_data[source_uri] = sice
|
57
|
-
Gem::SourceInfoCache.cache.update
|
58
|
-
Gem::SourceInfoCache.cache.flush
|
59
|
-
|
69
|
+
Gem::SpecFetcher.fetcher.load_specs uri, 'specs'
|
60
70
|
Gem.sources << source_uri
|
61
71
|
Gem.configuration.write
|
62
72
|
|
@@ -64,15 +74,24 @@ class Gem::Commands::SourcesCommand < Gem::Command
|
|
64
74
|
rescue URI::Error, ArgumentError
|
65
75
|
say "#{source_uri} is not a URI"
|
66
76
|
rescue Gem::RemoteFetcher::FetchError => e
|
67
|
-
|
68
|
-
|
69
|
-
end
|
77
|
+
yaml_uri = uri + 'yaml'
|
78
|
+
gem_repo = Gem::RemoteFetcher.fetcher.fetch_size yaml_uri rescue false
|
70
79
|
|
71
|
-
|
72
|
-
|
73
|
-
Gem::SourceInfoCache.cache.flush
|
80
|
+
if e.uri =~ /specs\.#{Regexp.escape Gem.marshal_version}\.gz$/ and
|
81
|
+
gem_repo then
|
74
82
|
|
75
|
-
|
83
|
+
alert_warning <<-EOF
|
84
|
+
RubyGems 1.2+ index not found for:
|
85
|
+
\t#{source_uri}
|
86
|
+
|
87
|
+
Will cause RubyGems to revert to legacy indexes, degrading performance.
|
88
|
+
EOF
|
89
|
+
|
90
|
+
say "#{source_uri} added to sources"
|
91
|
+
else
|
92
|
+
say "Error fetching #{source_uri}:\n\t#{e.message}"
|
93
|
+
end
|
94
|
+
end
|
76
95
|
end
|
77
96
|
|
78
97
|
if options[:remove] then
|
@@ -81,14 +100,6 @@ class Gem::Commands::SourcesCommand < Gem::Command
|
|
81
100
|
unless Gem.sources.include? source_uri then
|
82
101
|
say "source #{source_uri} not present in cache"
|
83
102
|
else
|
84
|
-
begin # HACK figure out how to get the cache w/o update
|
85
|
-
Gem::SourceInfoCache.cache
|
86
|
-
rescue Gem::RemoteFetcher::FetchError
|
87
|
-
end
|
88
|
-
|
89
|
-
Gem::SourceInfoCache.cache_data.delete source_uri
|
90
|
-
Gem::SourceInfoCache.cache.update
|
91
|
-
Gem::SourceInfoCache.cache.flush
|
92
103
|
Gem.sources.delete source_uri
|
93
104
|
Gem.configuration.write
|
94
105
|
|
@@ -96,6 +107,23 @@ class Gem::Commands::SourcesCommand < Gem::Command
|
|
96
107
|
end
|
97
108
|
end
|
98
109
|
|
110
|
+
if options[:update] then
|
111
|
+
fetcher = Gem::SpecFetcher.fetcher
|
112
|
+
|
113
|
+
if fetcher.legacy_repos.empty? then
|
114
|
+
Gem.sources.each do |update_uri|
|
115
|
+
update_uri = URI.parse update_uri
|
116
|
+
fetcher.load_specs update_uri, 'specs'
|
117
|
+
fetcher.load_specs update_uri, 'latest_specs'
|
118
|
+
end
|
119
|
+
else
|
120
|
+
Gem::SourceInfoCache.cache true
|
121
|
+
Gem::SourceInfoCache.cache.flush
|
122
|
+
end
|
123
|
+
|
124
|
+
say "source cache successfully updated"
|
125
|
+
end
|
126
|
+
|
99
127
|
if options[:list] then
|
100
128
|
say "*** CURRENT SOURCES ***"
|
101
129
|
say
|
@@ -52,9 +52,10 @@ class Gem::Commands::SpecificationCommand < Gem::Command
|
|
52
52
|
end
|
53
53
|
|
54
54
|
if remote? then
|
55
|
-
Gem::
|
56
|
-
|
57
|
-
|
55
|
+
dep = Gem::Dependency.new gem, options[:version]
|
56
|
+
found = Gem::SpecFetcher.fetcher.fetch dep
|
57
|
+
|
58
|
+
specs.push(*found.map { |spec,| spec })
|
58
59
|
end
|
59
60
|
|
60
61
|
if specs.empty? then
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'rubygems/command'
|
2
|
+
|
3
|
+
class Gem::Commands::StaleCommand < Gem::Command
|
4
|
+
def initialize
|
5
|
+
super('stale', 'List gems along with access times')
|
6
|
+
end
|
7
|
+
|
8
|
+
def usage # :nodoc:
|
9
|
+
"#{program_name}"
|
10
|
+
end
|
11
|
+
|
12
|
+
def execute
|
13
|
+
gem_to_atime = {}
|
14
|
+
Gem.source_index.each do |name, spec|
|
15
|
+
Dir["#{spec.full_gem_path}/**/*.*"].each do |file|
|
16
|
+
next if File.directory?(file)
|
17
|
+
stat = File.stat(file)
|
18
|
+
gem_to_atime[name] ||= stat.atime
|
19
|
+
gem_to_atime[name] = stat.atime if gem_to_atime[name] < stat.atime
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
gem_to_atime.sort_by { |_, atime| atime }.each do |name, atime|
|
24
|
+
say "#{name} at #{atime.strftime '%c'}"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -2,7 +2,7 @@ require 'rubygems/command'
|
|
2
2
|
require 'rubygems/command_manager'
|
3
3
|
require 'rubygems/install_update_options'
|
4
4
|
require 'rubygems/local_remote_options'
|
5
|
-
require 'rubygems/
|
5
|
+
require 'rubygems/spec_fetcher'
|
6
6
|
require 'rubygems/version_option'
|
7
7
|
require 'rubygems/commands/install_command'
|
8
8
|
|
@@ -15,11 +15,10 @@ class Gem::Commands::UpdateCommand < Gem::Command
|
|
15
15
|
def initialize
|
16
16
|
super 'update',
|
17
17
|
'Update the named gems (or all installed gems) in the local repository',
|
18
|
-
:generate_rdoc => true,
|
19
|
-
:generate_ri => true,
|
20
|
-
:force => false,
|
21
|
-
:test => false
|
22
|
-
:install_dir => Gem.dir
|
18
|
+
:generate_rdoc => true,
|
19
|
+
:generate_ri => true,
|
20
|
+
:force => false,
|
21
|
+
:test => false
|
23
22
|
|
24
23
|
add_install_update_options
|
25
24
|
|
@@ -60,21 +59,13 @@ class Gem::Commands::UpdateCommand < Gem::Command
|
|
60
59
|
|
61
60
|
hig = {} # highest installed gems
|
62
61
|
|
63
|
-
Gem
|
62
|
+
Gem.source_index.each do |name, spec|
|
64
63
|
if hig[spec.name].nil? or hig[spec.name].version < spec.version then
|
65
64
|
hig[spec.name] = spec
|
66
65
|
end
|
67
66
|
end
|
68
67
|
|
69
|
-
|
70
|
-
//
|
71
|
-
else
|
72
|
-
Regexp.union(*options[:args])
|
73
|
-
end
|
74
|
-
|
75
|
-
remote_gemspecs = Gem::SourceInfoCache.search pattern
|
76
|
-
|
77
|
-
gems_to_update = which_to_update hig, remote_gemspecs
|
68
|
+
gems_to_update = which_to_update hig, options[:args]
|
78
69
|
|
79
70
|
updated = []
|
80
71
|
|
@@ -135,20 +126,42 @@ class Gem::Commands::UpdateCommand < Gem::Command
|
|
135
126
|
end
|
136
127
|
end
|
137
128
|
|
138
|
-
def which_to_update(highest_installed_gems,
|
129
|
+
def which_to_update(highest_installed_gems, gem_names)
|
139
130
|
result = []
|
140
131
|
|
141
132
|
highest_installed_gems.each do |l_name, l_spec|
|
142
|
-
|
143
|
-
|
144
|
-
|
133
|
+
next if not gem_names.empty? and
|
134
|
+
gem_names.all? { |name| /#{name}/ !~ l_spec.name }
|
135
|
+
|
136
|
+
dependency = Gem::Dependency.new l_spec.name, "> #{l_spec.version}"
|
137
|
+
|
138
|
+
begin
|
139
|
+
fetcher = Gem::SpecFetcher.fetcher
|
140
|
+
spec_tuples = fetcher.find_matching dependency
|
141
|
+
rescue Gem::RemoteFetcher::FetchError => e
|
142
|
+
raise unless fetcher.warn_legacy e do
|
143
|
+
require 'rubygems/source_info_cache'
|
144
|
+
|
145
|
+
dependency.name = '' if dependency.name == //
|
146
|
+
|
147
|
+
specs = Gem::SourceInfoCache.search_with_source dependency
|
148
|
+
|
149
|
+
spec_tuples = specs.map do |spec, source_uri|
|
150
|
+
[[spec.name, spec.version, spec.original_platform], source_uri]
|
151
|
+
end
|
145
152
|
end
|
146
153
|
end
|
147
154
|
|
148
|
-
|
155
|
+
matching_gems = spec_tuples.select do |(name, version, platform),|
|
156
|
+
name == l_name and Gem::Platform.match platform
|
157
|
+
end
|
158
|
+
|
159
|
+
highest_remote_gem = matching_gems.sort_by do |(name, version),|
|
160
|
+
version
|
161
|
+
end.last
|
149
162
|
|
150
163
|
if highest_remote_gem and
|
151
|
-
l_spec.version < highest_remote_gem.
|
164
|
+
l_spec.version < highest_remote_gem.first[1] then
|
152
165
|
result << l_name
|
153
166
|
end
|
154
167
|
end
|
data/lib/rubygems/config_file.rb
CHANGED
@@ -18,6 +18,22 @@ class Gem::ConfigFile
|
|
18
18
|
DEFAULT_VERBOSITY = true
|
19
19
|
DEFAULT_UPDATE_SOURCES = true
|
20
20
|
|
21
|
+
system_config_path =
|
22
|
+
begin
|
23
|
+
require 'Win32API'
|
24
|
+
|
25
|
+
CSIDL_COMMON_APPDATA = 0x0023
|
26
|
+
path = 0.chr * 260
|
27
|
+
SHGetFolderPath = Win32API.new 'shell32', 'SHGetFolderPath', 'LLLLP', 'L'
|
28
|
+
SHGetFolderPath.call 0, CSIDL_COMMON_APPDATA, 0, 1, path
|
29
|
+
|
30
|
+
path.strip
|
31
|
+
rescue LoadError
|
32
|
+
'/etc'
|
33
|
+
end
|
34
|
+
|
35
|
+
SYSTEM_WIDE_CONFIG_FILE = File.join system_config_path, 'gemrc'
|
36
|
+
|
21
37
|
# List of arguments supplied to the config file object.
|
22
38
|
attr_reader :args
|
23
39
|
|
@@ -63,6 +79,7 @@ class Gem::ConfigFile
|
|
63
79
|
arg_list = arg_list.map do |arg|
|
64
80
|
if need_config_file_name then
|
65
81
|
@config_file_name = arg
|
82
|
+
need_config_file_name = false
|
66
83
|
nil
|
67
84
|
elsif arg =~ /^--config-file=(.*)/ then
|
68
85
|
@config_file_name = $1
|
@@ -81,18 +98,8 @@ class Gem::ConfigFile
|
|
81
98
|
@verbose = DEFAULT_VERBOSITY
|
82
99
|
@update_sources = DEFAULT_UPDATE_SOURCES
|
83
100
|
|
84
|
-
|
85
|
-
|
86
|
-
@hash = open(config_file_name.dup.untaint) {|f| YAML.load(f) }
|
87
|
-
rescue ArgumentError
|
88
|
-
warn "Failed to load #{config_file_name}"
|
89
|
-
rescue Errno::ENOENT
|
90
|
-
# Ignore missing config file error.
|
91
|
-
rescue Errno::EACCES
|
92
|
-
warn "Failed to load #{config_file_name} due to permissions problem."
|
93
|
-
end
|
94
|
-
|
95
|
-
@hash ||= {}
|
101
|
+
@hash = load_file(SYSTEM_WIDE_CONFIG_FILE)
|
102
|
+
@hash.merge!(load_file(config_file_name.dup.untaint))
|
96
103
|
|
97
104
|
# HACK these override command-line args, which is bad
|
98
105
|
@backtrace = @hash[:backtrace] if @hash.key? :backtrace
|
@@ -105,6 +112,16 @@ class Gem::ConfigFile
|
|
105
112
|
handle_arguments arg_list
|
106
113
|
end
|
107
114
|
|
115
|
+
def load_file(filename)
|
116
|
+
begin
|
117
|
+
YAML.load(File.read(filename)) if filename and File.exist?(filename)
|
118
|
+
rescue ArgumentError
|
119
|
+
warn "Failed to load #{config_file_name}"
|
120
|
+
rescue Errno::EACCES
|
121
|
+
warn "Failed to load #{config_file_name} due to permissions problem."
|
122
|
+
end or {}
|
123
|
+
end
|
124
|
+
|
108
125
|
# True if the backtrace option has been specified, or debug is on.
|
109
126
|
def backtrace
|
110
127
|
@backtrace or $DEBUG
|
@@ -26,7 +26,7 @@ module Kernel
|
|
26
26
|
def require(path) # :nodoc:
|
27
27
|
gem_original_require path
|
28
28
|
rescue LoadError => load_error
|
29
|
-
if load_error.message =~
|
29
|
+
if load_error.message =~ /#{Regexp.escape path}\z/ and
|
30
30
|
spec = Gem.searcher.find(path) then
|
31
31
|
Gem.activate(spec.name, "= #{spec.version}")
|
32
32
|
gem_original_require path
|
data/lib/rubygems/defaults.rb
CHANGED
data/lib/rubygems/dependency.rb
CHANGED
@@ -8,24 +8,54 @@ require 'rubygems'
|
|
8
8
|
|
9
9
|
##
|
10
10
|
# The Dependency class holds a Gem name and a Gem::Requirement
|
11
|
+
|
11
12
|
class Gem::Dependency
|
12
13
|
|
14
|
+
##
|
15
|
+
# Valid dependency types.
|
16
|
+
#--
|
17
|
+
# When this list is updated, be sure to change
|
18
|
+
# Gem::Specification::CURRENT_SPECIFICATION_VERSION as well.
|
19
|
+
|
20
|
+
TYPES = [
|
21
|
+
:development,
|
22
|
+
:runtime,
|
23
|
+
]
|
24
|
+
|
25
|
+
##
|
26
|
+
# Dependency name or regular expression.
|
27
|
+
|
13
28
|
attr_accessor :name
|
14
29
|
|
30
|
+
##
|
31
|
+
# Dependency type.
|
32
|
+
|
33
|
+
attr_reader :type
|
34
|
+
|
35
|
+
##
|
36
|
+
# Dependent versions.
|
37
|
+
|
15
38
|
attr_writer :version_requirements
|
16
39
|
|
40
|
+
##
|
41
|
+
# Orders dependencies by name only.
|
42
|
+
|
17
43
|
def <=>(other)
|
18
44
|
[@name] <=> [other.name]
|
19
45
|
end
|
20
46
|
|
21
47
|
##
|
22
|
-
# Constructs
|
23
|
-
|
24
|
-
|
25
|
-
# version_requirements:: [String Array] version requirement (e.g. ["> 1.2"])
|
26
|
-
#
|
27
|
-
def initialize(name, version_requirements)
|
48
|
+
# Constructs a dependency with +name+ and +requirements+.
|
49
|
+
|
50
|
+
def initialize(name, version_requirements, type=:runtime)
|
28
51
|
@name = name
|
52
|
+
|
53
|
+
unless TYPES.include? type
|
54
|
+
raise ArgumentError, "Valid types are #{TYPES.inspect}, not #{@type.inspect}"
|
55
|
+
end
|
56
|
+
|
57
|
+
@type = type
|
58
|
+
|
29
59
|
@version_requirements = Gem::Requirement.create version_requirements
|
30
60
|
@version_requirement = nil # Avoid warnings.
|
31
61
|
end
|
@@ -48,17 +78,41 @@ class Gem::Dependency
|
|
48
78
|
end
|
49
79
|
|
50
80
|
def to_s # :nodoc:
|
51
|
-
"#{name} (#{version_requirements})"
|
81
|
+
"#{name} (#{version_requirements}, #{@type || :runtime})"
|
52
82
|
end
|
53
83
|
|
54
84
|
def ==(other) # :nodoc:
|
55
85
|
self.class === other &&
|
56
86
|
self.name == other.name &&
|
87
|
+
self.type == other.type &&
|
57
88
|
self.version_requirements == other.version_requirements
|
58
89
|
end
|
59
90
|
|
60
|
-
|
61
|
-
|
91
|
+
##
|
92
|
+
# Uses this dependency as a pattern to compare to the dependency +other+.
|
93
|
+
# This dependency will match if the name matches the other's name, and other
|
94
|
+
# has only an equal version requirement that satisfies this dependency.
|
95
|
+
|
96
|
+
def =~(other)
|
97
|
+
return false unless self.class === other
|
98
|
+
|
99
|
+
pattern = @name
|
100
|
+
pattern = /\A#{@name}\Z/ unless Regexp === pattern
|
101
|
+
|
102
|
+
return false unless pattern =~ other.name
|
103
|
+
|
104
|
+
reqs = other.version_requirements.requirements
|
105
|
+
|
106
|
+
return false unless reqs.length == 1
|
107
|
+
return false unless reqs.first.first == '='
|
108
|
+
|
109
|
+
version = reqs.first.last
|
110
|
+
|
111
|
+
version_requirements.satisfied_by? version
|
112
|
+
end
|
113
|
+
|
114
|
+
def hash # :nodoc:
|
115
|
+
name.hash + type.hash + version_requirements.hash
|
62
116
|
end
|
63
117
|
|
64
118
|
end
|