rubygems-update 1.8.30 → 2.0.0.preview2
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.
- checksums.yaml +6 -6
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +3 -0
- data/.autotest +6 -3
- data/History.txt +137 -63
- data/LICENSE.txt +1 -5
- data/Manifest.txt +69 -32
- data/README.rdoc +11 -9
- data/Rakefile +24 -38
- data/bin/gem +0 -9
- data/bin/update_rubygems +1 -0
- data/lib/rubygems.rb +193 -405
- data/lib/rubygems/available_set.rb +95 -0
- data/lib/rubygems/command.rb +88 -45
- data/lib/rubygems/command_manager.rb +67 -40
- data/lib/rubygems/commands/build_command.rb +5 -23
- data/lib/rubygems/commands/cert_command.rb +199 -57
- data/lib/rubygems/commands/check_command.rb +14 -39
- data/lib/rubygems/commands/cleanup_command.rb +9 -1
- data/lib/rubygems/commands/contents_command.rb +30 -12
- data/lib/rubygems/commands/dependency_command.rb +3 -8
- data/lib/rubygems/commands/environment_command.rb +13 -8
- data/lib/rubygems/commands/fetch_command.rb +3 -16
- data/lib/rubygems/commands/generate_index_command.rb +7 -47
- data/lib/rubygems/commands/help_command.rb +1 -1
- data/lib/rubygems/commands/install_command.rb +69 -36
- data/lib/rubygems/commands/list_command.rb +6 -4
- data/lib/rubygems/commands/lock_command.rb +1 -1
- data/lib/rubygems/commands/mirror_command.rb +17 -0
- data/lib/rubygems/commands/outdated_command.rb +6 -3
- data/lib/rubygems/commands/owner_command.rb +13 -5
- data/lib/rubygems/commands/pristine_command.rb +19 -4
- data/lib/rubygems/commands/push_command.rb +12 -1
- data/lib/rubygems/commands/query_command.rb +43 -27
- data/lib/rubygems/commands/rdoc_command.rb +23 -28
- data/lib/rubygems/commands/search_command.rb +4 -18
- data/lib/rubygems/commands/server_command.rb +1 -1
- data/lib/rubygems/commands/setup_command.rb +124 -38
- data/lib/rubygems/commands/sources_command.rb +16 -16
- data/lib/rubygems/commands/specification_command.rb +11 -13
- data/lib/rubygems/commands/uninstall_command.rb +24 -7
- data/lib/rubygems/commands/unpack_command.rb +7 -3
- data/lib/rubygems/commands/update_command.rb +22 -36
- data/lib/rubygems/commands/yank_command.rb +98 -0
- data/lib/rubygems/compatibility.rb +51 -0
- data/lib/rubygems/config_file.rb +82 -54
- data/lib/rubygems/core_ext/kernel_gem.rb +53 -0
- data/lib/rubygems/core_ext/kernel_require.rb +119 -0
- data/lib/rubygems/defaults.rb +10 -21
- data/lib/rubygems/dependency.rb +61 -10
- data/lib/rubygems/dependency_installer.rb +157 -69
- data/lib/rubygems/dependency_list.rb +11 -19
- data/lib/rubygems/dependency_resolver.rb +562 -0
- data/lib/rubygems/deprecate.rb +40 -40
- data/lib/rubygems/errors.rb +77 -24
- data/lib/rubygems/exceptions.rb +25 -7
- data/lib/rubygems/ext/builder.rb +20 -23
- data/lib/rubygems/ext/configure_builder.rb +2 -2
- data/lib/rubygems/ext/ext_conf_builder.rb +5 -45
- data/lib/rubygems/ext/rake_builder.rb +2 -2
- data/lib/rubygems/gem_runner.rb +3 -16
- data/lib/rubygems/gemcutter_utilities.rb +22 -7
- data/lib/rubygems/indexer.rb +6 -159
- data/lib/rubygems/install_message.rb +12 -0
- data/lib/rubygems/install_update_options.rb +56 -18
- data/lib/rubygems/installer.rb +244 -134
- data/lib/rubygems/installer_test_case.rb +71 -19
- data/lib/rubygems/mock_gem_ui.rb +17 -0
- data/lib/rubygems/name_tuple.rb +110 -0
- data/lib/rubygems/package.rb +514 -43
- data/lib/rubygems/package/digest_io.rb +64 -0
- data/lib/rubygems/package/old.rb +147 -0
- data/lib/rubygems/package/tar_header.rb +18 -55
- data/lib/rubygems/package/tar_reader.rb +20 -3
- data/lib/rubygems/package/tar_writer.rb +63 -7
- data/lib/rubygems/package_task.rb +3 -4
- data/lib/rubygems/path_support.rb +14 -7
- data/lib/rubygems/platform.rb +19 -26
- data/lib/rubygems/rdoc.rb +316 -0
- data/lib/rubygems/remote_fetcher.rb +117 -54
- data/lib/rubygems/request_set.rb +182 -0
- data/lib/rubygems/requirement.rb +63 -26
- data/lib/rubygems/security.rb +295 -555
- data/lib/rubygems/security/policies.rb +115 -0
- data/lib/rubygems/security/policy.rb +227 -0
- data/lib/rubygems/security/signer.rb +136 -0
- data/lib/rubygems/security/trust_dir.rb +104 -0
- data/lib/rubygems/server.rb +45 -55
- data/lib/rubygems/source.rb +144 -0
- data/lib/rubygems/source_list.rb +87 -0
- data/lib/rubygems/source_local.rb +92 -0
- data/lib/rubygems/source_specific_file.rb +28 -0
- data/lib/rubygems/spec_fetcher.rb +116 -184
- data/lib/rubygems/specification.rb +731 -335
- data/lib/rubygems/ssl_certs/AddTrustExternalCARoot.pem +88 -30
- data/lib/rubygems/ssl_certs/Entrust_net-Secure-Server-Certification-Authority.pem +90 -0
- data/lib/rubygems/ssl_certs/VerisignClass3PublicPrimaryCertificationAuthority-G2.pem +57 -0
- data/lib/rubygems/syck_hack.rb +2 -0
- data/lib/rubygems/test_case.rb +199 -109
- data/lib/rubygems/test_utilities.rb +25 -5
- data/lib/rubygems/uninstaller.rb +62 -20
- data/lib/rubygems/user_interaction.rb +10 -0
- data/lib/rubygems/validator.rb +33 -40
- data/lib/rubygems/version.rb +19 -8
- data/setup.rb +8 -1
- data/test/rubygems/alternate_cert.pem +9 -0
- data/test/rubygems/alternate_cert_32.pem +9 -0
- data/test/rubygems/alternate_key.pem +9 -0
- data/test/rubygems/bad_rake.rb +1 -0
- data/test/rubygems/child_cert.pem +9 -0
- data/test/rubygems/child_cert_32.pem +9 -0
- data/test/rubygems/child_key.pem +9 -0
- data/test/rubygems/data/null-type.gemspec.rz +0 -0
- data/test/rubygems/expired_cert.pem +9 -0
- data/test/rubygems/future_cert.pem +9 -0
- data/test/rubygems/future_cert_32.pem +9 -0
- data/test/rubygems/good_rake.rb +1 -0
- data/test/rubygems/grandchild_cert.pem +9 -0
- data/test/rubygems/grandchild_cert_32.pem +9 -0
- data/test/rubygems/grandchild_key.pem +9 -0
- data/test/rubygems/invalid_issuer_cert.pem +9 -0
- data/test/rubygems/invalid_issuer_cert_32.pem +9 -0
- data/test/rubygems/invalid_key.pem +9 -0
- data/test/rubygems/invalid_signer_cert.pem +9 -0
- data/test/rubygems/invalid_signer_cert_32.pem +9 -0
- data/test/rubygems/invalidchild_cert.pem +9 -0
- data/test/rubygems/invalidchild_cert_32.pem +9 -0
- data/test/rubygems/invalidchild_key.pem +9 -0
- data/test/rubygems/plugin/exception/rubygems_plugin.rb +1 -1
- data/test/rubygems/plugin/standarderror/rubygems_plugin.rb +1 -1
- data/test/rubygems/private_key.pem +7 -25
- data/test/rubygems/public_cert.pem +8 -18
- data/test/rubygems/public_cert_32.pem +10 -0
- data/test/rubygems/public_key.pem +4 -0
- data/test/rubygems/rubygems/commands/crash_command.rb +1 -1
- data/test/rubygems/test_config.rb +4 -6
- data/test/rubygems/test_deprecate.rb +76 -0
- data/test/rubygems/test_gem.rb +318 -83
- data/test/rubygems/test_gem_available_set.rb +106 -0
- data/test/rubygems/test_gem_command.rb +10 -0
- data/test/rubygems/test_gem_command_manager.rb +55 -9
- data/test/rubygems/test_gem_commands_build_command.rb +11 -19
- data/test/rubygems/test_gem_commands_cert_command.rb +441 -42
- data/test/rubygems/test_gem_commands_cleanup_command.rb +29 -1
- data/test/rubygems/test_gem_commands_contents_command.rb +23 -0
- data/test/rubygems/test_gem_commands_dependency_command.rb +5 -0
- data/test/rubygems/test_gem_commands_fetch_command.rb +19 -20
- data/test/rubygems/test_gem_commands_generate_index_command.rb +2 -83
- data/test/rubygems/test_gem_commands_help_command.rb +2 -1
- data/test/rubygems/test_gem_commands_install_command.rb +647 -48
- data/test/rubygems/test_gem_commands_mirror.rb +32 -0
- data/test/rubygems/test_gem_commands_owner_command.rb +4 -8
- data/test/rubygems/test_gem_commands_pristine_command.rb +99 -4
- data/test/rubygems/test_gem_commands_push_command.rb +62 -8
- data/test/rubygems/test_gem_commands_query_command.rb +51 -0
- data/test/rubygems/test_gem_commands_search_command.rb +25 -0
- data/test/rubygems/test_gem_commands_setup_command.rb +45 -0
- data/test/rubygems/test_gem_commands_sources_command.rb +21 -6
- data/test/rubygems/test_gem_commands_specification_command.rb +33 -1
- data/test/rubygems/test_gem_commands_uninstall_command.rb +91 -31
- data/test/rubygems/test_gem_commands_unpack_command.rb +3 -3
- data/test/rubygems/test_gem_commands_update_command.rb +56 -38
- data/test/rubygems/test_gem_commands_which_command.rb +4 -4
- data/test/rubygems/test_gem_commands_yank_command.rb +97 -0
- data/test/rubygems/test_gem_config_file.rb +66 -21
- data/test/rubygems/test_gem_dependency.rb +46 -0
- data/test/rubygems/test_gem_dependency_installer.rb +228 -18
- data/test/rubygems/test_gem_dependency_list.rb +0 -9
- data/test/rubygems/test_gem_dependency_resolver.rb +327 -0
- data/test/rubygems/test_gem_ext_configure_builder.rb +4 -4
- data/test/rubygems/test_gem_ext_ext_conf_builder.rb +21 -49
- data/test/rubygems/test_gem_ext_rake_builder.rb +13 -13
- data/test/rubygems/test_gem_gem_runner.rb +27 -5
- data/test/rubygems/test_gem_gemcutter_utilities.rb +19 -0
- data/test/rubygems/test_gem_indexer.rb +14 -227
- data/test/rubygems/test_gem_install_update_options.rb +83 -3
- data/test/rubygems/test_gem_installer.rb +211 -236
- data/test/rubygems/test_gem_local_remote_options.rb +8 -2
- data/test/rubygems/test_gem_name_tuple.rb +15 -0
- data/test/rubygems/test_gem_package.rb +547 -0
- data/test/rubygems/test_gem_package_old.rb +37 -0
- data/test/rubygems/test_gem_package_tar_reader.rb +32 -0
- data/test/rubygems/test_gem_package_tar_writer.rb +84 -1
- data/test/rubygems/test_gem_path_support.rb +4 -30
- data/test/rubygems/test_gem_platform.rb +3 -6
- data/test/rubygems/test_gem_rdoc.rb +245 -0
- data/test/rubygems/test_gem_remote_fetcher.rb +51 -5
- data/test/rubygems/test_gem_request_set.rb +70 -0
- data/test/rubygems/test_gem_requirement.rb +53 -24
- data/test/rubygems/test_gem_security.rb +189 -43
- data/test/rubygems/test_gem_security_policy.rb +376 -0
- data/test/rubygems/test_gem_security_signer.rb +184 -0
- data/test/rubygems/test_gem_security_trust_dir.rb +94 -0
- data/test/rubygems/test_gem_server.rb +31 -36
- data/test/rubygems/test_gem_silent_ui.rb +2 -2
- data/test/rubygems/test_gem_source.rb +188 -0
- data/test/rubygems/test_gem_source_list.rb +87 -0
- data/test/rubygems/test_gem_source_local.rb +83 -0
- data/test/rubygems/test_gem_source_specific_file.rb +33 -0
- data/test/rubygems/test_gem_spec_fetcher.rb +91 -255
- data/test/rubygems/test_gem_specification.rb +293 -39
- data/test/rubygems/test_gem_uninstaller.rb +136 -13
- data/test/rubygems/test_gem_validator.rb +14 -41
- data/test/rubygems/test_gem_version.rb +15 -21
- data/test/rubygems/test_require.rb +193 -0
- data/test/rubygems/wrong_key_cert.pem +9 -0
- data/test/rubygems/wrong_key_cert_32.pem +9 -0
- metadata +171 -83
- metadata.gz.sig +1 -0
- data/CVE-2013-4287.txt +0 -36
- data/CVE-2013-4363.txt +0 -45
- data/ci_build.sh +0 -27
- data/cruise_config.rb +0 -32
- data/lib/rbconfig/datadir.rb +0 -13
- data/lib/rubygems/builder.rb +0 -99
- data/lib/rubygems/custom_require.rb +0 -69
- data/lib/rubygems/doc_manager.rb +0 -243
- data/lib/rubygems/format.rb +0 -82
- data/lib/rubygems/gem_openssl.rb +0 -90
- data/lib/rubygems/gem_path_searcher.rb +0 -172
- data/lib/rubygems/old_format.rb +0 -153
- data/lib/rubygems/package/f_sync_dir.rb +0 -23
- data/lib/rubygems/package/tar_input.rb +0 -234
- data/lib/rubygems/package/tar_output.rb +0 -146
- data/lib/rubygems/require_paths_builder.rb +0 -18
- data/lib/rubygems/source_index.rb +0 -406
- data/lib/rubygems/ssl_certs/AddTrustExternalCARoot-2048.pem +0 -25
- data/lib/rubygems/ssl_certs/Class3PublicPrimaryCertificationAuthority.pem +0 -14
- data/lib/rubygems/ssl_certs/DigiCertHighAssuranceEVRootCA.pem +0 -23
- data/lib/rubygems/ssl_certs/EntrustnetSecureServerCertificationAuthority.pem +0 -28
- data/lib/rubygems/ssl_certs/GeoTrustGlobalCA.pem +0 -20
- data/test/rubygems/test_bundled_ca.rb +0 -59
- data/test/rubygems/test_gem_builder.rb +0 -44
- data/test/rubygems/test_gem_doc_manager.rb +0 -32
- data/test/rubygems/test_gem_ext_builder.rb +0 -58
- data/test/rubygems/test_gem_format.rb +0 -88
- data/test/rubygems/test_gem_gem_path_searcher.rb +0 -94
- data/test/rubygems/test_gem_package_tar_input.rb +0 -129
- data/test/rubygems/test_gem_package_tar_output.rb +0 -101
- data/test/rubygems/test_gem_source_index.rb +0 -250
- data/util/update_bundled_ca_certificates.rb +0 -103
@@ -48,7 +48,7 @@ class Gem::Commands::SourcesCommand < Gem::Command
|
|
48
48
|
options[:update])
|
49
49
|
|
50
50
|
if options[:clear_all] then
|
51
|
-
path = Gem
|
51
|
+
path = File.join Gem.user_home, '.gem', 'specs'
|
52
52
|
FileUtils.rm_rf path
|
53
53
|
|
54
54
|
unless File.exist? path then
|
@@ -64,16 +64,19 @@ class Gem::Commands::SourcesCommand < Gem::Command
|
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
|
-
if options[:add] then
|
68
|
-
|
69
|
-
uri = URI.parse source_uri
|
67
|
+
if source_uri = options[:add] then
|
68
|
+
source = Gem::Source.new source_uri
|
70
69
|
|
71
70
|
begin
|
72
|
-
Gem
|
73
|
-
|
74
|
-
|
71
|
+
if Gem.sources.include? source_uri then
|
72
|
+
say "source #{source_uri} already present in the cache"
|
73
|
+
else
|
74
|
+
source.load_specs :released
|
75
|
+
Gem.sources << source
|
76
|
+
Gem.configuration.write
|
75
77
|
|
76
|
-
|
78
|
+
say "#{source_uri} added to sources"
|
79
|
+
end
|
77
80
|
rescue URI::Error, ArgumentError
|
78
81
|
say "#{source_uri} is not a URI"
|
79
82
|
terminate_interaction 1
|
@@ -97,12 +100,9 @@ class Gem::Commands::SourcesCommand < Gem::Command
|
|
97
100
|
end
|
98
101
|
|
99
102
|
if options[:update] then
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
update_uri = URI.parse update_uri
|
104
|
-
fetcher.load_specs update_uri, 'specs'
|
105
|
-
fetcher.load_specs update_uri, 'latest_specs'
|
103
|
+
Gem.sources.each_source do |src|
|
104
|
+
src.load_specs :released
|
105
|
+
src.load_specs :latest
|
106
106
|
end
|
107
107
|
|
108
108
|
say "source cache successfully updated"
|
@@ -112,8 +112,8 @@ class Gem::Commands::SourcesCommand < Gem::Command
|
|
112
112
|
say "*** CURRENT SOURCES ***"
|
113
113
|
say
|
114
114
|
|
115
|
-
Gem.sources.each do |
|
116
|
-
say
|
115
|
+
Gem.sources.each do |src|
|
116
|
+
say src
|
117
117
|
end
|
118
118
|
end
|
119
119
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'rubygems/command'
|
2
2
|
require 'rubygems/local_remote_options'
|
3
3
|
require 'rubygems/version_option'
|
4
|
-
require 'rubygems/
|
4
|
+
require 'rubygems/package'
|
5
5
|
|
6
6
|
class Gem::Commands::SpecificationCommand < Gem::Command
|
7
7
|
|
@@ -17,6 +17,7 @@ class Gem::Commands::SpecificationCommand < Gem::Command
|
|
17
17
|
|
18
18
|
add_version_option('examine')
|
19
19
|
add_platform_option
|
20
|
+
add_prerelease_option
|
20
21
|
|
21
22
|
add_option('--all', 'Output specifications for all versions of',
|
22
23
|
'the gem') do |value, options|
|
@@ -62,13 +63,13 @@ FIELD name of gemspec field to show
|
|
62
63
|
"Please specify a gem name or file on the command line"
|
63
64
|
end
|
64
65
|
|
65
|
-
case options[:version]
|
66
|
+
case v = options[:version]
|
66
67
|
when String
|
67
|
-
req = Gem::Requirement.
|
68
|
+
req = Gem::Requirement.create v
|
68
69
|
when Gem::Requirement
|
69
|
-
req =
|
70
|
+
req = v
|
70
71
|
else
|
71
|
-
raise Gem::CommandLineError, "Unsupported version type: #{
|
72
|
+
raise Gem::CommandLineError, "Unsupported version type: '#{v}'"
|
72
73
|
end
|
73
74
|
|
74
75
|
if !req.none? and options[:all]
|
@@ -79,7 +80,7 @@ FIELD name of gemspec field to show
|
|
79
80
|
if options[:all]
|
80
81
|
dep = Gem::Dependency.new gem
|
81
82
|
else
|
82
|
-
dep = Gem::Dependency.new gem,
|
83
|
+
dep = Gem::Dependency.new gem, req
|
83
84
|
end
|
84
85
|
|
85
86
|
field = get_one_optional_argument
|
@@ -89,7 +90,7 @@ FIELD name of gemspec field to show
|
|
89
90
|
|
90
91
|
if local? then
|
91
92
|
if File.exist? gem then
|
92
|
-
specs << Gem::
|
93
|
+
specs << Gem::Package.new(gem).spec rescue nil
|
93
94
|
end
|
94
95
|
|
95
96
|
if specs.empty? then
|
@@ -98,17 +99,14 @@ FIELD name of gemspec field to show
|
|
98
99
|
end
|
99
100
|
|
100
101
|
if remote? then
|
101
|
-
|
102
|
-
|
103
|
-
if dep.prerelease? or options[:prerelease]
|
104
|
-
found += Gem::SpecFetcher.fetcher.fetch dep, false, true, true
|
105
|
-
end
|
102
|
+
dep.prerelease = options[:prerelease]
|
103
|
+
found, _ = Gem::SpecFetcher.fetcher.spec_for_dependency dep
|
106
104
|
|
107
105
|
specs.push(*found.map { |spec,| spec })
|
108
106
|
end
|
109
107
|
|
110
108
|
if specs.empty? then
|
111
|
-
alert_error "
|
109
|
+
alert_error "No gem matching '#{dep}' found"
|
112
110
|
terminate_interaction 1
|
113
111
|
end
|
114
112
|
|
@@ -13,7 +13,8 @@ class Gem::Commands::UninstallCommand < Gem::Command
|
|
13
13
|
|
14
14
|
def initialize
|
15
15
|
super 'uninstall', 'Uninstall gems from the local repository',
|
16
|
-
:version => Gem::Requirement.default, :user_install => true
|
16
|
+
:version => Gem::Requirement.default, :user_install => true,
|
17
|
+
:check_dev => false
|
17
18
|
|
18
19
|
add_option('-a', '--[no-]all',
|
19
20
|
'Uninstall all matching versions'
|
@@ -27,6 +28,12 @@ class Gem::Commands::UninstallCommand < Gem::Command
|
|
27
28
|
options[:ignore] = value
|
28
29
|
end
|
29
30
|
|
31
|
+
add_option('-D', '--[no-]-check-development',
|
32
|
+
'Check development dependencies while uninstalling',
|
33
|
+
'(default: false)') do |value, options|
|
34
|
+
options[:check_dev] = value
|
35
|
+
end
|
36
|
+
|
30
37
|
add_option('-x', '--[no-]executables',
|
31
38
|
'Uninstall applicable executables without',
|
32
39
|
'confirmation') do |value, options|
|
@@ -54,6 +61,12 @@ class Gem::Commands::UninstallCommand < Gem::Command
|
|
54
61
|
options[:format_executable] = value
|
55
62
|
end
|
56
63
|
|
64
|
+
add_option('--[no-]force',
|
65
|
+
'Uninstall all versions of the named gems',
|
66
|
+
'ignoring dependencies') do |value, options|
|
67
|
+
options[:force] = value
|
68
|
+
end
|
69
|
+
|
57
70
|
add_version_option
|
58
71
|
add_platform_option
|
59
72
|
end
|
@@ -73,19 +86,23 @@ class Gem::Commands::UninstallCommand < Gem::Command
|
|
73
86
|
end
|
74
87
|
|
75
88
|
def execute
|
76
|
-
|
89
|
+
# REFACTOR: stolen from cleanup_command
|
90
|
+
deplist = Gem::DependencyList.new
|
91
|
+
get_all_gem_names.uniq.each do |name|
|
92
|
+
Gem::Specification.find_all_by_name(name).each do |spec|
|
93
|
+
deplist.add spec
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
deps = deplist.strongly_connected_components.flatten.reverse
|
77
98
|
|
78
|
-
|
99
|
+
deps.map(&:name).uniq.each do |gem_name|
|
79
100
|
begin
|
80
101
|
Gem::Uninstaller.new(gem_name, options).uninstall
|
81
|
-
rescue Gem::InstallError => e
|
82
|
-
alert e.message
|
83
102
|
rescue Gem::GemNotInHomeException => e
|
84
103
|
spec = e.spec
|
85
104
|
alert("In order to remove #{spec.name}, please execute:\n" \
|
86
105
|
"\tgem uninstall #{spec.name} --install-dir=#{spec.installation_path}")
|
87
|
-
ensure
|
88
|
-
Gem.use_paths(*original_path)
|
89
106
|
end
|
90
107
|
end
|
91
108
|
end
|
@@ -69,8 +69,10 @@ class Gem::Commands::UnpackCommand < Gem::Command
|
|
69
69
|
else
|
70
70
|
basename = File.basename path, '.gem'
|
71
71
|
target_dir = File.expand_path basename, options[:target]
|
72
|
-
|
73
|
-
Gem::
|
72
|
+
|
73
|
+
package = Gem::Package.new path
|
74
|
+
package.extract_files target_dir
|
75
|
+
|
74
76
|
say "Unpacked gem: '#{target_dir}'"
|
75
77
|
end
|
76
78
|
end
|
@@ -134,9 +136,11 @@ class Gem::Commands::UnpackCommand < Gem::Command
|
|
134
136
|
##
|
135
137
|
# Extracts the Gem::Specification and raw metadata from the .gem file at
|
136
138
|
# +path+.
|
139
|
+
#--
|
140
|
+
# TODO move to Gem::Package as #raw_spec or something
|
137
141
|
|
138
142
|
def get_metadata path
|
139
|
-
format = Gem::
|
143
|
+
format = Gem::Package.new path
|
140
144
|
spec = format.spec
|
141
145
|
|
142
146
|
metadata = nil
|
@@ -1,10 +1,12 @@
|
|
1
1
|
require 'rubygems/command'
|
2
2
|
require 'rubygems/command_manager'
|
3
|
+
require 'rubygems/dependency_installer'
|
3
4
|
require 'rubygems/install_update_options'
|
4
5
|
require 'rubygems/local_remote_options'
|
5
6
|
require 'rubygems/spec_fetcher'
|
6
7
|
require 'rubygems/version_option'
|
7
|
-
require 'rubygems/
|
8
|
+
require 'rubygems/install_message' # must come before rdoc for messaging
|
9
|
+
require 'rubygems/rdoc'
|
8
10
|
|
9
11
|
class Gem::Commands::UpdateCommand < Gem::Command
|
10
12
|
|
@@ -13,11 +15,9 @@ class Gem::Commands::UpdateCommand < Gem::Command
|
|
13
15
|
include Gem::VersionOption
|
14
16
|
|
15
17
|
def initialize
|
16
|
-
super 'update',
|
17
|
-
|
18
|
-
:
|
19
|
-
:generate_ri => true,
|
20
|
-
:force => false
|
18
|
+
super 'update', 'Update installed gems to the latest version',
|
19
|
+
:document => %w[rdoc ri],
|
20
|
+
:force => false
|
21
21
|
|
22
22
|
add_install_update_options
|
23
23
|
|
@@ -37,6 +37,9 @@ class Gem::Commands::UpdateCommand < Gem::Command
|
|
37
37
|
add_local_remote_options
|
38
38
|
add_platform_option
|
39
39
|
add_prerelease_option "as update targets"
|
40
|
+
|
41
|
+
@updated = []
|
42
|
+
@installer = Gem::DependencyInstaller.new options
|
40
43
|
end
|
41
44
|
|
42
45
|
def arguments # :nodoc:
|
@@ -44,7 +47,7 @@ class Gem::Commands::UpdateCommand < Gem::Command
|
|
44
47
|
end
|
45
48
|
|
46
49
|
def defaults_str # :nodoc:
|
47
|
-
"--
|
50
|
+
"--document --no-force --install-dir #{Gem.dir}"
|
48
51
|
end
|
49
52
|
|
50
53
|
def usage # :nodoc:
|
@@ -52,9 +55,6 @@ class Gem::Commands::UpdateCommand < Gem::Command
|
|
52
55
|
end
|
53
56
|
|
54
57
|
def execute
|
55
|
-
@installer = Gem::DependencyInstaller.new options
|
56
|
-
@updated = []
|
57
|
-
|
58
58
|
hig = {}
|
59
59
|
|
60
60
|
if options[:system] then
|
@@ -79,21 +79,7 @@ class Gem::Commands::UpdateCommand < Gem::Command
|
|
79
79
|
if updated.empty? then
|
80
80
|
say "Nothing to update"
|
81
81
|
else
|
82
|
-
say "Gems updated: #{updated.map { |spec| spec.name }.join '
|
83
|
-
|
84
|
-
if options[:generate_ri] then
|
85
|
-
updated.each do |gem|
|
86
|
-
Gem::DocManager.new(gem, options[:rdoc_args]).generate_ri
|
87
|
-
end
|
88
|
-
|
89
|
-
Gem::DocManager.update_ri_cache
|
90
|
-
end
|
91
|
-
|
92
|
-
if options[:generate_rdoc] then
|
93
|
-
updated.each do |gem|
|
94
|
-
Gem::DocManager.new(gem, options[:rdoc_args]).generate_rdoc
|
95
|
-
end
|
96
|
-
end
|
82
|
+
say "Gems updated: #{updated.map { |spec| spec.name }.join ' '}"
|
97
83
|
end
|
98
84
|
end
|
99
85
|
|
@@ -112,7 +98,6 @@ class Gem::Commands::UpdateCommand < Gem::Command
|
|
112
98
|
|
113
99
|
@installer.installed_gems.each do |spec|
|
114
100
|
@updated << spec
|
115
|
-
say "Successfully installed #{spec.full_name}" if success
|
116
101
|
end
|
117
102
|
end
|
118
103
|
|
@@ -178,8 +163,9 @@ class Gem::Commands::UpdateCommand < Gem::Command
|
|
178
163
|
|
179
164
|
args = []
|
180
165
|
args << '--prefix' << Gem.prefix if Gem.prefix
|
181
|
-
|
182
|
-
args << '--no-
|
166
|
+
# TODO use --document for >= 1.9 , --no-rdoc --no-ri < 1.9
|
167
|
+
args << '--no-rdoc' unless options[:document].include? 'rdoc'
|
168
|
+
args << '--no-ri' unless options[:document].include? 'ri'
|
183
169
|
args << '--no-format-executable' if options[:no_format_executable]
|
184
170
|
|
185
171
|
update_dir = File.join Gem.dir, 'gems', "rubygems-update-#{version}"
|
@@ -205,20 +191,20 @@ class Gem::Commands::UpdateCommand < Gem::Command
|
|
205
191
|
gem_names.all? { |name| /#{name}/ !~ l_spec.name }
|
206
192
|
|
207
193
|
dependency = Gem::Dependency.new l_spec.name, "> #{l_spec.version}"
|
194
|
+
dependency.prerelease = options[:prerelease]
|
208
195
|
|
209
196
|
fetcher = Gem::SpecFetcher.fetcher
|
210
|
-
spec_tuples = fetcher.find_matching dependency
|
211
197
|
|
212
|
-
|
213
|
-
|
198
|
+
spec_tuples, _ = fetcher.search_for_dependency dependency
|
199
|
+
|
200
|
+
matching_gems = spec_tuples.select do |g,_|
|
201
|
+
g.name == l_name and g.match_platform?
|
214
202
|
end
|
215
203
|
|
216
|
-
highest_remote_gem = matching_gems.sort_by
|
217
|
-
version
|
218
|
-
end.last
|
204
|
+
highest_remote_gem = matching_gems.sort_by { |g,_| g.version }.last
|
219
205
|
|
220
|
-
highest_remote_gem ||= [
|
221
|
-
highest_remote_ver = highest_remote_gem.first
|
206
|
+
highest_remote_gem ||= [Gem::NameTuple.null]
|
207
|
+
highest_remote_ver = highest_remote_gem.first.version
|
222
208
|
|
223
209
|
if system or (l_spec.version < highest_remote_ver) then
|
224
210
|
result << [l_spec.name, [l_spec.version, highest_remote_ver].max]
|
@@ -0,0 +1,98 @@
|
|
1
|
+
require 'rubygems/command'
|
2
|
+
require 'rubygems/local_remote_options'
|
3
|
+
require 'rubygems/version_option'
|
4
|
+
require 'rubygems/gemcutter_utilities'
|
5
|
+
|
6
|
+
class Gem::Commands::YankCommand < Gem::Command
|
7
|
+
include Gem::LocalRemoteOptions
|
8
|
+
include Gem::VersionOption
|
9
|
+
include Gem::GemcutterUtilities
|
10
|
+
|
11
|
+
def description # :nodoc:
|
12
|
+
'Remove a specific gem version release from RubyGems.org'
|
13
|
+
end
|
14
|
+
|
15
|
+
def arguments # :nodoc:
|
16
|
+
"GEM name of gem"
|
17
|
+
end
|
18
|
+
|
19
|
+
def usage # :nodoc:
|
20
|
+
"#{program_name} GEM -v VERSION [-p PLATFORM] [--undo] [--key KEY_NAME]"
|
21
|
+
end
|
22
|
+
|
23
|
+
def initialize
|
24
|
+
super 'yank', description
|
25
|
+
|
26
|
+
add_version_option("remove")
|
27
|
+
add_platform_option("remove")
|
28
|
+
|
29
|
+
add_option('--undo') do |value, options|
|
30
|
+
options[:undo] = true
|
31
|
+
end
|
32
|
+
|
33
|
+
add_option('-k', '--key KEY_NAME',
|
34
|
+
'Use API key from your gem credentials file') do |value, options|
|
35
|
+
options[:key] = value
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def execute
|
40
|
+
sign_in
|
41
|
+
|
42
|
+
version = get_version_from_requirements(options[:version])
|
43
|
+
platform = get_platform_from_requirements(options)
|
44
|
+
api_key = Gem.configuration.rubygems_api_key
|
45
|
+
api_key = Gem.configuration.api_keys[options[:key].to_sym] if options[:key]
|
46
|
+
|
47
|
+
if version then
|
48
|
+
if options[:undo] then
|
49
|
+
unyank_gem(version, platform, api_key)
|
50
|
+
else
|
51
|
+
yank_gem(version, platform, api_key)
|
52
|
+
end
|
53
|
+
else
|
54
|
+
say "A version argument is required: #{usage}"
|
55
|
+
terminate_interaction
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def yank_gem(version, platform, api_key)
|
60
|
+
say "Yanking gem from #{self.host}..."
|
61
|
+
yank_api_request(:delete, version, platform, "api/v1/gems/yank", api_key)
|
62
|
+
end
|
63
|
+
|
64
|
+
def unyank_gem(version, platform, api_key)
|
65
|
+
say "Unyanking gem from #{host}..."
|
66
|
+
yank_api_request(:put, version, platform, "api/v1/gems/unyank", api_key)
|
67
|
+
end
|
68
|
+
|
69
|
+
private
|
70
|
+
|
71
|
+
def yank_api_request(method, version, platform, api, api_key)
|
72
|
+
name = get_one_gem_name
|
73
|
+
response = rubygems_api_request(method, api) do |request|
|
74
|
+
request.add_field("Authorization", api_key)
|
75
|
+
|
76
|
+
data = {
|
77
|
+
'gem_name' => name,
|
78
|
+
'version' => version,
|
79
|
+
}
|
80
|
+
data['platform'] = platform if platform
|
81
|
+
|
82
|
+
request.set_form_data data
|
83
|
+
end
|
84
|
+
say response.body
|
85
|
+
end
|
86
|
+
|
87
|
+
def get_version_from_requirements(requirements)
|
88
|
+
requirements.requirements.first[1].version
|
89
|
+
rescue
|
90
|
+
nil
|
91
|
+
end
|
92
|
+
|
93
|
+
def get_platform_from_requirements(requirements)
|
94
|
+
Gem.platforms[1].to_s if requirements.key? :added_platform
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
98
|
+
|