rubygems-update 2.0.17 → 2.1.0.rc.1
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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +2 -0
- data/.autotest +1 -1
- data/History.txt +82 -153
- data/Manifest.txt +35 -9
- data/Rakefile +35 -36
- data/lib/rubygems.rb +106 -18
- data/lib/rubygems/available_set.rb +68 -0
- data/lib/rubygems/basic_specification.rb +139 -0
- data/lib/rubygems/command_manager.rb +37 -40
- data/lib/rubygems/commands/cert_command.rb +78 -29
- data/lib/rubygems/commands/cleanup_command.rb +2 -2
- data/lib/rubygems/commands/contents_command.rb +101 -58
- data/lib/rubygems/commands/dependency_command.rb +94 -53
- data/lib/rubygems/commands/environment_command.rb +70 -53
- data/lib/rubygems/commands/fetch_command.rb +1 -2
- data/lib/rubygems/commands/help_command.rb +85 -55
- data/lib/rubygems/commands/install_command.rb +84 -42
- data/lib/rubygems/commands/outdated_command.rb +2 -12
- data/lib/rubygems/commands/owner_command.rb +6 -0
- data/lib/rubygems/commands/pristine_command.rb +26 -16
- data/lib/rubygems/commands/sources_command.rb +85 -70
- data/lib/rubygems/commands/uninstall_command.rb +32 -2
- data/lib/rubygems/commands/update_command.rb +111 -75
- data/lib/rubygems/config_file.rb +15 -3
- data/lib/rubygems/core_ext/kernel_require.rb +9 -31
- data/lib/rubygems/defaults.rb +8 -0
- data/lib/rubygems/dependency.rb +4 -2
- data/lib/rubygems/dependency_installer.rb +180 -170
- data/lib/rubygems/dependency_resolver.rb +191 -526
- data/lib/rubygems/dependency_resolver/activation_request.rb +109 -0
- data/lib/rubygems/dependency_resolver/api_set.rb +65 -0
- data/lib/rubygems/dependency_resolver/api_specification.rb +36 -0
- data/lib/rubygems/dependency_resolver/composed_set.rb +18 -0
- data/lib/rubygems/dependency_resolver/current_set.rb +16 -0
- data/lib/rubygems/dependency_resolver/dependency_conflict.rb +85 -0
- data/lib/rubygems/dependency_resolver/dependency_request.rb +51 -0
- data/lib/rubygems/dependency_resolver/index_set.rb +59 -0
- data/lib/rubygems/dependency_resolver/index_specification.rb +53 -0
- data/lib/rubygems/dependency_resolver/installed_specification.rb +38 -0
- data/lib/rubygems/dependency_resolver/installer_set.rb +130 -0
- data/lib/rubygems/exceptions.rb +88 -1
- data/lib/rubygems/ext/builder.rb +1 -1
- data/lib/rubygems/gem_runner.rb +17 -9
- data/lib/rubygems/gemcutter_utilities.rb +72 -42
- data/lib/rubygems/install_default_message.rb +12 -0
- data/lib/rubygems/install_update_options.rb +3 -0
- data/lib/rubygems/installer.rb +55 -30
- data/lib/rubygems/name_tuple.rb +18 -7
- data/lib/rubygems/package.rb +50 -25
- data/lib/rubygems/package/tar_test_case.rb +9 -9
- data/lib/rubygems/package/tar_writer.rb +35 -12
- data/lib/rubygems/package_task.rb +2 -5
- data/lib/rubygems/path_support.rb +10 -0
- data/lib/rubygems/platform.rb +9 -3
- data/lib/rubygems/psych_additions.rb +1 -1
- data/lib/rubygems/remote_fetcher.rb +9 -276
- data/lib/rubygems/request.rb +267 -0
- data/lib/rubygems/request_set.rb +123 -125
- data/lib/rubygems/request_set/gem_dependency_api.rb +39 -0
- data/lib/rubygems/security.rb +32 -23
- data/lib/rubygems/security/policy.rb +35 -9
- data/lib/rubygems/security/signer.rb +2 -2
- data/lib/rubygems/server.rb +8 -16
- data/lib/rubygems/source.rb +25 -14
- data/lib/rubygems/source/installed.rb +28 -0
- data/lib/rubygems/source/local.rb +122 -0
- data/lib/rubygems/source/specific_file.rb +28 -0
- data/lib/rubygems/source_local.rb +2 -89
- data/lib/rubygems/source_specific_file.rb +2 -26
- data/lib/rubygems/spec_fetcher.rb +11 -11
- data/lib/rubygems/specification.rb +186 -198
- 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/{GeoTrustGlobalCA.pem → GeoTrust_Global_CA.pem} +20 -20
- data/lib/rubygems/ssl_certs/VerisignClass3PublicPrimaryCertificationAuthority-G2.pem +57 -0
- data/lib/rubygems/stub_specification.rb +119 -0
- data/lib/rubygems/test_case.rb +117 -49
- data/lib/rubygems/uninstaller.rb +14 -9
- data/lib/rubygems/uri_formatter.rb +39 -0
- data/lib/rubygems/util/list.rb +44 -0
- data/lib/rubygems/version.rb +15 -5
- data/lib/rubygems/version_option.rb +8 -2
- data/test/rubygems/ca_cert.pem +23 -0
- data/test/rubygems/client.pem +49 -0
- data/test/rubygems/encrypted_private_key.pem +30 -0
- data/test/rubygems/invalid_client.pem +49 -0
- data/test/rubygems/specifications/bar-0.0.2.gemspec +9 -0
- data/test/rubygems/specifications/foo-0.0.1.gemspec +0 -0
- data/test/rubygems/test_gem.rb +76 -454
- data/test/rubygems/test_gem_command_manager.rb +23 -21
- data/test/rubygems/test_gem_commands_cert_command.rb +154 -14
- data/test/rubygems/test_gem_commands_cleanup_command.rb +15 -0
- data/test/rubygems/test_gem_commands_contents_command.rb +32 -4
- data/test/rubygems/test_gem_commands_environment_command.rb +9 -1
- data/test/rubygems/test_gem_commands_fetch_command.rb +2 -28
- data/test/rubygems/test_gem_commands_help_command.rb +6 -3
- data/test/rubygems/test_gem_commands_install_command.rb +2 -65
- data/test/rubygems/test_gem_commands_owner_command.rb +49 -0
- data/test/rubygems/test_gem_commands_pristine_command.rb +30 -0
- data/test/rubygems/test_gem_commands_sources_command.rb +1 -1
- data/test/rubygems/test_gem_commands_uninstall_command.rb +33 -0
- data/test/rubygems/test_gem_commands_update_command.rb +2 -1
- data/test/rubygems/test_gem_config_file.rb +12 -0
- data/test/rubygems/test_gem_dependency_installer.rb +58 -65
- data/test/rubygems/test_gem_dependency_resolver.rb +6 -3
- data/test/rubygems/test_gem_dependency_resolver_dependency_conflict.rb +36 -0
- data/test/rubygems/test_gem_ext_builder.rb +2 -4
- data/test/rubygems/test_gem_ext_ext_conf_builder.rb +7 -2
- data/test/rubygems/test_gem_gem_runner.rb +17 -13
- data/test/rubygems/test_gem_gemcutter_utilities.rb +6 -19
- data/test/rubygems/test_gem_impossible_dependencies_error.rb +41 -0
- data/test/rubygems/test_gem_install_update_options.rb +4 -1
- data/test/rubygems/test_gem_installer.rb +31 -2
- data/test/rubygems/test_gem_name_tuple.rb +22 -0
- data/test/rubygems/test_gem_package.rb +122 -11
- data/test/rubygems/test_gem_package_old.rb +8 -0
- data/test/rubygems/test_gem_package_tar_reader.rb +9 -8
- data/test/rubygems/test_gem_package_tar_reader_entry.rb +1 -1
- data/test/rubygems/test_gem_package_tar_writer.rb +78 -56
- data/test/rubygems/test_gem_package_task.rb +2 -23
- data/test/rubygems/test_gem_path_support.rb +17 -0
- data/test/rubygems/test_gem_platform.rb +18 -0
- data/test/rubygems/test_gem_remote_fetcher.rb +106 -385
- data/test/rubygems/test_gem_request.rb +239 -0
- data/test/rubygems/test_gem_requirement.rb +9 -11
- data/test/rubygems/test_gem_security.rb +58 -2
- data/test/rubygems/test_gem_security_policy.rb +42 -1
- data/test/rubygems/test_gem_security_signer.rb +13 -1
- data/test/rubygems/test_gem_security_trust_dir.rb +5 -1
- data/test/rubygems/test_gem_server.rb +1 -105
- data/test/rubygems/test_gem_source.rb +4 -14
- data/test/rubygems/test_gem_source_local.rb +4 -4
- data/test/rubygems/test_gem_source_specific_file.rb +1 -1
- data/test/rubygems/test_gem_spec_fetcher.rb +0 -12
- data/test/rubygems/test_gem_specification.rb +452 -28
- data/test/rubygems/test_gem_stub_specification.rb +30 -0
- data/test/rubygems/test_gem_uninstaller.rb +14 -0
- data/test/rubygems/test_gem_uri_formatter.rb +20 -0
- data/test/rubygems/test_gem_version.rb +23 -13
- data/test/rubygems/test_gem_version_option.rb +63 -1
- data/test/rubygems/test_require.rb +0 -12
- data/util/create_encrypted_key.rb +16 -0
- metadata +161 -23
- metadata.gz.sig +0 -0
- data/CVE-2013-4287.txt +0 -36
- data/CVE-2013-4363.txt +0 -45
- 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/test/rubygems/test_bundled_ca.rb +0 -59
- data/util/update_bundled_ca_certificates.rb +0 -103
@@ -4,8 +4,6 @@ require 'rubygems/dependency_installer'
|
|
4
4
|
require 'rubygems/local_remote_options'
|
5
5
|
require 'rubygems/validator'
|
6
6
|
require 'rubygems/version_option'
|
7
|
-
require 'rubygems/install_message' # must come before rdoc for messaging
|
8
|
-
require 'rubygems/rdoc'
|
9
7
|
|
10
8
|
##
|
11
9
|
# Gem installer command line tool
|
@@ -40,6 +38,12 @@ class Gem::Commands::InstallCommand < Gem::Command
|
|
40
38
|
o[:gemdeps] = v
|
41
39
|
end
|
42
40
|
|
41
|
+
add_option(:"Install/Update", '--default',
|
42
|
+
'Add the gem\'s full specification to',
|
43
|
+
'specifications/default and extract only its bin') do |v,o|
|
44
|
+
o[:install_as_default] = v
|
45
|
+
end
|
46
|
+
|
43
47
|
@installed_specs = nil
|
44
48
|
end
|
45
49
|
|
@@ -109,7 +113,44 @@ to write the specification by hand. For example:
|
|
109
113
|
"#{program_name} GEMNAME [GEMNAME ...] [options] -- --build-flags"
|
110
114
|
end
|
111
115
|
|
112
|
-
def
|
116
|
+
def check_install_dir # :nodoc:
|
117
|
+
if options[:install_dir] and options[:user_install] then
|
118
|
+
alert_error "Use --install-dir or --user-install but not both"
|
119
|
+
terminate_interaction 1
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
def check_version # :nodoc:
|
124
|
+
if options[:version] != Gem::Requirement.default and
|
125
|
+
get_all_gem_names.size > 1 then
|
126
|
+
alert_error "Can't use --version w/ multiple gems. Use name:ver instead."
|
127
|
+
terminate_interaction 1
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
def execute
|
132
|
+
if gf = options[:gemdeps] then
|
133
|
+
install_from_gemdeps gf
|
134
|
+
return
|
135
|
+
end
|
136
|
+
|
137
|
+
@installed_specs = []
|
138
|
+
|
139
|
+
ENV.delete 'GEM_PATH' if options[:install_dir].nil? and RUBY_VERSION > '1.9'
|
140
|
+
|
141
|
+
check_install_dir
|
142
|
+
check_version
|
143
|
+
|
144
|
+
load_hooks
|
145
|
+
|
146
|
+
exit_code = install_gems
|
147
|
+
|
148
|
+
show_installed
|
149
|
+
|
150
|
+
raise Gem::SystemExitException, exit_code
|
151
|
+
end
|
152
|
+
|
153
|
+
def install_from_gemdeps gf # :nodoc:
|
113
154
|
require 'rubygems/request_set'
|
114
155
|
rs = Gem::RequestSet.new
|
115
156
|
rs.load_gemdeps gf
|
@@ -131,51 +172,26 @@ to write the specification by hand. For example:
|
|
131
172
|
raise Gem::SystemExitException, 0
|
132
173
|
end
|
133
174
|
|
134
|
-
def
|
135
|
-
if
|
136
|
-
|
137
|
-
return
|
138
|
-
end
|
175
|
+
def install_gem name, version # :nodoc:
|
176
|
+
return if options[:conservative] and
|
177
|
+
not Gem::Dependency.new(name, version).matching_specs.empty?
|
139
178
|
|
140
|
-
|
179
|
+
inst = Gem::DependencyInstaller.new options
|
180
|
+
inst.install name, Gem::Requirement.create(version)
|
141
181
|
|
142
|
-
|
182
|
+
@installed_specs.push(*inst.installed_gems)
|
143
183
|
|
144
|
-
|
145
|
-
|
146
|
-
terminate_interaction 1
|
147
|
-
end
|
184
|
+
show_install_errors inst.errors
|
185
|
+
end
|
148
186
|
|
187
|
+
def install_gems # :nodoc:
|
149
188
|
exit_code = 0
|
150
189
|
|
151
|
-
if options[:version] != Gem::Requirement.default &&
|
152
|
-
get_all_gem_names.size > 1 then
|
153
|
-
alert_error "Can't use --version w/ multiple gems. Use name:ver instead."
|
154
|
-
terminate_interaction 1
|
155
|
-
end
|
156
|
-
|
157
|
-
|
158
190
|
get_all_gem_names_and_versions.each do |gem_name, gem_version|
|
159
191
|
gem_version ||= options[:version]
|
160
192
|
|
161
193
|
begin
|
162
|
-
|
163
|
-
not Gem::Dependency.new(gem_name, gem_version).matching_specs.empty?
|
164
|
-
|
165
|
-
inst = Gem::DependencyInstaller.new options
|
166
|
-
inst.install gem_name, Gem::Requirement.create(gem_version)
|
167
|
-
|
168
|
-
@installed_specs.push(*inst.installed_gems)
|
169
|
-
|
170
|
-
next unless errs = inst.errors
|
171
|
-
|
172
|
-
errs.each do |x|
|
173
|
-
next unless Gem::SourceFetchProblem === x
|
174
|
-
|
175
|
-
msg = "Unable to pull data from '#{x.source.uri}': #{x.error.message}"
|
176
|
-
|
177
|
-
alert_warning msg
|
178
|
-
end
|
194
|
+
install_gem gem_name, gem_version
|
179
195
|
rescue Gem::InstallError => e
|
180
196
|
alert_error "Error installing #{gem_name}:\n\t#{e.message}"
|
181
197
|
exit_code |= 1
|
@@ -186,12 +202,38 @@ to write the specification by hand. For example:
|
|
186
202
|
end
|
187
203
|
end
|
188
204
|
|
189
|
-
|
190
|
-
|
191
|
-
|
205
|
+
exit_code
|
206
|
+
end
|
207
|
+
|
208
|
+
##
|
209
|
+
# Loads post-install hooks
|
210
|
+
|
211
|
+
def load_hooks # :nodoc:
|
212
|
+
if options[:install_as_default]
|
213
|
+
require 'rubygems/install_default_message'
|
214
|
+
else
|
215
|
+
require 'rubygems/install_message'
|
192
216
|
end
|
217
|
+
require 'rubygems/rdoc'
|
218
|
+
end
|
193
219
|
|
194
|
-
|
220
|
+
def show_install_errors errors # :nodoc:
|
221
|
+
return unless errors
|
222
|
+
|
223
|
+
errors.each do |x|
|
224
|
+
return unless Gem::SourceFetchProblem === x
|
225
|
+
|
226
|
+
msg = "Unable to pull data from '#{x.source.uri}': #{x.error.message}"
|
227
|
+
|
228
|
+
alert_warning msg
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
232
|
+
def show_installed # :nodoc:
|
233
|
+
return if @installed_specs.empty?
|
234
|
+
|
235
|
+
gems = @installed_specs.length == 1 ? 'gem' : 'gems'
|
236
|
+
say "#{@installed_specs.length} #{gems} installed"
|
195
237
|
end
|
196
238
|
|
197
239
|
end
|
@@ -16,18 +16,8 @@ class Gem::Commands::OutdatedCommand < Gem::Command
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def execute
|
19
|
-
Gem::Specification.
|
20
|
-
|
21
|
-
dep = Gem::Dependency.new local.name, ">= #{local.version}"
|
22
|
-
remotes, _ = Gem::SpecFetcher.fetcher.spec_for_dependency dep
|
23
|
-
|
24
|
-
next if remotes.empty?
|
25
|
-
|
26
|
-
remotes.sort! { |a,b| a[0].version <=> b[0].version }
|
27
|
-
|
28
|
-
highest = remotes.last.first
|
29
|
-
|
30
|
-
say "#{local.name} (#{local.version} < #{highest.version})"
|
19
|
+
Gem::Specification.outdated_and_latest_version.each do |spec, remote_version|
|
20
|
+
say "#{spec.name} (#{spec.version} < #{remote_version})"
|
31
21
|
end
|
32
22
|
end
|
33
23
|
end
|
@@ -31,9 +31,15 @@ class Gem::Commands::OwnerCommand < Gem::Command
|
|
31
31
|
add_option '-r', '--remove EMAIL', 'Remove an owner' do |value, options|
|
32
32
|
options[:remove] << value
|
33
33
|
end
|
34
|
+
|
35
|
+
add_option '-h', '--host HOST', 'Use another gemcutter-compatible host' do |value, options|
|
36
|
+
options[:host] = value
|
37
|
+
end
|
34
38
|
end
|
35
39
|
|
36
40
|
def execute
|
41
|
+
@host = options[:host]
|
42
|
+
|
37
43
|
sign_in
|
38
44
|
name = get_one_gem_name
|
39
45
|
|
@@ -21,8 +21,7 @@ class Gem::Commands::PristineCommand < Gem::Command
|
|
21
21
|
end
|
22
22
|
|
23
23
|
add_option('--[no-]extensions',
|
24
|
-
'Restore gems with extensions',
|
25
|
-
'in addition to regular gems') do |value, options|
|
24
|
+
'Restore gems with extensions') do |value, options|
|
26
25
|
options[:extensions] = value
|
27
26
|
end
|
28
27
|
|
@@ -31,6 +30,12 @@ class Gem::Commands::PristineCommand < Gem::Command
|
|
31
30
|
options[:only_executables] = value
|
32
31
|
end
|
33
32
|
|
33
|
+
add_option('-E', '--[no-]env-shebang',
|
34
|
+
'Rewrite executables with a shebang',
|
35
|
+
'of /usr/bin/env') do |value, options|
|
36
|
+
options[:env_shebang] = value
|
37
|
+
end
|
38
|
+
|
34
39
|
add_version_option('restore to', 'pristine condition')
|
35
40
|
end
|
36
41
|
|
@@ -44,23 +49,23 @@ class Gem::Commands::PristineCommand < Gem::Command
|
|
44
49
|
|
45
50
|
def description # :nodoc:
|
46
51
|
<<-EOF
|
47
|
-
The pristine command compares
|
48
|
-
cached
|
49
|
-
copy.
|
52
|
+
The pristine command compares the installed gems with the contents of the
|
53
|
+
cached gem and restores any files that don't match the cached gem's copy.
|
50
54
|
|
51
|
-
If you have made modifications to
|
52
|
-
will revert them.
|
53
|
-
|
55
|
+
If you have made modifications to your installed gems, the pristine command
|
56
|
+
will revert them. After all the gem's files have been checked all bin stubs
|
57
|
+
for the gem are regenerated.
|
54
58
|
|
55
|
-
If the cached gem cannot be found
|
59
|
+
If the cached gem cannot be found, you will need to use `gem install` to
|
60
|
+
revert the gem.
|
56
61
|
|
57
|
-
If --no-extensions is provided pristine will not attempt to restore
|
58
|
-
with
|
62
|
+
If --no-extensions is provided pristine will not attempt to restore gems
|
63
|
+
with extensions.
|
59
64
|
EOF
|
60
65
|
end
|
61
66
|
|
62
67
|
def usage # :nodoc:
|
63
|
-
"#{program_name} [
|
68
|
+
"#{program_name} [args]"
|
64
69
|
end
|
65
70
|
|
66
71
|
def execute
|
@@ -105,16 +110,21 @@ with an extension.
|
|
105
110
|
Gem::RemoteFetcher.fetcher.download_to_cache dep
|
106
111
|
end
|
107
112
|
|
108
|
-
|
109
|
-
|
110
|
-
|
113
|
+
env_shebang =
|
114
|
+
if options.include? :env_shebang then
|
115
|
+
options[:env_shebang]
|
116
|
+
else
|
117
|
+
install_defaults = Gem::ConfigFile::PLATFORM_DEFAULTS['install']
|
118
|
+
install_defaults.to_s['--env-shebang']
|
119
|
+
end
|
111
120
|
|
112
121
|
installer = Gem::Installer.new(gem,
|
113
122
|
:wrappers => true,
|
114
123
|
:force => true,
|
115
124
|
:install_dir => spec.base_dir,
|
116
|
-
:env_shebang =>
|
125
|
+
:env_shebang => env_shebang,
|
117
126
|
:build_args => spec.build_args)
|
127
|
+
|
118
128
|
if options[:only_executables] then
|
119
129
|
installer.generate_bin
|
120
130
|
else
|
@@ -37,103 +37,118 @@ class Gem::Commands::SourcesCommand < Gem::Command
|
|
37
37
|
add_proxy_option
|
38
38
|
end
|
39
39
|
|
40
|
-
def
|
41
|
-
|
42
|
-
end
|
40
|
+
def add_source source_uri # :nodoc:
|
41
|
+
check_rubygems_https source_uri
|
43
42
|
|
44
|
-
|
45
|
-
options[:list] = !(options[:add] ||
|
46
|
-
options[:clear_all] ||
|
47
|
-
options[:remove] ||
|
48
|
-
options[:update])
|
43
|
+
source = Gem::Source.new source_uri
|
49
44
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
unless File.exist? path then
|
55
|
-
say "*** Removed specs cache ***"
|
45
|
+
begin
|
46
|
+
if Gem.sources.include? source_uri then
|
47
|
+
say "source #{source_uri} already present in the cache"
|
56
48
|
else
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
say "*** Unable to remove source cache ***"
|
61
|
-
end
|
49
|
+
source.load_specs :released
|
50
|
+
Gem.sources << source
|
51
|
+
Gem.configuration.write
|
62
52
|
|
63
|
-
|
53
|
+
say "#{source_uri} added to sources"
|
64
54
|
end
|
55
|
+
rescue URI::Error, ArgumentError
|
56
|
+
say "#{source_uri} is not a URI"
|
57
|
+
terminate_interaction 1
|
58
|
+
rescue Gem::RemoteFetcher::FetchError => e
|
59
|
+
say "Error fetching #{source_uri}:\n\t#{e.message}"
|
60
|
+
terminate_interaction 1
|
65
61
|
end
|
62
|
+
end
|
66
63
|
|
67
|
-
|
68
|
-
|
64
|
+
def check_rubygems_https source_uri # :nodoc:
|
65
|
+
uri = URI source_uri
|
69
66
|
|
70
|
-
|
71
|
-
|
72
|
-
|
67
|
+
if uri.scheme and uri.scheme.downcase == 'http' and
|
68
|
+
uri.host.downcase == 'rubygems.org' then
|
69
|
+
question = <<-QUESTION.chomp
|
73
70
|
https://rubygems.org is recommended for security over #{uri}
|
74
71
|
|
75
72
|
Do you want to add this insecure source?
|
76
|
-
|
77
|
-
|
78
|
-
terminate_interaction 1 unless ask_yes_no question
|
79
|
-
end
|
73
|
+
QUESTION
|
80
74
|
|
81
|
-
|
82
|
-
|
83
|
-
begin
|
84
|
-
if Gem.sources.include? source_uri then
|
85
|
-
say "source #{source_uri} already present in the cache"
|
86
|
-
else
|
87
|
-
source.load_specs :released
|
88
|
-
Gem.sources << source
|
89
|
-
Gem.configuration.write
|
90
|
-
|
91
|
-
say "#{source_uri} added to sources"
|
92
|
-
end
|
93
|
-
rescue URI::Error, ArgumentError
|
94
|
-
say "#{source_uri} is not a URI"
|
95
|
-
terminate_interaction 1
|
96
|
-
rescue Gem::RemoteFetcher::FetchError => e
|
97
|
-
say "Error fetching #{source_uri}:\n\t#{e.message}"
|
98
|
-
terminate_interaction 1
|
99
|
-
end
|
75
|
+
terminate_interaction 1 unless ask_yes_no question
|
100
76
|
end
|
77
|
+
end
|
101
78
|
|
102
|
-
|
103
|
-
|
79
|
+
def clear_all # :nodoc:
|
80
|
+
path = Gem.spec_cache_dir
|
81
|
+
FileUtils.rm_rf path
|
104
82
|
|
105
|
-
|
106
|
-
|
83
|
+
unless File.exist? path then
|
84
|
+
say "*** Removed specs cache ***"
|
85
|
+
else
|
86
|
+
unless File.writable? path then
|
87
|
+
say "*** Unable to remove source cache (write protected) ***"
|
107
88
|
else
|
108
|
-
|
109
|
-
Gem.configuration.write
|
110
|
-
|
111
|
-
say "#{source_uri} removed from sources"
|
89
|
+
say "*** Unable to remove source cache ***"
|
112
90
|
end
|
91
|
+
|
92
|
+
terminate_interaction 1
|
113
93
|
end
|
94
|
+
end
|
114
95
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
96
|
+
def defaults_str # :nodoc:
|
97
|
+
'--list'
|
98
|
+
end
|
99
|
+
|
100
|
+
def list # :nodoc:
|
101
|
+
say "*** CURRENT SOURCES ***"
|
102
|
+
say
|
120
103
|
|
121
|
-
|
104
|
+
Gem.sources.each do |src|
|
105
|
+
say src
|
122
106
|
end
|
107
|
+
end
|
123
108
|
|
124
|
-
|
125
|
-
|
126
|
-
|
109
|
+
def list? # :nodoc:
|
110
|
+
!(options[:list] ||
|
111
|
+
options[:add] ||
|
112
|
+
options[:clear_all] ||
|
113
|
+
options[:remove] ||
|
114
|
+
options[:update])
|
115
|
+
end
|
127
116
|
|
128
|
-
|
129
|
-
|
130
|
-
|
117
|
+
def execute
|
118
|
+
clear_all if options[:clear_all]
|
119
|
+
|
120
|
+
source_uri = options[:add]
|
121
|
+
add_source source_uri if source_uri
|
122
|
+
|
123
|
+
source_uri = options[:remove]
|
124
|
+
remove_source source_uri if source_uri
|
125
|
+
|
126
|
+
update if options[:update]
|
127
|
+
|
128
|
+
list if list?
|
129
|
+
end
|
130
|
+
|
131
|
+
def remove_source source_uri # :nodoc:
|
132
|
+
unless Gem.sources.include? source_uri then
|
133
|
+
say "source #{source_uri} not present in cache"
|
134
|
+
else
|
135
|
+
Gem.sources.delete source_uri
|
136
|
+
Gem.configuration.write
|
137
|
+
|
138
|
+
say "#{source_uri} removed from sources"
|
131
139
|
end
|
132
140
|
end
|
133
141
|
|
134
|
-
|
142
|
+
def update # :nodoc:
|
143
|
+
Gem.sources.each_source do |src|
|
144
|
+
src.load_specs :released
|
145
|
+
src.load_specs :latest
|
146
|
+
end
|
147
|
+
|
148
|
+
say "source cache successfully updated"
|
149
|
+
end
|
135
150
|
|
136
|
-
def remove_cache_file
|
151
|
+
def remove_cache_file desc, path # :nodoc:
|
137
152
|
FileUtils.rm_rf path
|
138
153
|
|
139
154
|
if not File.exist?(path) then
|