rubygems-update 0.9.4 → 0.9.5
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/ChangeLog +587 -0
- data/README +0 -1
- data/Rakefile +39 -12
- data/TODO +0 -5
- data/bin/gem +7 -7
- data/bin/update_rubygems +1 -1
- data/examples/application/an-app.gemspec +1 -1
- data/gemspecs/cgikit-1.1.0.gemspec +1 -2
- data/gemspecs/jabber4r.gemspec +1 -1
- data/gemspecs/linguistics.gemspec +1 -1
- data/gemspecs/ook.gemspec +1 -1
- data/gemspecs/progressbar.gemspec +1 -1
- data/gemspecs/redcloth.gemspec +1 -1
- data/gemspecs/rublog.gemspec +1 -1
- data/gemspecs/ruby-doom.gemspec +1 -1
- data/gemspecs/rubyjdwp.gemspec +1 -1
- data/gemspecs/statistics.gemspec +1 -1
- data/lib/rubygems.rb +167 -105
- data/lib/rubygems/builder.rb +12 -10
- data/lib/rubygems/command.rb +177 -60
- data/lib/rubygems/command_manager.rb +30 -38
- data/lib/rubygems/commands/build_command.rb +42 -46
- data/lib/rubygems/commands/cert_command.rb +72 -69
- data/lib/rubygems/commands/check_command.rb +63 -63
- data/lib/rubygems/commands/cleanup_command.rb +25 -7
- data/lib/rubygems/commands/contents_command.rb +70 -62
- data/lib/rubygems/commands/dependency_command.rb +131 -86
- data/lib/rubygems/commands/environment_command.rb +67 -46
- data/lib/rubygems/commands/fetch_command.rb +62 -0
- data/lib/rubygems/commands/generate_index_command.rb +57 -0
- data/lib/rubygems/commands/help_command.rb +163 -73
- data/lib/rubygems/commands/install_command.rb +114 -128
- data/lib/rubygems/commands/list_command.rb +10 -8
- data/lib/rubygems/commands/lock_command.rb +101 -0
- data/lib/rubygems/commands/mirror_command.rb +105 -0
- data/lib/rubygems/commands/outdated_command.rb +24 -15
- data/lib/rubygems/commands/pristine_command.rb +118 -88
- data/lib/rubygems/commands/query_command.rb +109 -77
- data/lib/rubygems/commands/rdoc_command.rb +13 -10
- data/lib/rubygems/commands/search_command.rb +10 -8
- data/lib/rubygems/commands/server_command.rb +48 -0
- data/lib/rubygems/commands/sources_command.rb +104 -83
- data/lib/rubygems/commands/specification_command.rb +65 -51
- data/lib/rubygems/commands/uninstall_command.rb +17 -12
- data/lib/rubygems/commands/unpack_command.rb +68 -68
- data/lib/rubygems/commands/update_command.rb +72 -25
- data/lib/rubygems/commands/which_command.rb +86 -0
- data/lib/rubygems/config_file.rb +202 -78
- data/lib/rubygems/custom_require.rb +7 -88
- data/lib/rubygems/dependency.rb +65 -0
- data/lib/rubygems/dependency_installer.rb +232 -0
- data/lib/rubygems/dependency_list.rb +133 -105
- data/lib/rubygems/digest/md5.rb +4 -1
- data/lib/rubygems/digest/sha2.rb +1 -1
- data/lib/rubygems/doc_manager.rb +41 -19
- data/lib/rubygems/exceptions.rb +63 -0
- data/lib/rubygems/ext.rb +18 -0
- data/lib/rubygems/ext/builder.rb +56 -0
- data/lib/rubygems/ext/configure_builder.rb +24 -0
- data/lib/rubygems/ext/ext_conf_builder.rb +23 -0
- data/lib/rubygems/ext/rake_builder.rb +27 -0
- data/lib/rubygems/format.rb +16 -6
- data/lib/rubygems/gem_openssl.rb +43 -6
- data/lib/rubygems/gem_path_searcher.rb +84 -0
- data/lib/rubygems/gem_runner.rb +20 -5
- data/lib/rubygems/indexer.rb +163 -0
- data/lib/rubygems/indexer/abstract_index_builder.rb +80 -0
- data/lib/rubygems/indexer/marshal_index_builder.rb +17 -0
- data/lib/rubygems/indexer/master_index_builder.rb +53 -0
- data/lib/rubygems/indexer/quick_index_builder.rb +48 -0
- data/lib/rubygems/install_update_options.rb +87 -0
- data/lib/rubygems/installer.rb +316 -562
- data/lib/rubygems/local_remote_options.rb +106 -0
- data/lib/rubygems/old_format.rb +5 -13
- data/lib/rubygems/open-uri.rb +2 -0
- data/lib/rubygems/package.rb +28 -32
- data/lib/rubygems/platform.rb +187 -0
- data/lib/rubygems/remote_fetcher.rb +46 -29
- data/lib/rubygems/remote_installer.rb +11 -18
- data/lib/rubygems/requirement.rb +157 -0
- data/lib/rubygems/rubygems_version.rb +1 -1
- data/lib/rubygems/security.rb +715 -457
- data/lib/rubygems/server.rb +77 -59
- data/lib/rubygems/source_index.rb +154 -83
- data/lib/rubygems/source_info_cache.rb +73 -30
- data/lib/rubygems/source_info_cache_entry.rb +12 -3
- data/lib/rubygems/specification.rb +378 -145
- data/lib/rubygems/uninstaller.rb +183 -0
- data/lib/rubygems/user_interaction.rb +38 -9
- data/lib/rubygems/validator.rb +53 -24
- data/lib/rubygems/version.rb +126 -289
- data/lib/rubygems/version_option.rb +49 -0
- data/pkgs/sources/lib/sources.rb +1 -4
- data/pkgs/sources/sources.gemspec +3 -3
- data/scripts/gemdoc.rb +0 -1
- data/setup.rb +166 -1505
- data/test/bogussources.rb +0 -1
- data/test/data/gem-private_key.pem +27 -0
- data/test/data/gem-public_cert.pem +20 -0
- data/test/functional.rb +3 -105
- data/test/gemutilities.rb +145 -24
- data/test/insure_session.rb +0 -1
- data/test/{test_datadir.rb → test_config.rb} +7 -13
- data/test/test_gem.rb +360 -9
- data/test/test_gem_builder.rb +34 -0
- data/test/{test_command.rb → test_gem_command.rb} +119 -62
- data/test/{test_parse_commands.rb → test_gem_command_manager.rb} +64 -40
- data/test/test_gem_commands_build_command.rb +75 -0
- data/test/test_gem_commands_cert_command.rb +122 -0
- data/test/test_gem_commands_check_command.rb +25 -0
- data/test/test_gem_commands_contents_command.rb +92 -0
- data/test/test_gem_commands_dependency_command.rb +108 -0
- data/test/test_gem_commands_environment_command.rb +117 -0
- data/test/test_gem_commands_fetch_command.rb +34 -0
- data/test/test_gem_commands_generate_index_command.rb +32 -0
- data/test/test_gem_commands_install_command.rb +160 -0
- data/test/test_gem_commands_mirror_command.rb +56 -0
- data/test/test_gem_commands_pristine_command.rb +100 -0
- data/test/test_gem_commands_query_command.rb +82 -0
- data/test/test_gem_commands_sources_command.rb +147 -0
- data/test/test_gem_commands_specification_command.rb +93 -0
- data/test/test_gem_commands_unpack_command.rb +55 -0
- data/test/test_gem_config_file.rb +210 -0
- data/test/test_gem_dependency.rb +89 -0
- data/test/test_gem_dependency_installer.rb +542 -0
- data/test/test_gem_dependency_list.rb +212 -0
- data/test/test_gem_doc_manager.rb +32 -0
- data/test/test_gem_ext_configure_builder.rb +13 -17
- data/test/test_gem_ext_ext_conf_builder.rb +9 -9
- data/test/test_gem_ext_rake_builder.rb +23 -11
- data/test/test_gem_format.rb +69 -0
- data/test/test_gem_gem_path_searcher.rb +57 -0
- data/test/test_gem_gem_runner.rb +35 -0
- data/test/test_gem_indexer.rb +119 -0
- data/test/test_gem_install_update_options.rb +40 -0
- data/test/test_gem_installer.rb +796 -0
- data/test/test_gem_local_remote_options.rb +84 -0
- data/test/test_gem_outdated_command.rb +11 -9
- data/test/test_gem_platform.rb +240 -0
- data/test/{test_remote_fetcher.rb → test_gem_remote_fetcher.rb} +124 -55
- data/test/{test_remote_installer.rb → test_gem_remote_installer.rb} +3 -4
- data/test/test_gem_requirement.rb +223 -0
- data/test/test_gem_server.rb +71 -0
- data/test/test_gem_source_index.rb +429 -0
- data/test/test_gem_source_info_cache.rb +79 -17
- data/test/test_gem_source_info_cache_entry.rb +11 -9
- data/test/test_gem_specification.rb +738 -0
- data/test/test_gem_stream_ui.rb +117 -0
- data/test/test_gem_validator.rb +70 -0
- data/test/test_gem_version.rb +191 -0
- data/test/test_gem_version_option.rb +77 -0
- data/test/{test_require_gem.rb → test_kernel.rb} +19 -12
- data/test/test_open_uri.rb +1 -2
- data/test/test_package.rb +45 -34
- metadata +116 -141
- data/Releases +0 -127
- data/bin/gem_mirror +0 -73
- data/bin/gem_server +0 -6
- data/bin/gemlock +0 -127
- data/bin/gemri +0 -24
- data/bin/gemwhich +0 -89
- data/bin/index_gem_repository.rb +0 -302
- data/lib/gemconfigure.rb +0 -24
- data/lib/rubygems/gem_commands.rb +0 -273
- data/pkgs/sources/sources-0.0.1.gem +0 -0
- data/post-install.rb +0 -121
- data/test/brokenbuildgem.rb +0 -35
- data/test/data/PostMessage-0.0.1.gem +0 -0
- data/test/data/a-0.0.1.gem +0 -0
- data/test/data/a-0.0.2.gem +0 -0
- data/test/data/b-0.0.2.gem +0 -0
- data/test/data/broken-1.0.0.gem +0 -0
- data/test/data/broken_build/broken-build.gemspec +0 -20
- data/test/data/broken_build/ext/extconf.rb +0 -3
- data/test/data/broken_build/ext/foo.c +0 -1
- data/test/data/c-1.2.gem +0 -0
- data/test/data/gemhome/cache/a-0.0.1.gem +0 -0
- data/test/data/gemhome/cache/a-0.0.2.gem +0 -0
- data/test/data/gemhome/cache/b-0.0.2.gem +0 -0
- data/test/data/gemhome/cache/c-1.2.gem +0 -0
- data/test/data/gemhome/gems/a-0.0.1/lib/code.rb +0 -1
- data/test/data/gemhome/gems/a-0.0.2/lib/code.rb +0 -1
- data/test/data/gemhome/gems/b-0.0.2/lib/code.rb +0 -1
- data/test/data/gemhome/gems/c-1.2/lib/code.rb +0 -1
- data/test/data/gemhome/specifications/a-0.0.1.gemspec +0 -8
- data/test/data/gemhome/specifications/a-0.0.2.gemspec +0 -8
- data/test/data/gemhome/specifications/b-0.0.2.gemspec +0 -8
- data/test/data/gemhome/specifications/c-1.2.gemspec +0 -8
- data/test/data/legacy/keyedlist-0.4.0.ruby +0 -11
- data/test/data/legacy/keyedlist-0.4.0.yaml +0 -16
- data/test/data/lib/code.rb +0 -1
- data/test/data/one/README.one +0 -1
- data/test/data/one/lib/one.rb +0 -9
- data/test/data/one/one-0.0.1.gem +0 -0
- data/test/data/one/one.gemspec +0 -17
- data/test/data/one/one.yaml +0 -40
- data/test/data/post_install.gemspec +0 -19
- data/test/functional_extension_gems.rb +0 -48
- data/test/functional_generate_yaml_index.rb +0 -104
- data/test/gemenvironment.rb +0 -59
- data/test/io_capture.rb +0 -33
- data/test/mock/gems/gems/sources-0.0.1/lib/sources.rb +0 -11
- data/test/mock/gems/specifications/sources-0.0.1.gemspec +0 -8
- data/test/onegem.rb +0 -35
- data/test/test_builder.rb +0 -34
- data/test/test_check_command.rb +0 -34
- data/test/test_configfile.rb +0 -42
- data/test/test_dependency_list.rb +0 -169
- data/test/test_file_list.rb +0 -101
- data/test/test_format.rb +0 -49
- data/test/test_gem_sources_command.rb +0 -135
- data/test/test_gemloadpaths.rb +0 -51
- data/test/test_gempaths.rb +0 -170
- data/test/test_installer.rb +0 -369
- data/test/test_loadmanager.rb +0 -48
- data/test/test_process_commands.rb +0 -52
- data/test/test_source_index.rb +0 -231
- data/test/test_specific_extras.rb +0 -46
- data/test/test_specification.rb +0 -565
- data/test/test_user_interaction.rb +0 -48
- data/test/test_validator.rb +0 -59
- data/test/test_version_comparison.rb +0 -321
- data/test/testgem.rc +0 -7
- data/test/user_capture.rb +0 -7
- data/test/yaml_data.rb +0 -63
@@ -1,57 +1,53 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
class BuildCommand < Command
|
4
|
-
include CommandAids
|
1
|
+
require 'rubygems/command'
|
2
|
+
require 'rubygems/builder'
|
5
3
|
|
6
|
-
|
7
|
-
super('build', 'Build a gem from a gemspec')
|
8
|
-
end
|
4
|
+
class Gem::Commands::BuildCommand < Gem::Command
|
9
5
|
|
10
|
-
|
11
|
-
|
12
|
-
|
6
|
+
def initialize
|
7
|
+
super('build', 'Build a gem from a gemspec')
|
8
|
+
end
|
13
9
|
|
14
|
-
|
15
|
-
|
16
|
-
|
10
|
+
def arguments # :nodoc:
|
11
|
+
"GEMSPEC_FILE gemspec file name to build a gem for"
|
12
|
+
end
|
17
13
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
end
|
14
|
+
def usage # :nodoc:
|
15
|
+
"#{program_name} GEMSPEC_FILE"
|
16
|
+
end
|
17
|
+
|
18
|
+
def execute
|
19
|
+
gemspec = get_one_gem_name
|
20
|
+
if File.exist?(gemspec)
|
21
|
+
specs = load_gemspecs(gemspec)
|
22
|
+
specs.each do |spec|
|
23
|
+
Gem::Builder.new(spec).build
|
29
24
|
end
|
25
|
+
else
|
26
|
+
alert_error "Gemspec file not found: #{gemspec}"
|
27
|
+
end
|
28
|
+
end
|
30
29
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
result << spec
|
39
|
-
end
|
40
|
-
rescue EndOfYAMLException => e
|
41
|
-
# OK
|
42
|
-
end
|
30
|
+
def load_gemspecs(filename)
|
31
|
+
if yaml?(filename)
|
32
|
+
result = []
|
33
|
+
open(filename) do |f|
|
34
|
+
begin
|
35
|
+
while not f.eof? and spec = Gem::Specification.from_yaml(f)
|
36
|
+
result << spec
|
43
37
|
end
|
44
|
-
|
45
|
-
|
38
|
+
rescue Gem::EndOfYAMLException => e
|
39
|
+
# OK
|
46
40
|
end
|
47
|
-
result
|
48
|
-
end
|
49
|
-
|
50
|
-
def yaml?(filename)
|
51
|
-
line = open(filename) { |f| line = f.gets }
|
52
|
-
result = line =~ %r{^--- *!ruby/object:Gem::Specification}
|
53
|
-
result
|
54
41
|
end
|
42
|
+
else
|
43
|
+
result = [Gem::Specification.load(filename)]
|
55
44
|
end
|
45
|
+
result
|
46
|
+
end
|
47
|
+
|
48
|
+
def yaml?(filename)
|
49
|
+
line = open(filename) { |f| line = f.gets }
|
50
|
+
result = line =~ %r{^--- *!ruby/object:Gem::Specification}
|
51
|
+
result
|
56
52
|
end
|
57
|
-
end
|
53
|
+
end
|
@@ -1,83 +1,86 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
class CertCommand < Command
|
5
|
-
include CommandAids
|
6
|
-
|
7
|
-
def initialize
|
8
|
-
super(
|
9
|
-
'cert',
|
10
|
-
'Adjust RubyGems certificate settings',
|
11
|
-
{
|
12
|
-
})
|
1
|
+
require 'rubygems/command'
|
2
|
+
require 'rubygems/security'
|
13
3
|
|
14
|
-
|
15
|
-
cert = OpenSSL::X509::Certificate.new(File.read(value))
|
16
|
-
Gem::Security.add_trusted_cert(cert)
|
17
|
-
puts "Added #{cert.subject.to_s}"
|
18
|
-
end
|
19
|
-
|
20
|
-
add_option('-l', '--list', 'List trusted certificates.') do |value, options|
|
21
|
-
glob_str = File::join(Gem::Security::OPT[:trust_dir], '*.pem')
|
22
|
-
Dir::glob(glob_str) do |path|
|
23
|
-
cert = OpenSSL::X509::Certificate.new(File.read(path))
|
24
|
-
# this could proably be formatted more gracefully
|
25
|
-
puts cert.subject.to_s
|
26
|
-
end
|
27
|
-
end
|
4
|
+
class Gem::Commands::CertCommand < Gem::Command
|
28
5
|
|
29
|
-
|
30
|
-
|
31
|
-
'STRING.') do |value, options|
|
32
|
-
trust_dir = Gem::Security::OPT[:trust_dir]
|
33
|
-
glob_str = File::join(trust_dir, '*.pem')
|
6
|
+
def initialize
|
7
|
+
super 'cert', 'Manage RubyGems certificates and signing settings'
|
34
8
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
end
|
42
|
-
end
|
9
|
+
add_option('-a', '--add CERT',
|
10
|
+
'Add a trusted certificate.') do |value, options|
|
11
|
+
cert = OpenSSL::X509::Certificate.new(File.read(value))
|
12
|
+
Gem::Security.add_trusted_cert(cert)
|
13
|
+
say "Added '#{cert.subject.to_s}'"
|
14
|
+
end
|
43
15
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
16
|
+
add_option('-l', '--list',
|
17
|
+
'List trusted certificates.') do |value, options|
|
18
|
+
glob_str = File::join(Gem::Security::OPT[:trust_dir], '*.pem')
|
19
|
+
Dir::glob(glob_str) do |path|
|
20
|
+
begin
|
21
|
+
cert = OpenSSL::X509::Certificate.new(File.read(path))
|
22
|
+
# this could proably be formatted more gracefully
|
23
|
+
say cert.subject.to_s
|
24
|
+
rescue OpenSSL::X509::CertificateError
|
25
|
+
next
|
52
26
|
end
|
27
|
+
end
|
28
|
+
end
|
53
29
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
30
|
+
add_option('-r', '--remove STRING',
|
31
|
+
'Remove trusted certificates containing',
|
32
|
+
'STRING.') do |value, options|
|
33
|
+
trust_dir = Gem::Security::OPT[:trust_dir]
|
34
|
+
glob_str = File::join(trust_dir, '*.pem')
|
59
35
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
36
|
+
Dir::glob(glob_str) do |path|
|
37
|
+
begin
|
38
|
+
cert = OpenSSL::X509::Certificate.new(File.read(path))
|
39
|
+
if cert.subject.to_s.downcase.index(value)
|
40
|
+
say "Removed '#{cert.subject.to_s}'"
|
41
|
+
File.unlink(path)
|
42
|
+
end
|
43
|
+
rescue OpenSSL::X509::CertificateError
|
44
|
+
next
|
64
45
|
end
|
46
|
+
end
|
47
|
+
end
|
65
48
|
|
49
|
+
add_option('-b', '--build EMAIL_ADDR',
|
50
|
+
'Build private key and self-signed',
|
51
|
+
'certificate for EMAIL_ADDR.') do |value, options|
|
52
|
+
vals = Gem::Security.build_self_signed_cert(value)
|
53
|
+
File.chmod 0600, vals[:key_path]
|
54
|
+
say "Public Cert: #{vals[:cert_path]}"
|
55
|
+
say "Private Key: #{vals[:key_path]}"
|
56
|
+
say "Don't forget to move the key file to somewhere private..."
|
57
|
+
end
|
66
58
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
my_key = Gem::Security::OPT[:issuer_key]
|
73
|
-
cert = Gem::Security.sign_cert(cert, my_key, my_cert)
|
74
|
-
File::open(value, 'wb') { |file| file.write(cert.to_pem) }
|
75
|
-
end
|
59
|
+
add_option('-C', '--certificate CERT',
|
60
|
+
'Certificate for --sign command.') do |value, options|
|
61
|
+
cert = OpenSSL::X509::Certificate.new(File.read(value))
|
62
|
+
Gem::Security::OPT[:issuer_cert] = cert
|
63
|
+
end
|
76
64
|
|
77
|
-
|
65
|
+
add_option('-K', '--private-key KEY',
|
66
|
+
'Private key for --sign command.') do |value, options|
|
67
|
+
key = OpenSSL::PKey::RSA.new(File.read(value))
|
68
|
+
Gem::Security::OPT[:issuer_key] = key
|
69
|
+
end
|
78
70
|
|
79
|
-
|
80
|
-
|
71
|
+
add_option('-s', '--sign NEWCERT',
|
72
|
+
'Sign a certificate with my key and',
|
73
|
+
'certificate.') do |value, options|
|
74
|
+
cert = OpenSSL::X509::Certificate.new(File.read(value))
|
75
|
+
my_cert = Gem::Security::OPT[:issuer_cert]
|
76
|
+
my_key = Gem::Security::OPT[:issuer_key]
|
77
|
+
cert = Gem::Security.sign_cert(cert, my_key, my_cert)
|
78
|
+
File.open(value, 'wb') { |file| file.write(cert.to_pem) }
|
81
79
|
end
|
82
80
|
end
|
83
|
-
|
81
|
+
|
82
|
+
def execute
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
|
@@ -1,74 +1,74 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
include CommandAids
|
1
|
+
require 'rubygems/command'
|
2
|
+
require 'rubygems/version_option'
|
3
|
+
require 'rubygems/validator'
|
5
4
|
|
6
|
-
|
7
|
-
super('check', 'Check installed gems',
|
8
|
-
{:verify => false, :alien => false})
|
5
|
+
class Gem::Commands::CheckCommand < Gem::Command
|
9
6
|
|
10
|
-
|
11
|
-
'Verify gem file against its internal',
|
12
|
-
'checksum') do |value, options|
|
13
|
-
options[:verify] = value
|
14
|
-
end
|
7
|
+
include Gem::VersionOption
|
15
8
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
end
|
9
|
+
def initialize
|
10
|
+
super 'check', 'Check installed gems',
|
11
|
+
:verify => false, :alien => false
|
20
12
|
|
21
|
-
|
22
|
-
|
23
|
-
|
13
|
+
add_option( '--verify FILE',
|
14
|
+
'Verify gem file against its internal',
|
15
|
+
'checksum') do |value, options|
|
16
|
+
options[:verify] = value
|
17
|
+
end
|
24
18
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
19
|
+
add_option('-a', '--alien', "Report 'unmanaged' or rogue files in the",
|
20
|
+
"gem repository") do |value, options|
|
21
|
+
options[:alien] = true
|
22
|
+
end
|
23
|
+
|
24
|
+
add_option('-t', '--test', "Run unit tests for gem") do |value, options|
|
25
|
+
options[:test] = true
|
26
|
+
end
|
27
|
+
|
28
|
+
add_version_option 'run tests for'
|
29
|
+
end
|
30
|
+
|
31
|
+
def execute
|
32
|
+
if options[:test]
|
33
|
+
version = options[:version] || Gem::Requirement.default
|
34
|
+
gem_spec = Gem::SourceIndex.from_installed_gems.search(get_one_gem_name, version).first
|
35
|
+
Gem::Validator.new.unit_test(gem_spec)
|
36
|
+
end
|
37
|
+
|
38
|
+
if options[:alien]
|
39
|
+
say "Performing the 'alien' operation"
|
40
|
+
Gem::Validator.new.alien.each do |key, val|
|
41
|
+
if(val.size > 0)
|
42
|
+
say "#{key} has #{val.size} problems"
|
43
|
+
val.each do |error_entry|
|
44
|
+
say "\t#{error_entry.path}:"
|
45
|
+
say "\t#{error_entry.problem}"
|
50
46
|
say
|
51
47
|
end
|
48
|
+
else
|
49
|
+
say "#{key} is error-free"
|
52
50
|
end
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
51
|
+
say
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
if options[:verify]
|
56
|
+
gem_name = options[:verify]
|
57
|
+
unless gem_name
|
58
|
+
alert_error "Must specify a .gem file with --verify NAME"
|
59
|
+
return
|
60
|
+
end
|
61
|
+
unless File.exist?(gem_name)
|
62
|
+
alert_error "Unknown file: #{gem_name}."
|
63
|
+
return
|
64
|
+
end
|
65
|
+
say "Verifying gem: '#{gem_name}'"
|
66
|
+
begin
|
67
|
+
Gem::Validator.new.verify_gem_file(gem_name)
|
68
|
+
rescue Exception => e
|
69
|
+
alert_error "#{gem_name} is invalid."
|
70
70
|
end
|
71
|
-
|
72
71
|
end
|
73
72
|
end
|
74
|
-
|
73
|
+
|
74
|
+
end
|
@@ -1,3 +1,7 @@
|
|
1
|
+
require 'rubygems/command'
|
2
|
+
require 'rubygems/source_index'
|
3
|
+
require 'rubygems/dependency_list'
|
4
|
+
|
1
5
|
module Gem
|
2
6
|
module Commands
|
3
7
|
class CleanupCommand < Command
|
@@ -14,26 +18,33 @@ module Gem
|
|
14
18
|
options[:dryrun] = true
|
15
19
|
end
|
16
20
|
end
|
17
|
-
|
18
|
-
def
|
21
|
+
|
22
|
+
def arguments # :nodoc:
|
23
|
+
"GEMNAME name of gem to cleanup"
|
24
|
+
end
|
25
|
+
|
26
|
+
def defaults_str # :nodoc:
|
19
27
|
"--no-dryrun"
|
20
28
|
end
|
21
29
|
|
22
|
-
def
|
23
|
-
"GEMNAME
|
30
|
+
def usage # :nodoc:
|
31
|
+
"#{program_name} [GEMNAME ...]"
|
24
32
|
end
|
25
33
|
|
26
34
|
def execute
|
27
35
|
say "Cleaning up installed gems..."
|
28
36
|
srcindex = Gem::SourceIndex.from_installed_gems
|
29
37
|
primary_gems = {}
|
38
|
+
|
30
39
|
srcindex.each do |name, spec|
|
31
40
|
if primary_gems[spec.name].nil? or primary_gems[spec.name].version < spec.version
|
32
41
|
primary_gems[spec.name] = spec
|
33
42
|
end
|
34
43
|
end
|
44
|
+
|
35
45
|
gems_to_cleanup = []
|
36
|
-
|
46
|
+
|
47
|
+
unless options[:args].empty? then
|
37
48
|
options[:args].each do |gem_name|
|
38
49
|
specs = Gem.cache.search(/^#{gem_name}$/i)
|
39
50
|
specs.each do |spec|
|
@@ -45,21 +56,27 @@ module Gem
|
|
45
56
|
gems_to_cleanup << spec
|
46
57
|
end
|
47
58
|
end
|
59
|
+
|
48
60
|
gems_to_cleanup = gems_to_cleanup.select { |spec|
|
49
61
|
primary_gems[spec.name].version != spec.version
|
50
62
|
}
|
51
|
-
|
63
|
+
|
64
|
+
uninstall_command = Gem::CommandManager.instance['uninstall']
|
52
65
|
deplist = DependencyList.new
|
53
66
|
gems_to_cleanup.uniq.each do |spec| deplist.add(spec) end
|
67
|
+
|
54
68
|
deplist.dependency_order.each do |spec|
|
55
|
-
if options[:dryrun]
|
69
|
+
if options[:dryrun] then
|
56
70
|
say "Dry Run Mode: Would uninstall #{spec.full_name}"
|
57
71
|
else
|
58
72
|
say "Attempting uninstall on #{spec.full_name}"
|
73
|
+
|
59
74
|
options[:args] = [spec.name]
|
60
75
|
options[:version] = "= #{spec.version}"
|
61
76
|
options[:executables] = true
|
77
|
+
|
62
78
|
uninstall_command.merge_options(options)
|
79
|
+
|
63
80
|
begin
|
64
81
|
uninstall_command.execute
|
65
82
|
rescue Gem::DependencyRemovalException => ex
|
@@ -67,6 +84,7 @@ module Gem
|
|
67
84
|
end
|
68
85
|
end
|
69
86
|
end
|
87
|
+
|
70
88
|
say "Clean Up Complete"
|
71
89
|
end
|
72
90
|
end
|