rubygems-update 1.0.1 → 1.1.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 +248 -0
- data/README +2 -0
- data/Rakefile +47 -23
- data/bin/gem +9 -4
- data/bin/update_rubygems +15 -1
- data/examples/application/bin/myapp +0 -0
- data/lib/rubygems.rb +506 -373
- data/lib/rubygems/builder.rb +14 -7
- data/lib/rubygems/command.rb +9 -9
- data/lib/rubygems/command_manager.rb +1 -0
- data/lib/rubygems/commands/cleanup_command.rb +67 -69
- data/lib/rubygems/commands/environment_command.rb +16 -10
- data/lib/rubygems/commands/fetch_command.rb +7 -9
- data/lib/rubygems/commands/install_command.rb +9 -3
- data/lib/rubygems/commands/list_command.rb +2 -4
- data/lib/rubygems/commands/mirror_command.rb +1 -1
- data/lib/rubygems/commands/query_command.rb +52 -5
- data/lib/rubygems/commands/sources_command.rb +19 -10
- data/lib/rubygems/commands/specification_command.rb +10 -6
- data/lib/rubygems/commands/uninstall_command.rb +23 -6
- data/lib/rubygems/commands/unpack_command.rb +15 -3
- data/lib/rubygems/commands/update_command.rb +27 -25
- data/lib/rubygems/custom_require.rb +1 -1
- data/lib/rubygems/defaults.rb +8 -1
- data/lib/rubygems/dependency_installer.rb +72 -104
- data/lib/rubygems/digest/digest_adapter.rb +0 -0
- data/lib/rubygems/digest/md5.rb +0 -0
- data/lib/rubygems/digest/sha1.rb +0 -0
- data/lib/rubygems/digest/sha2.rb +0 -0
- data/lib/rubygems/exceptions.rb +22 -1
- data/lib/rubygems/format.rb +16 -10
- data/lib/rubygems/indexer.rb +46 -33
- data/lib/rubygems/indexer/abstract_index_builder.rb +10 -2
- data/lib/rubygems/indexer/latest_index_builder.rb +35 -0
- data/lib/rubygems/indexer/master_index_builder.rb +9 -8
- data/lib/rubygems/indexer/quick_index_builder.rb +5 -3
- data/lib/rubygems/install_update_options.rb +7 -1
- data/lib/rubygems/installer.rb +8 -5
- data/lib/rubygems/package.rb +17 -774
- data/lib/rubygems/package/f_sync_dir.rb +24 -0
- data/lib/rubygems/package/tar_header.rb +245 -0
- data/lib/rubygems/package/tar_input.rb +219 -0
- data/lib/rubygems/package/tar_output.rb +143 -0
- data/lib/rubygems/package/tar_reader.rb +86 -0
- data/lib/rubygems/package/tar_reader/entry.rb +99 -0
- data/lib/rubygems/package/tar_writer.rb +180 -0
- data/lib/rubygems/remote_fetcher.rb +131 -16
- data/lib/rubygems/requirement.rb +2 -0
- data/lib/rubygems/rubygems_version.rb +1 -1
- data/lib/rubygems/security.rb +1 -0
- data/lib/rubygems/server.rb +85 -104
- data/lib/rubygems/source_index.rb +412 -329
- data/lib/rubygems/source_info_cache.rb +232 -99
- data/lib/rubygems/source_info_cache_entry.rb +14 -4
- data/lib/rubygems/specification.rb +9 -10
- data/lib/rubygems/timer.rb +0 -0
- data/lib/rubygems/uninstaller.rb +56 -32
- data/lib/rubygems/user_interaction.rb +4 -10
- data/lib/rubygems/validator.rb +0 -0
- data/scripts/gemdoc.rb +0 -0
- data/scripts/specdoc.rb +0 -0
- data/setup.rb +56 -19
- data/test/gem_installer_test_case.rb +86 -0
- data/test/gem_installer_test_case.rbc +0 -0
- data/test/gem_package_tar_test_case.rb +146 -0
- data/test/gem_package_tar_test_case.rbc +0 -0
- data/test/gemutilities.rb +123 -38
- data/test/gemutilities.rbc +0 -0
- data/test/mockgemui.rb +5 -13
- data/test/mockgemui.rbc +0 -0
- data/test/private_key.pem +27 -0
- data/test/public_cert.pem +20 -0
- data/test/simple_gem.rbc +0 -0
- data/test/test_config.rbc +0 -0
- data/test/test_gem.rb +46 -4
- 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.rb +4 -2
- 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.rb +5 -1
- 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.rb +17 -1
- data/test/test_gem_commands_environment_command.rbc +0 -0
- data/test/test_gem_commands_fetch_command.rb +6 -5
- 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.rb +36 -28
- 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.rb +143 -19
- data/test/test_gem_commands_query_command.rbc +0 -0
- data/test/test_gem_commands_server_command.rb +1 -1
- data/test/test_gem_commands_server_command.rbc +0 -0
- data/test/test_gem_commands_sources_command.rb +67 -9
- data/test/test_gem_commands_sources_command.rbc +0 -0
- data/test/test_gem_commands_specification_command.rb +3 -2
- data/test/test_gem_commands_specification_command.rbc +0 -0
- data/test/test_gem_commands_unpack_command.rb +46 -4
- data/test/test_gem_commands_unpack_command.rbc +0 -0
- data/test/test_gem_commands_update_command.rb +174 -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.rb +172 -187
- data/test/test_gem_dependency_installer.rbc +0 -0
- data/test/test_gem_dependency_list.rbc +0 -0
- data/test/test_gem_digest.rb +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.rb +9 -6
- 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.rb +1 -1
- 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.rb +7 -2
- data/test/test_gem_indexer.rbc +0 -0
- data/test/test_gem_install_update_options.rbc +0 -0
- data/test/test_gem_installer.rb +5 -84
- 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.rb +137 -0
- data/test/test_gem_package_tar_header.rbc +0 -0
- data/test/test_gem_package_tar_input.rb +119 -0
- data/test/test_gem_package_tar_input.rbc +0 -0
- data/test/test_gem_package_tar_output.rb +104 -0
- data/test/test_gem_package_tar_output.rbc +0 -0
- data/test/test_gem_package_tar_reader.rb +53 -0
- data/test/test_gem_package_tar_reader.rbc +0 -0
- data/test/test_gem_package_tar_reader_entry.rb +116 -0
- data/test/test_gem_package_tar_reader_entry.rbc +0 -0
- data/test/test_gem_package_tar_writer.rb +151 -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.rb +189 -17
- data/test/test_gem_remote_fetcher.rbc +0 -0
- data/test/test_gem_requirement.rbc +0 -0
- data/test/test_gem_server.rb +13 -12
- data/test/test_gem_server.rbc +0 -0
- data/test/test_gem_source_index.rb +305 -56
- data/test/test_gem_source_index.rbc +0 -0
- data/test/test_gem_source_info_cache.rb +179 -53
- data/test/test_gem_source_info_cache.rbc +0 -0
- data/test/test_gem_source_info_cache_entry.rb +41 -10
- data/test/test_gem_source_info_cache_entry.rbc +0 -0
- data/test/test_gem_specification.rb +7 -7
- data/test/test_gem_specification.rbc +0 -0
- data/test/test_gem_stream_ui.rbc +0 -0
- data/test/test_gem_uninstaller.rb +43 -0
- data/test/test_gem_uninstaller.rbc +0 -0
- data/test/test_gem_validator.rbc +0 -0
- data/test/test_gem_version.rb +1 -1
- data/test/test_gem_version.rbc +0 -0
- data/test/test_gem_version_option.rbc +0 -0
- data/test/test_kernel.rb +1 -0
- data/test/test_kernel.rbc +0 -0
- metadata +85 -8
- metadata.gz.sig +0 -0
- data/lib/rubygems/gem_open_uri.rb +0 -7
- data/lib/rubygems/open-uri.rb +0 -773
- data/test/test_open_uri.rb +0 -13
- data/test/test_package.rb +0 -608
data/lib/rubygems/builder.rb
CHANGED
@@ -65,13 +65,20 @@ EOM
|
|
65
65
|
end
|
66
66
|
|
67
67
|
def write_package
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
68
|
+
open @spec.file_name, 'wb' do |gem_io|
|
69
|
+
Gem::Package.open gem_io, 'w', @signer do |pkg|
|
70
|
+
pkg.metadata = @spec.to_yaml
|
71
|
+
|
72
|
+
@spec.files.each do |file|
|
73
|
+
next if File.directory? file
|
74
|
+
|
75
|
+
stat = File.stat file
|
76
|
+
mode = stat.mode & 0777
|
77
|
+
size = stat.size
|
78
|
+
|
79
|
+
pkg.add_file_simple file, mode, size do |tar_io|
|
80
|
+
tar_io.write open(file, "rb") { |f| f.read }
|
81
|
+
end
|
75
82
|
end
|
76
83
|
end
|
77
84
|
end
|
data/lib/rubygems/command.rb
CHANGED
@@ -136,7 +136,7 @@ module Gem
|
|
136
136
|
execute
|
137
137
|
end
|
138
138
|
end
|
139
|
-
|
139
|
+
|
140
140
|
# Call the given block when invoked.
|
141
141
|
#
|
142
142
|
# Normal command invocations just executes the +execute+ method of
|
@@ -146,7 +146,7 @@ module Gem
|
|
146
146
|
def when_invoked(&block)
|
147
147
|
@when_invoked = block
|
148
148
|
end
|
149
|
-
|
149
|
+
|
150
150
|
# Add a command-line option and handler to the command.
|
151
151
|
#
|
152
152
|
# See OptionParser#make_switch for an explanation of +opts+.
|
@@ -165,7 +165,7 @@ module Gem
|
|
165
165
|
option_list.reject! { |args, _| args.any? { |x| x =~ /^#{name}/ } }
|
166
166
|
end
|
167
167
|
end
|
168
|
-
|
168
|
+
|
169
169
|
# Merge a set of command options with the set of default options
|
170
170
|
# (without modifying the default option hash).
|
171
171
|
def merge_options(new_options)
|
@@ -191,7 +191,7 @@ module Gem
|
|
191
191
|
parser.parse!(args)
|
192
192
|
@options[:args] = args
|
193
193
|
end
|
194
|
-
|
194
|
+
|
195
195
|
def add_extra_args(args)
|
196
196
|
result = []
|
197
197
|
s_extra = Command.specific_extra_args(@command)
|
@@ -291,7 +291,7 @@ module Gem
|
|
291
291
|
def common_options
|
292
292
|
@common_options ||= []
|
293
293
|
end
|
294
|
-
|
294
|
+
|
295
295
|
def add_common_option(*args, &handler)
|
296
296
|
Gem::Command.common_options << [args, handler]
|
297
297
|
end
|
@@ -315,7 +315,7 @@ module Gem
|
|
315
315
|
def specific_extra_args(cmd)
|
316
316
|
specific_extra_args_hash[cmd]
|
317
317
|
end
|
318
|
-
|
318
|
+
|
319
319
|
# Add a list of extra arguments for the given command. +args+
|
320
320
|
# may be an array or a string to be split on white space.
|
321
321
|
def add_specific_extra_args(cmd,args)
|
@@ -334,7 +334,7 @@ module Gem
|
|
334
334
|
# ----------------------------------------------------------------
|
335
335
|
# Add the options common to all commands.
|
336
336
|
|
337
|
-
add_common_option('-h', '--help',
|
337
|
+
add_common_option('-h', '--help',
|
338
338
|
'Get help on this command') do
|
339
339
|
|value, options|
|
340
340
|
options[:help] = true
|
@@ -358,11 +358,11 @@ module Gem
|
|
358
358
|
# commands. Both options are actually handled before the other
|
359
359
|
# options get parsed.
|
360
360
|
|
361
|
-
add_common_option('--config-file FILE',
|
361
|
+
add_common_option('--config-file FILE',
|
362
362
|
"Use this config file instead of default") do
|
363
363
|
end
|
364
364
|
|
365
|
-
add_common_option('--backtrace',
|
365
|
+
add_common_option('--backtrace',
|
366
366
|
'Show stack backtrace on errors') do
|
367
367
|
end
|
368
368
|
|
@@ -2,92 +2,90 @@ require 'rubygems/command'
|
|
2
2
|
require 'rubygems/source_index'
|
3
3
|
require 'rubygems/dependency_list'
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
super(
|
10
|
-
'cleanup',
|
5
|
+
class Gem::Commands::CleanupCommand < Gem::Command
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
super 'cleanup',
|
11
9
|
'Clean up old versions of installed gems in the local repository',
|
12
|
-
|
13
|
-
:force => false,
|
14
|
-
:test => false,
|
15
|
-
:install_dir => Gem.dir
|
16
|
-
})
|
17
|
-
add_option('-d', '--dryrun', "") do |value, options|
|
18
|
-
options[:dryrun] = true
|
19
|
-
end
|
20
|
-
end
|
10
|
+
:force => false, :test => false, :install_dir => Gem.dir
|
21
11
|
|
22
|
-
|
23
|
-
|
24
|
-
|
12
|
+
add_option('-d', '--dryrun', "") do |value, options|
|
13
|
+
options[:dryrun] = true
|
14
|
+
end
|
15
|
+
end
|
25
16
|
|
26
|
-
|
27
|
-
|
28
|
-
|
17
|
+
def arguments # :nodoc:
|
18
|
+
"GEMNAME name of gem to cleanup"
|
19
|
+
end
|
20
|
+
|
21
|
+
def defaults_str # :nodoc:
|
22
|
+
"--no-dryrun"
|
23
|
+
end
|
24
|
+
|
25
|
+
def usage # :nodoc:
|
26
|
+
"#{program_name} [GEMNAME ...]"
|
27
|
+
end
|
28
|
+
|
29
|
+
def execute
|
30
|
+
say "Cleaning up installed gems..."
|
31
|
+
primary_gems = {}
|
29
32
|
|
30
|
-
|
31
|
-
|
33
|
+
Gem.source_index.each do |name, spec|
|
34
|
+
if primary_gems[spec.name].nil? or
|
35
|
+
primary_gems[spec.name].version < spec.version then
|
36
|
+
primary_gems[spec.name] = spec
|
32
37
|
end
|
38
|
+
end
|
33
39
|
|
34
|
-
|
35
|
-
say "Cleaning up installed gems..."
|
36
|
-
srcindex = Gem::SourceIndex.from_installed_gems
|
37
|
-
primary_gems = {}
|
40
|
+
gems_to_cleanup = []
|
38
41
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
42
|
+
unless options[:args].empty? then
|
43
|
+
options[:args].each do |gem_name|
|
44
|
+
specs = Gem.cache.search(/^#{gem_name}$/i)
|
45
|
+
specs.each do |spec|
|
46
|
+
gems_to_cleanup << spec
|
43
47
|
end
|
48
|
+
end
|
49
|
+
else
|
50
|
+
Gem.source_index.each do |name, spec|
|
51
|
+
gems_to_cleanup << spec
|
52
|
+
end
|
53
|
+
end
|
44
54
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
options[:args].each do |gem_name|
|
49
|
-
specs = Gem.cache.search(/^#{gem_name}$/i)
|
50
|
-
specs.each do |spec|
|
51
|
-
gems_to_cleanup << spec
|
52
|
-
end
|
53
|
-
end
|
54
|
-
else
|
55
|
-
srcindex.each do |name, spec|
|
56
|
-
gems_to_cleanup << spec
|
57
|
-
end
|
58
|
-
end
|
55
|
+
gems_to_cleanup = gems_to_cleanup.select { |spec|
|
56
|
+
primary_gems[spec.name].version != spec.version
|
57
|
+
}
|
59
58
|
|
60
|
-
|
61
|
-
|
62
|
-
|
59
|
+
uninstall_command = Gem::CommandManager.instance['uninstall']
|
60
|
+
deplist = Gem::DependencyList.new
|
61
|
+
gems_to_cleanup.uniq.each do |spec| deplist.add spec end
|
63
62
|
|
64
|
-
|
65
|
-
deplist = DependencyList.new
|
66
|
-
gems_to_cleanup.uniq.each do |spec| deplist.add(spec) end
|
63
|
+
deps = deplist.strongly_connected_components.flatten.reverse
|
67
64
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
65
|
+
deps.each do |spec|
|
66
|
+
if options[:dryrun] then
|
67
|
+
say "Dry Run Mode: Would uninstall #{spec.full_name}"
|
68
|
+
else
|
69
|
+
say "Attempting to uninstall #{spec.full_name}"
|
73
70
|
|
74
|
-
|
75
|
-
|
76
|
-
|
71
|
+
options[:args] = [spec.name]
|
72
|
+
options[:version] = "= #{spec.version}"
|
73
|
+
options[:executables] = false
|
77
74
|
|
78
|
-
|
75
|
+
uninstaller = Gem::Uninstaller.new spec.name, options
|
79
76
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
77
|
+
begin
|
78
|
+
uninstaller.uninstall
|
79
|
+
rescue Gem::DependencyRemovalException,
|
80
|
+
Gem::GemNotInHomeException => e
|
81
|
+
say "Unable to uninstall #{spec.full_name}:"
|
82
|
+
say "\t#{e.class}: #{e.message}"
|
86
83
|
end
|
87
|
-
|
88
|
-
say "Clean Up Complete"
|
89
84
|
end
|
90
85
|
end
|
91
|
-
|
86
|
+
|
87
|
+
say "Clean Up Complete"
|
92
88
|
end
|
89
|
+
|
93
90
|
end
|
91
|
+
|
@@ -25,19 +25,18 @@ class Gem::Commands::EnvironmentCommand < Gem::Command
|
|
25
25
|
def execute
|
26
26
|
out = ''
|
27
27
|
arg = options[:args][0]
|
28
|
-
|
28
|
+
case arg
|
29
|
+
when /^packageversion/ then
|
29
30
|
out << Gem::RubyGemsPackageVersion
|
30
|
-
|
31
|
+
when /^version/ then
|
31
32
|
out << Gem::RubyGemsVersion
|
32
|
-
|
33
|
+
when /^gemdir/, /^gemhome/, /^home/, /^GEM_HOME/ then
|
33
34
|
out << Gem.dir
|
34
|
-
|
35
|
-
out << Gem.path.join(
|
36
|
-
|
35
|
+
when /^gempath/, /^path/, /^GEM_PATH/ then
|
36
|
+
out << Gem.path.join(File::PATH_SEPARATOR)
|
37
|
+
when /^remotesources/ then
|
37
38
|
out << Gem.sources.join("\n")
|
38
|
-
|
39
|
-
fail Gem::CommandLineError, "Unknown enviroment option [#{arg}]"
|
40
|
-
else
|
39
|
+
when nil then
|
41
40
|
out = "RubyGems Environment:\n"
|
42
41
|
|
43
42
|
out << " - RUBYGEMS VERSION: #{Gem::RubyGemsVersion} (#{Gem::RubyGemsPackageVersion})\n"
|
@@ -58,7 +57,11 @@ class Gem::Commands::EnvironmentCommand < Gem::Command
|
|
58
57
|
end
|
59
58
|
|
60
59
|
out << " - GEM PATHS:\n"
|
61
|
-
Gem.
|
60
|
+
out << " - #{Gem.dir}\n"
|
61
|
+
|
62
|
+
path = Gem.path.dup
|
63
|
+
path.delete Gem.dir
|
64
|
+
path.each do |p|
|
62
65
|
out << " - #{p}\n"
|
63
66
|
end
|
64
67
|
|
@@ -71,6 +74,9 @@ class Gem::Commands::EnvironmentCommand < Gem::Command
|
|
71
74
|
Gem.sources.each do |s|
|
72
75
|
out << " - #{s}\n"
|
73
76
|
end
|
77
|
+
|
78
|
+
else
|
79
|
+
fail Gem::CommandLineError, "Unknown enviroment option [#{arg}]"
|
74
80
|
end
|
75
81
|
say out
|
76
82
|
true
|
@@ -44,17 +44,15 @@ class Gem::Commands::FetchCommand < Gem::Command
|
|
44
44
|
|
45
45
|
spec, source_uri = specs_and_sources.last
|
46
46
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
gem = Gem::RemoteFetcher.fetcher.fetch_path gem_path
|
52
|
-
|
53
|
-
File.open gem_file, 'wb' do |fp|
|
54
|
-
fp.write gem
|
47
|
+
if spec.nil? then
|
48
|
+
alert_error "Could not find #{gem_name} in any repository"
|
49
|
+
next
|
55
50
|
end
|
56
51
|
|
57
|
-
|
52
|
+
path = Gem::RemoteFetcher.fetcher.download spec, source_uri
|
53
|
+
FileUtils.mv path, "#{spec.full_name}.gem"
|
54
|
+
|
55
|
+
say "Downloaded #{spec.full_name}"
|
58
56
|
end
|
59
57
|
end
|
60
58
|
|
@@ -62,13 +62,15 @@ class Gem::Commands::InstallCommand < Gem::Command
|
|
62
62
|
:install_dir => options[:install_dir],
|
63
63
|
:security_policy => options[:security_policy],
|
64
64
|
:wrappers => options[:wrappers],
|
65
|
+
:bin_dir => options[:bin_dir]
|
65
66
|
}
|
66
67
|
|
68
|
+
exit_code = 0
|
69
|
+
|
67
70
|
get_all_gem_names.each do |gem_name|
|
68
71
|
begin
|
69
|
-
inst = Gem::DependencyInstaller.new
|
70
|
-
|
71
|
-
inst.install
|
72
|
+
inst = Gem::DependencyInstaller.new install_options
|
73
|
+
inst.install gem_name, options[:version]
|
72
74
|
|
73
75
|
inst.installed_gems.each do |spec|
|
74
76
|
say "Successfully installed #{spec.full_name}"
|
@@ -77,8 +79,10 @@ class Gem::Commands::InstallCommand < Gem::Command
|
|
77
79
|
installed_gems.push(*inst.installed_gems)
|
78
80
|
rescue Gem::InstallError => e
|
79
81
|
alert_error "Error installing #{gem_name}:\n\t#{e.message}"
|
82
|
+
exit_code |= 1
|
80
83
|
rescue Gem::GemNotFoundException => e
|
81
84
|
alert_error e.message
|
85
|
+
exit_code |= 2
|
82
86
|
# rescue => e
|
83
87
|
# # TODO: Fix this handle to allow the error to propagate to
|
84
88
|
# # the top level handler. Examine the other errors as
|
@@ -121,6 +125,8 @@ class Gem::Commands::InstallCommand < Gem::Command
|
|
121
125
|
end
|
122
126
|
end
|
123
127
|
end
|
128
|
+
|
129
|
+
raise Gem::SystemExitException, exit_code
|
124
130
|
end
|
125
131
|
|
126
132
|
end
|
@@ -1,15 +1,25 @@
|
|
1
1
|
require 'rubygems/command'
|
2
2
|
require 'rubygems/local_remote_options'
|
3
3
|
require 'rubygems/source_info_cache'
|
4
|
+
require 'rubygems/version_option'
|
4
5
|
|
5
6
|
class Gem::Commands::QueryCommand < Gem::Command
|
6
7
|
|
7
8
|
include Gem::LocalRemoteOptions
|
9
|
+
include Gem::VersionOption
|
8
10
|
|
9
11
|
def initialize(name = 'query',
|
10
12
|
summary = 'Query gem information in local or remote repositories')
|
11
13
|
super name, summary,
|
12
|
-
:name =>
|
14
|
+
:name => //, :domain => :local, :details => false, :versions => true,
|
15
|
+
:installed => false, :version => Gem::Requirement.default
|
16
|
+
|
17
|
+
add_option('-i', '--[no-]installed',
|
18
|
+
'Check for installed gem') do |value, options|
|
19
|
+
options[:installed] = value
|
20
|
+
end
|
21
|
+
|
22
|
+
add_version_option
|
13
23
|
|
14
24
|
add_option('-n', '--name-matches REGEXP',
|
15
25
|
'Name of gem(s) to query on matches the',
|
@@ -28,33 +38,70 @@ class Gem::Commands::QueryCommand < Gem::Command
|
|
28
38
|
options[:details] = false unless value
|
29
39
|
end
|
30
40
|
|
41
|
+
add_option('-a', '--all',
|
42
|
+
'Display all gem versions') do |value, options|
|
43
|
+
options[:all] = value
|
44
|
+
end
|
45
|
+
|
31
46
|
add_local_remote_options
|
32
47
|
end
|
33
48
|
|
34
49
|
def defaults_str # :nodoc:
|
35
|
-
"--local --name-matches
|
50
|
+
"--local --name-matches // --no-details --versions --no-installed"
|
36
51
|
end
|
37
52
|
|
38
53
|
def execute
|
54
|
+
exit_code = 0
|
55
|
+
|
39
56
|
name = options[:name]
|
40
57
|
|
58
|
+
if options[:installed] then
|
59
|
+
if name.source.empty? then
|
60
|
+
alert_error "You must specify a gem name"
|
61
|
+
exit_code |= 4
|
62
|
+
elsif installed? name.source, options[:version] then
|
63
|
+
say "true"
|
64
|
+
else
|
65
|
+
say "false"
|
66
|
+
exit_code |= 1
|
67
|
+
end
|
68
|
+
|
69
|
+
raise Gem::SystemExitException, exit_code
|
70
|
+
end
|
71
|
+
|
41
72
|
if local? then
|
42
73
|
say
|
43
74
|
say "*** LOCAL GEMS ***"
|
44
75
|
say
|
45
|
-
|
76
|
+
|
77
|
+
output_query_results Gem.source_index.search(name)
|
46
78
|
end
|
47
79
|
|
48
80
|
if remote? then
|
49
81
|
say
|
50
82
|
say "*** REMOTE GEMS ***"
|
51
83
|
say
|
52
|
-
|
84
|
+
|
85
|
+
begin
|
86
|
+
Gem::SourceInfoCache.cache options[:all]
|
87
|
+
rescue Gem::RemoteFetcher::FetchError
|
88
|
+
# no network
|
89
|
+
end
|
90
|
+
|
91
|
+
output_query_results Gem::SourceInfoCache.search(name, false, true)
|
53
92
|
end
|
54
93
|
end
|
55
94
|
|
56
95
|
private
|
57
96
|
|
97
|
+
##
|
98
|
+
# Check if gem +name+ version +version+ is installed.
|
99
|
+
|
100
|
+
def installed?(name, version = Gem::Requirement.default)
|
101
|
+
dep = Gem::Dependency.new name, version
|
102
|
+
!Gem.source_index.search(dep).empty?
|
103
|
+
end
|
104
|
+
|
58
105
|
def output_query_results(gemspecs)
|
59
106
|
output = []
|
60
107
|
gem_list_with_version = {}
|
@@ -98,7 +145,7 @@ class Gem::Commands::QueryCommand < Gem::Command
|
|
98
145
|
|
99
146
|
##
|
100
147
|
# Used for wrapping and indenting text
|
101
|
-
|
148
|
+
|
102
149
|
def format_text(text, wrap, indent=0)
|
103
150
|
result = []
|
104
151
|
work = text.dup
|