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
data/lib/rubygems/command.rb
CHANGED
@@ -342,7 +342,7 @@ module Gem
|
|
342
342
|
|
343
343
|
add_common_option('-V', '--[no-]verbose',
|
344
344
|
'Set the verbose level of output') do |value, options|
|
345
|
-
# Set us to "really verbose" so the
|
345
|
+
# Set us to "really verbose" so the progress meter works
|
346
346
|
if Gem.configuration.verbose and value then
|
347
347
|
Gem.configuration.verbose = 1
|
348
348
|
else
|
@@ -16,7 +16,7 @@ module Gem
|
|
16
16
|
class CommandManager
|
17
17
|
include UserInteraction
|
18
18
|
|
19
|
-
# Return the
|
19
|
+
# Return the authoritative instance of the command manager.
|
20
20
|
def self.instance
|
21
21
|
@command_manager ||= CommandManager.new
|
22
22
|
end
|
@@ -46,6 +46,7 @@ module Gem
|
|
46
46
|
register_command :server
|
47
47
|
register_command :sources
|
48
48
|
register_command :specification
|
49
|
+
register_command :stale
|
49
50
|
register_command :uninstall
|
50
51
|
register_command :unpack
|
51
52
|
register_command :update
|
@@ -69,7 +70,7 @@ module Gem
|
|
69
70
|
@commands.keys.collect {|key| key.to_s}.sort
|
70
71
|
end
|
71
72
|
|
72
|
-
# Run the config
|
73
|
+
# Run the config specified by +args+.
|
73
74
|
def run(args)
|
74
75
|
process_args(args)
|
75
76
|
rescue StandardError, Timeout::Error => ex
|
@@ -19,7 +19,7 @@ class Gem::Commands::CertCommand < Gem::Command
|
|
19
19
|
Dir::glob(glob_str) do |path|
|
20
20
|
begin
|
21
21
|
cert = OpenSSL::X509::Certificate.new(File.read(path))
|
22
|
-
# this could
|
22
|
+
# this could probably be formatted more gracefully
|
23
23
|
say cert.subject.to_s
|
24
24
|
rescue OpenSSL::X509::CertificateError
|
25
25
|
next
|
@@ -43,40 +43,77 @@ class Gem::Commands::DependencyCommand < Gem::Command
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def execute
|
46
|
-
options[:args] << '
|
46
|
+
options[:args] << '' if options[:args].empty?
|
47
47
|
specs = {}
|
48
48
|
|
49
|
-
source_indexes =
|
49
|
+
source_indexes = Hash.new do |h, source_uri|
|
50
|
+
h[source_uri] = Gem::SourceIndex.new
|
51
|
+
end
|
50
52
|
|
51
|
-
if
|
52
|
-
|
53
|
+
pattern = if options[:args].length == 1 and
|
54
|
+
options[:args].first =~ /\A\/(.*)\/(i)?\z/m then
|
55
|
+
flags = $2 ? Regexp::IGNORECASE : nil
|
56
|
+
Regexp.new $1, flags
|
57
|
+
else
|
58
|
+
/\A#{Regexp.union(*options[:args])}/
|
59
|
+
end
|
60
|
+
|
61
|
+
dependency = Gem::Dependency.new pattern, options[:version]
|
62
|
+
|
63
|
+
if options[:reverse_dependencies] and remote? and not local? then
|
64
|
+
alert_error 'Only reverse dependencies for local gems are supported.'
|
65
|
+
terminate_interaction 1
|
53
66
|
end
|
54
67
|
|
55
|
-
if
|
56
|
-
Gem
|
57
|
-
source_indexes
|
68
|
+
if local? then
|
69
|
+
Gem.source_index.search(dependency).each do |spec|
|
70
|
+
source_indexes[:local].add_spec spec
|
58
71
|
end
|
59
72
|
end
|
60
73
|
|
61
|
-
options[:
|
62
|
-
|
63
|
-
|
64
|
-
|
74
|
+
if remote? and not options[:reverse_dependencies] then
|
75
|
+
fetcher = Gem::SpecFetcher.fetcher
|
76
|
+
|
77
|
+
begin
|
78
|
+
fetcher.find_matching(dependency).each do |spec_tuple, source_uri|
|
79
|
+
spec = fetcher.fetch_spec spec_tuple, URI.parse(source_uri)
|
80
|
+
|
81
|
+
source_indexes[source_uri].add_spec spec
|
82
|
+
end
|
83
|
+
rescue Gem::RemoteFetcher::FetchError => e
|
84
|
+
raise unless fetcher.warn_legacy e do
|
85
|
+
require 'rubygems/source_info_cache'
|
86
|
+
|
87
|
+
specs = Gem::SourceInfoCache.search_with_source dependency, false
|
88
|
+
|
89
|
+
specs.each do |spec, source_uri|
|
90
|
+
source_indexes[source_uri].add_spec spec
|
91
|
+
end
|
92
|
+
end
|
65
93
|
end
|
94
|
+
end
|
66
95
|
|
67
|
-
|
68
|
-
|
96
|
+
if source_indexes.empty? then
|
97
|
+
patterns = options[:args].join ','
|
98
|
+
say "No gems found matching #{patterns} (#{options[:version]})" if
|
99
|
+
Gem.configuration.verbose
|
69
100
|
|
70
|
-
|
101
|
+
terminate_interaction 1
|
71
102
|
end
|
72
103
|
|
73
|
-
|
104
|
+
specs = {}
|
105
|
+
|
106
|
+
source_indexes.values.each do |source_index|
|
107
|
+
source_index.gems.each do |name, spec|
|
108
|
+
specs[spec.full_name] = [source_index, spec]
|
109
|
+
end
|
110
|
+
end
|
74
111
|
|
75
112
|
reverse = Hash.new { |h, k| h[k] = [] }
|
76
113
|
|
77
114
|
if options[:reverse_dependencies] then
|
78
|
-
specs.values.each do |
|
79
|
-
reverse[spec.full_name] = find_reverse_dependencies spec
|
115
|
+
specs.values.each do |_, spec|
|
116
|
+
reverse[spec.full_name] = find_reverse_dependencies spec
|
80
117
|
end
|
81
118
|
end
|
82
119
|
|
@@ -118,10 +155,10 @@ class Gem::Commands::DependencyCommand < Gem::Command
|
|
118
155
|
end
|
119
156
|
|
120
157
|
# Retuns list of [specification, dep] that are satisfied by spec.
|
121
|
-
def find_reverse_dependencies(spec
|
158
|
+
def find_reverse_dependencies(spec)
|
122
159
|
result = []
|
123
160
|
|
124
|
-
source_index.each do |name, sp|
|
161
|
+
Gem.source_index.each do |name, sp|
|
125
162
|
sp.dependencies.each do |dep|
|
126
163
|
dep = Gem::Dependency.new(*dep) unless Gem::Dependency === dep
|
127
164
|
|
@@ -146,5 +183,6 @@ class Gem::Commands::DependencyCommand < Gem::Command
|
|
146
183
|
|
147
184
|
specs
|
148
185
|
end
|
186
|
+
|
149
187
|
end
|
150
188
|
|
@@ -51,6 +51,8 @@ class Gem::Commands::EnvironmentCommand < Gem::Command
|
|
51
51
|
|
52
52
|
out << " - RUBY EXECUTABLE: #{Gem.ruby}\n"
|
53
53
|
|
54
|
+
out << " - EXECUTABLE DIRECTORY: #{Gem.bindir}\n"
|
55
|
+
|
54
56
|
out << " - RUBYGEMS PLATFORMS:\n"
|
55
57
|
Gem.platforms.each do |platform|
|
56
58
|
out << " - #{platform}\n"
|
@@ -33,12 +33,14 @@ class Gem::Commands::FetchCommand < Gem::Command
|
|
33
33
|
|
34
34
|
def execute
|
35
35
|
version = options[:version] || Gem::Requirement.default
|
36
|
+
all = Gem::Requirement.default
|
36
37
|
|
37
38
|
gem_names = get_all_gem_names
|
38
39
|
|
39
40
|
gem_names.each do |gem_name|
|
40
41
|
dep = Gem::Dependency.new gem_name, version
|
41
|
-
|
42
|
+
|
43
|
+
specs_and_sources = Gem::SpecFetcher.fetcher.fetch dep, all
|
42
44
|
|
43
45
|
specs_and_sources.sort_by { |spec,| spec.version }
|
44
46
|
|
@@ -16,7 +16,6 @@ class Gem::Commands::InstallCommand < Gem::Command
|
|
16
16
|
defaults = Gem::DependencyInstaller::DEFAULT_OPTIONS.merge({
|
17
17
|
:generate_rdoc => true,
|
18
18
|
:generate_ri => true,
|
19
|
-
:install_dir => Gem.dir,
|
20
19
|
:format_executable => false,
|
21
20
|
:test => false,
|
22
21
|
:version => Gem::Requirement.default,
|
@@ -51,7 +50,7 @@ class Gem::Commands::InstallCommand < Gem::Command
|
|
51
50
|
|
52
51
|
installed_gems = []
|
53
52
|
|
54
|
-
ENV
|
53
|
+
ENV.delete 'GEM_PATH' if options[:install_dir].nil? and RUBY_VERSION > '1.9'
|
55
54
|
|
56
55
|
install_options = {
|
57
56
|
:env_shebang => options[:env_shebang],
|
@@ -62,7 +61,8 @@ class Gem::Commands::InstallCommand < Gem::Command
|
|
62
61
|
:install_dir => options[:install_dir],
|
63
62
|
:security_policy => options[:security_policy],
|
64
63
|
:wrappers => options[:wrappers],
|
65
|
-
:bin_dir => options[:bin_dir]
|
64
|
+
:bin_dir => options[:bin_dir],
|
65
|
+
:development => options[:development],
|
66
66
|
}
|
67
67
|
|
68
68
|
exit_code = 0
|
@@ -1,33 +1,35 @@
|
|
1
1
|
require 'rubygems/command'
|
2
2
|
require 'rubygems/commands/query_command'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
def usage # :nodoc:
|
23
|
-
"#{program_name} [STRING]"
|
24
|
-
end
|
25
|
-
|
26
|
-
def execute
|
27
|
-
string = get_one_optional_argument || ''
|
28
|
-
options[:name] = /^#{string}/i
|
29
|
-
super
|
30
|
-
end
|
31
|
-
end
|
4
|
+
##
|
5
|
+
# An alternate to Gem::Commands::QueryCommand that searches for gems starting
|
6
|
+
# with the the supplied argument.
|
7
|
+
|
8
|
+
class Gem::Commands::ListCommand < Gem::Commands::QueryCommand
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
super 'list', 'Display gems whose name starts with STRING'
|
12
|
+
|
13
|
+
remove_option('--name-matches')
|
14
|
+
end
|
15
|
+
|
16
|
+
def arguments # :nodoc:
|
17
|
+
"STRING start of gem name to look for"
|
18
|
+
end
|
19
|
+
|
20
|
+
def defaults_str # :nodoc:
|
21
|
+
"--local --no-details"
|
32
22
|
end
|
23
|
+
|
24
|
+
def usage # :nodoc:
|
25
|
+
"#{program_name} [STRING]"
|
26
|
+
end
|
27
|
+
|
28
|
+
def execute
|
29
|
+
string = get_one_optional_argument || ''
|
30
|
+
options[:name] = /^#{string}/i
|
31
|
+
super
|
32
|
+
end
|
33
|
+
|
33
34
|
end
|
35
|
+
|
@@ -80,7 +80,7 @@ lock it down to the exact version.
|
|
80
80
|
say "gem '#{spec.name}', '= #{spec.version}'" unless locked[spec.name]
|
81
81
|
locked[spec.name] = true
|
82
82
|
|
83
|
-
spec.
|
83
|
+
spec.runtime_dependencies.each do |dep|
|
84
84
|
next if locked[dep.name]
|
85
85
|
candidates = Gem.source_index.search dep.name, dep.requirement_list
|
86
86
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'rubygems/command'
|
2
2
|
require 'rubygems/local_remote_options'
|
3
|
-
require 'rubygems/
|
3
|
+
require 'rubygems/spec_fetcher'
|
4
4
|
require 'rubygems/version_option'
|
5
5
|
|
6
6
|
class Gem::Commands::OutdatedCommand < Gem::Command
|
@@ -20,8 +20,11 @@ class Gem::Commands::OutdatedCommand < Gem::Command
|
|
20
20
|
|
21
21
|
locals.outdated.sort.each do |name|
|
22
22
|
local = locals.search(/^#{name}$/).last
|
23
|
-
|
23
|
+
|
24
|
+
dep = Gem::Dependency.new local.name, ">= #{local.version}"
|
25
|
+
remotes = Gem::SpecFetcher.fetcher.fetch dep
|
24
26
|
remote = remotes.last.first
|
27
|
+
|
25
28
|
say "#{local.name} (#{local.version} < #{remote.version})"
|
26
29
|
end
|
27
30
|
end
|
@@ -82,51 +82,10 @@ revert the gem.
|
|
82
82
|
end
|
83
83
|
|
84
84
|
# TODO use installer options
|
85
|
-
installer = Gem::Installer.new gem, :wrappers => true
|
85
|
+
installer = Gem::Installer.new gem, :wrappers => true, :force => true
|
86
|
+
installer.install
|
86
87
|
|
87
|
-
|
88
|
-
|
89
|
-
security_policy = nil # TODO use installer option
|
90
|
-
|
91
|
-
format = Gem::Format.from_file_by_path gem_file, security_policy
|
92
|
-
|
93
|
-
target_directory = File.join(install_dir, "gems", format.spec.full_name)
|
94
|
-
target_directory.untaint
|
95
|
-
|
96
|
-
pristine_files = format.file_entries.collect { |data| data[0]["path"] }
|
97
|
-
file_map = {}
|
98
|
-
|
99
|
-
format.file_entries.each do |entry, file_data|
|
100
|
-
file_map[entry["path"]] = file_data
|
101
|
-
end
|
102
|
-
|
103
|
-
Dir.chdir target_directory do
|
104
|
-
deployed_files = Dir.glob(File.join("**", "*")) +
|
105
|
-
Dir.glob(File.join("**", ".*"))
|
106
|
-
|
107
|
-
pristine_files = pristine_files.map { |f| File.expand_path f }
|
108
|
-
deployed_files = deployed_files.map { |f| File.expand_path f }
|
109
|
-
|
110
|
-
to_redeploy = (pristine_files - deployed_files)
|
111
|
-
to_redeploy = to_redeploy.map { |path| path.untaint}
|
112
|
-
|
113
|
-
if to_redeploy.length > 0 then
|
114
|
-
say "Restoring #{to_redeploy.length} file#{to_redeploy.length == 1 ? "" : "s"} to #{spec.full_name}..."
|
115
|
-
|
116
|
-
to_redeploy.each do |path|
|
117
|
-
say " #{path}"
|
118
|
-
FileUtils.mkdir_p File.dirname(path)
|
119
|
-
File.open(path, "wb") do |out|
|
120
|
-
out.write file_map[path]
|
121
|
-
end
|
122
|
-
end
|
123
|
-
else
|
124
|
-
say "#{spec.full_name} is in pristine condition"
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
installer.generate_bin
|
129
|
-
installer.build_extensions
|
88
|
+
say "Restored #{spec.full_name}"
|
130
89
|
end
|
131
90
|
end
|
132
91
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'rubygems/command'
|
2
2
|
require 'rubygems/local_remote_options'
|
3
|
-
require 'rubygems/
|
3
|
+
require 'rubygems/spec_fetcher'
|
4
4
|
require 'rubygems/version_option'
|
5
5
|
|
6
6
|
class Gem::Commands::QueryCommand < Gem::Command
|
@@ -74,7 +74,13 @@ class Gem::Commands::QueryCommand < Gem::Command
|
|
74
74
|
say "*** LOCAL GEMS ***"
|
75
75
|
say
|
76
76
|
|
77
|
-
|
77
|
+
specs = Gem.source_index.search name
|
78
|
+
|
79
|
+
spec_tuples = specs.map do |spec|
|
80
|
+
[[spec.name, spec.version, spec.original_platform, spec], :local]
|
81
|
+
end
|
82
|
+
|
83
|
+
output_query_results spec_tuples
|
78
84
|
end
|
79
85
|
|
80
86
|
if remote? then
|
@@ -84,13 +90,26 @@ class Gem::Commands::QueryCommand < Gem::Command
|
|
84
90
|
|
85
91
|
all = options[:all]
|
86
92
|
|
93
|
+
dep = Gem::Dependency.new name, Gem::Requirement.default
|
87
94
|
begin
|
88
|
-
Gem::
|
89
|
-
|
90
|
-
|
95
|
+
fetcher = Gem::SpecFetcher.fetcher
|
96
|
+
spec_tuples = fetcher.find_matching dep, all, false
|
97
|
+
rescue Gem::RemoteFetcher::FetchError => e
|
98
|
+
raise unless fetcher.warn_legacy e do
|
99
|
+
require 'rubygems/source_info_cache'
|
100
|
+
|
101
|
+
dep.name = '' if dep.name == //
|
102
|
+
|
103
|
+
specs = Gem::SourceInfoCache.search_with_source dep, false, all
|
104
|
+
|
105
|
+
spec_tuples = specs.map do |spec, source_uri|
|
106
|
+
[[spec.name, spec.version, spec.original_platform, spec],
|
107
|
+
source_uri]
|
108
|
+
end
|
109
|
+
end
|
91
110
|
end
|
92
111
|
|
93
|
-
output_query_results
|
112
|
+
output_query_results spec_tuples
|
94
113
|
end
|
95
114
|
end
|
96
115
|
|
@@ -104,28 +123,30 @@ class Gem::Commands::QueryCommand < Gem::Command
|
|
104
123
|
!Gem.source_index.search(dep).empty?
|
105
124
|
end
|
106
125
|
|
107
|
-
def output_query_results(
|
126
|
+
def output_query_results(spec_tuples)
|
108
127
|
output = []
|
109
|
-
|
128
|
+
versions = Hash.new { |h,name| h[name] = [] }
|
110
129
|
|
111
|
-
|
112
|
-
|
113
|
-
gem_list_with_version[gemspec.name] << gemspec
|
130
|
+
spec_tuples.each do |spec_tuple, source_uri|
|
131
|
+
versions[spec_tuple.first] << [spec_tuple, source_uri]
|
114
132
|
end
|
115
133
|
|
116
|
-
|
134
|
+
versions = versions.sort_by do |(name,_),_|
|
117
135
|
name.downcase
|
118
136
|
end
|
119
137
|
|
120
|
-
|
121
|
-
|
122
|
-
|
138
|
+
versions.each do |gem_name, matching_tuples|
|
139
|
+
matching_tuples = matching_tuples.sort_by do |(name, version,_),_|
|
140
|
+
version
|
141
|
+
end.reverse
|
123
142
|
|
124
|
-
|
125
|
-
|
143
|
+
seen = {}
|
144
|
+
|
145
|
+
matching_tuples.delete_if do |(name, version,_),_|
|
146
|
+
if seen[version] then
|
126
147
|
true
|
127
148
|
else
|
128
|
-
|
149
|
+
seen[version] = true
|
129
150
|
false
|
130
151
|
end
|
131
152
|
end
|
@@ -133,12 +154,50 @@ class Gem::Commands::QueryCommand < Gem::Command
|
|
133
154
|
entry = gem_name.dup
|
134
155
|
|
135
156
|
if options[:versions] then
|
136
|
-
versions =
|
157
|
+
versions = matching_tuples.map { |(name, version,_),_| version }.uniq
|
137
158
|
entry << " (#{versions.join ', '})"
|
138
159
|
end
|
139
160
|
|
140
|
-
|
141
|
-
|
161
|
+
if options[:details] then
|
162
|
+
detail_tuple = matching_tuples.first
|
163
|
+
|
164
|
+
spec = if detail_tuple.first.length == 4 then
|
165
|
+
detail_tuple.first.last
|
166
|
+
else
|
167
|
+
uri = URI.parse detail_tuple.last
|
168
|
+
Gem::SpecFetcher.fetcher.fetch_spec detail_tuple.first, uri
|
169
|
+
end
|
170
|
+
|
171
|
+
entry << "\n"
|
172
|
+
authors = "Author#{spec.authors.length > 1 ? 's' : ''}: "
|
173
|
+
authors << spec.authors.join(', ')
|
174
|
+
entry << format_text(authors, 68, 4)
|
175
|
+
|
176
|
+
if spec.rubyforge_project and not spec.rubyforge_project.empty? then
|
177
|
+
rubyforge = "Rubyforge: http://rubyforge.org/projects/#{spec.rubyforge_project}"
|
178
|
+
entry << "\n" << format_text(rubyforge, 68, 4)
|
179
|
+
end
|
180
|
+
|
181
|
+
if spec.homepage and not spec.homepage.empty? then
|
182
|
+
entry << "\n" << format_text("Homepage: #{spec.homepage}", 68, 4)
|
183
|
+
end
|
184
|
+
|
185
|
+
if spec.loaded_from then
|
186
|
+
if matching_tuples.length == 1 then
|
187
|
+
loaded_from = File.dirname File.dirname(spec.loaded_from)
|
188
|
+
entry << "\n" << " Installed at: #{loaded_from}"
|
189
|
+
else
|
190
|
+
label = 'Installed at'
|
191
|
+
matching_tuples.each do |(_,version,_,s),|
|
192
|
+
loaded_from = File.dirname File.dirname(s.loaded_from)
|
193
|
+
entry << "\n" << " #{label} (#{version}): #{loaded_from}"
|
194
|
+
label = ' ' * label.length
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
entry << "\n\n" << format_text(spec.summary, 68, 4)
|
200
|
+
end
|
142
201
|
output << entry
|
143
202
|
end
|
144
203
|
|