rubygems-update 1.8.30 → 2.0.0.preview2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -0,0 +1,51 @@
|
|
1
|
+
# This file contains all sorts of little compatibility hacks that we've
|
2
|
+
# had to introduce over the years. Quarantining them into one file helps
|
3
|
+
# us know when we can get rid of them.
|
4
|
+
|
5
|
+
# Ruby 1.9.x has introduced some things that are awkward, and we need to
|
6
|
+
# support them, so we define some constants to use later.
|
7
|
+
module Gem
|
8
|
+
# Only MRI 1.9.2 has the custom prelude.
|
9
|
+
GEM_PRELUDE_SUCKAGE = RUBY_VERSION =~ /^1\.9\.2/ and RUBY_ENGINE == "ruby"
|
10
|
+
end
|
11
|
+
|
12
|
+
# Gem::QuickLoader exists in the gem prelude code in ruby 1.9.2 itself.
|
13
|
+
# We gotta get rid of it if it's there, before we do anything else.
|
14
|
+
if Gem::GEM_PRELUDE_SUCKAGE and defined?(Gem::QuickLoader) then
|
15
|
+
Gem::QuickLoader.remove
|
16
|
+
|
17
|
+
$LOADED_FEATURES.delete Gem::QuickLoader.path_to_full_rubygems_library
|
18
|
+
|
19
|
+
if $LOADED_FEATURES.any? do |path| path.end_with? '/rubygems.rb' end then
|
20
|
+
# TODO path does not exist here
|
21
|
+
raise LoadError, "another rubygems is already loaded from #{path}"
|
22
|
+
end
|
23
|
+
|
24
|
+
class << Gem
|
25
|
+
remove_method :try_activate if Gem.respond_to?(:try_activate, true)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
module Gem
|
30
|
+
RubyGemsVersion = VERSION
|
31
|
+
|
32
|
+
RbConfigPriorities = %w[
|
33
|
+
EXEEXT RUBY_SO_NAME arch bindir datadir libdir ruby_install_name
|
34
|
+
ruby_version rubylibprefix sitedir sitelibdir vendordir vendorlibdir
|
35
|
+
rubylibdir
|
36
|
+
]
|
37
|
+
|
38
|
+
unless defined?(ConfigMap)
|
39
|
+
##
|
40
|
+
# Configuration settings from ::RbConfig
|
41
|
+
ConfigMap = Hash.new do |cm, key|
|
42
|
+
cm[key] = RbConfig::CONFIG[key.to_s]
|
43
|
+
end
|
44
|
+
else
|
45
|
+
RbConfigPriorities.each do |key|
|
46
|
+
ConfigMap[key.to_sym] = RbConfig::CONFIG[key]
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
RubyGemsPackageVersion = VERSION
|
51
|
+
end
|
data/lib/rubygems/config_file.rb
CHANGED
@@ -5,9 +5,9 @@
|
|
5
5
|
#++
|
6
6
|
|
7
7
|
##
|
8
|
-
# Gem::ConfigFile RubyGems options and gem command options from
|
8
|
+
# Gem::ConfigFile RubyGems options and gem command options from gemrc.
|
9
9
|
#
|
10
|
-
#
|
10
|
+
# gemrc is a YAML file that uses strings to match gem command arguments and
|
11
11
|
# symbols to match RubyGems options.
|
12
12
|
#
|
13
13
|
# Gem command arguments use a String key that matches the command name and
|
@@ -21,16 +21,19 @@
|
|
21
21
|
# RubyGems options use symbol keys. Valid options are:
|
22
22
|
#
|
23
23
|
# +:backtrace+:: See #backtrace
|
24
|
-
# +:benchmark+:: See #benchmark
|
25
24
|
# +:sources+:: Sets Gem::sources
|
26
25
|
# +:verbose+:: See #verbose
|
27
|
-
|
28
|
-
|
26
|
+
#
|
27
|
+
# gemrc files may exist in various locations and are read and merged in
|
28
|
+
# the following order:
|
29
|
+
#
|
30
|
+
# - system wide (/etc/gemrc)
|
31
|
+
# - per user (~/.gemrc)
|
32
|
+
# - per environment (gemrc files listed in the GEMRC environment variable)
|
29
33
|
|
30
34
|
class Gem::ConfigFile
|
31
35
|
|
32
36
|
DEFAULT_BACKTRACE = false
|
33
|
-
DEFAULT_BENCHMARK = false
|
34
37
|
DEFAULT_BULK_THRESHOLD = 1000
|
35
38
|
DEFAULT_VERBOSITY = true
|
36
39
|
DEFAULT_UPDATE_SOURCES = true
|
@@ -96,11 +99,6 @@ class Gem::ConfigFile
|
|
96
99
|
|
97
100
|
attr_writer :backtrace
|
98
101
|
|
99
|
-
##
|
100
|
-
# True if we are benchmarking this run.
|
101
|
-
|
102
|
-
attr_accessor :benchmark
|
103
|
-
|
104
102
|
##
|
105
103
|
# Bulk threshold value. If the number of missing gems are above this
|
106
104
|
# threshold value, then a bulk download technique is used. (deprecated)
|
@@ -131,6 +129,10 @@ class Gem::ConfigFile
|
|
131
129
|
attr_reader :api_keys
|
132
130
|
|
133
131
|
##
|
132
|
+
# True if we want to force specification of gem server when pushing a gem
|
133
|
+
|
134
|
+
attr_accessor :disable_default_gem_server
|
135
|
+
|
134
136
|
# openssl verify mode value, used for remote https connection
|
135
137
|
|
136
138
|
attr_reader :ssl_verify_mode
|
@@ -158,29 +160,29 @@ class Gem::ConfigFile
|
|
158
160
|
# <tt>--debug</tt>::
|
159
161
|
# Enable Ruby level debug messages. Handled early for the same reason as
|
160
162
|
# --backtrace.
|
163
|
+
#--
|
164
|
+
# TODO: parse options upstream, pass in options directly
|
161
165
|
|
162
|
-
def initialize(
|
166
|
+
def initialize(args)
|
163
167
|
@config_file_name = nil
|
164
168
|
need_config_file_name = false
|
165
169
|
|
166
|
-
arg_list =
|
170
|
+
arg_list = []
|
171
|
+
|
172
|
+
args.each do |arg|
|
167
173
|
if need_config_file_name then
|
168
174
|
@config_file_name = arg
|
169
175
|
need_config_file_name = false
|
170
|
-
nil
|
171
176
|
elsif arg =~ /^--config-file=(.*)/ then
|
172
177
|
@config_file_name = $1
|
173
|
-
nil
|
174
178
|
elsif arg =~ /^--config-file$/ then
|
175
179
|
need_config_file_name = true
|
176
|
-
nil
|
177
180
|
else
|
178
|
-
arg
|
181
|
+
arg_list << arg
|
179
182
|
end
|
180
|
-
end
|
183
|
+
end
|
181
184
|
|
182
185
|
@backtrace = DEFAULT_BACKTRACE
|
183
|
-
@benchmark = DEFAULT_BENCHMARK
|
184
186
|
@bulk_threshold = DEFAULT_BULK_THRESHOLD
|
185
187
|
@verbose = DEFAULT_VERBOSITY
|
186
188
|
@update_sources = DEFAULT_UPDATE_SOURCES
|
@@ -189,19 +191,25 @@ class Gem::ConfigFile
|
|
189
191
|
platform_config = Marshal.load Marshal.dump(PLATFORM_DEFAULTS)
|
190
192
|
system_config = load_file SYSTEM_WIDE_CONFIG_FILE
|
191
193
|
user_config = load_file config_file_name.dup.untaint
|
194
|
+
environment_config = (ENV['GEMRC'] || '').split(/[:;]/).inject({}) do |result, file|
|
195
|
+
result.merge load_file file
|
196
|
+
end
|
197
|
+
|
192
198
|
|
193
199
|
@hash = operating_system_config.merge platform_config
|
194
200
|
@hash = @hash.merge system_config
|
195
201
|
@hash = @hash.merge user_config
|
202
|
+
@hash = @hash.merge environment_config
|
196
203
|
|
197
204
|
# HACK these override command-line args, which is bad
|
198
|
-
@backtrace
|
199
|
-
@
|
200
|
-
@
|
201
|
-
@
|
202
|
-
@
|
203
|
-
@
|
204
|
-
@
|
205
|
+
@backtrace = @hash[:backtrace] if @hash.key? :backtrace
|
206
|
+
@bulk_threshold = @hash[:bulk_threshold] if @hash.key? :bulk_threshold
|
207
|
+
@home = @hash[:gemhome] if @hash.key? :gemhome
|
208
|
+
@path = @hash[:gempath] if @hash.key? :gempath
|
209
|
+
@update_sources = @hash[:update_sources] if @hash.key? :update_sources
|
210
|
+
@verbose = @hash[:verbose] if @hash.key? :verbose
|
211
|
+
@disable_default_gem_server = @hash[:disable_default_gem_server] if @hash.key? :disable_default_gem_server
|
212
|
+
|
205
213
|
@ssl_verify_mode = @hash[:ssl_verify_mode] if @hash.key? :ssl_verify_mode
|
206
214
|
@ssl_ca_cert = @hash[:ssl_ca_cert] if @hash.key? :ssl_ca_cert
|
207
215
|
|
@@ -224,6 +232,7 @@ class Gem::ConfigFile
|
|
224
232
|
else
|
225
233
|
@hash
|
226
234
|
end
|
235
|
+
|
227
236
|
if @api_keys.key? :rubygems_api_key then
|
228
237
|
@rubygems_api_key = @api_keys[:rubygems_api_key]
|
229
238
|
@api_keys[:rubygems] = @api_keys.delete :rubygems_api_key unless @api_keys.key? :rubygems
|
@@ -238,7 +247,8 @@ class Gem::ConfigFile
|
|
238
247
|
|
239
248
|
Gem.load_yaml
|
240
249
|
|
241
|
-
File.
|
250
|
+
permissions = 0600 & (~File.umask)
|
251
|
+
File.open(credentials_path, 'w', permissions) do |f|
|
242
252
|
f.write config.to_yaml
|
243
253
|
end
|
244
254
|
|
@@ -249,13 +259,21 @@ class Gem::ConfigFile
|
|
249
259
|
Gem.load_yaml
|
250
260
|
|
251
261
|
return {} unless filename and File.exist? filename
|
262
|
+
|
252
263
|
begin
|
253
|
-
YAML.load(File.read(filename))
|
264
|
+
content = YAML.load(File.read(filename))
|
265
|
+
unless content.kind_of? Hash
|
266
|
+
warn "Failed to load #{config_file_name} because it doesn't contain valid YAML hash"
|
267
|
+
return {}
|
268
|
+
end
|
269
|
+
return content
|
254
270
|
rescue ArgumentError
|
255
271
|
warn "Failed to load #{config_file_name}"
|
256
272
|
rescue Errno::EACCES
|
257
273
|
warn "Failed to load #{config_file_name} due to permissions problem."
|
258
|
-
end
|
274
|
+
end
|
275
|
+
|
276
|
+
{}
|
259
277
|
end
|
260
278
|
|
261
279
|
# True if the backtrace option has been specified, or debug is on.
|
@@ -273,13 +291,11 @@ class Gem::ConfigFile
|
|
273
291
|
hash = @hash.dup
|
274
292
|
hash.delete :update_sources
|
275
293
|
hash.delete :verbose
|
276
|
-
hash.delete :benchmark
|
277
294
|
hash.delete :backtrace
|
278
295
|
hash.delete :bulk_threshold
|
279
296
|
|
280
297
|
yield :update_sources, @update_sources
|
281
298
|
yield :verbose, @verbose
|
282
|
-
yield :benchmark, @benchmark
|
283
299
|
yield :backtrace, @backtrace
|
284
300
|
yield :bulk_threshold, @bulk_threshold
|
285
301
|
|
@@ -296,8 +312,6 @@ class Gem::ConfigFile
|
|
296
312
|
case arg
|
297
313
|
when /^--(backtrace|traceback)$/ then
|
298
314
|
@backtrace = true
|
299
|
-
when /^--bench(mark)?$/ then
|
300
|
-
@benchmark = true
|
301
315
|
when /^--debug$/ then
|
302
316
|
$DEBUG = true
|
303
317
|
else
|
@@ -309,25 +323,41 @@ class Gem::ConfigFile
|
|
309
323
|
# Really verbose mode gives you extra output.
|
310
324
|
def really_verbose
|
311
325
|
case verbose
|
312
|
-
when true, false, nil then
|
313
|
-
|
326
|
+
when true, false, nil then
|
327
|
+
false
|
328
|
+
else
|
329
|
+
true
|
314
330
|
end
|
315
331
|
end
|
316
332
|
|
317
333
|
# to_yaml only overwrites things you can't override on the command line.
|
318
334
|
def to_yaml # :nodoc:
|
319
335
|
yaml_hash = {}
|
320
|
-
yaml_hash[:backtrace] = @hash.key?(:backtrace)
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
yaml_hash[:
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
336
|
+
yaml_hash[:backtrace] = if @hash.key?(:backtrace)
|
337
|
+
@hash[:backtrace]
|
338
|
+
else
|
339
|
+
DEFAULT_BACKTRACE
|
340
|
+
end
|
341
|
+
|
342
|
+
yaml_hash[:bulk_threshold] = if @hash.key?(:bulk_threshold)
|
343
|
+
@hash[:bulk_threshold]
|
344
|
+
else
|
345
|
+
DEFAULT_BULK_THRESHOLD
|
346
|
+
end
|
347
|
+
|
348
|
+
yaml_hash[:sources] = Gem.sources.to_a
|
349
|
+
|
350
|
+
yaml_hash[:update_sources] = if @hash.key?(:update_sources)
|
351
|
+
@hash[:update_sources]
|
352
|
+
else
|
353
|
+
DEFAULT_UPDATE_SOURCES
|
354
|
+
end
|
355
|
+
|
356
|
+
yaml_hash[:verbose] = if @hash.key?(:verbose)
|
357
|
+
@hash[:verbose]
|
358
|
+
else
|
359
|
+
DEFAULT_VERBOSITY
|
360
|
+
end
|
331
361
|
|
332
362
|
keys = yaml_hash.keys.map { |key| key.to_s }
|
333
363
|
keys << 'debug'
|
@@ -361,15 +391,13 @@ class Gem::ConfigFile
|
|
361
391
|
|
362
392
|
def ==(other) # :nodoc:
|
363
393
|
self.class === other and
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
@hash == other.hash
|
394
|
+
@backtrace == other.backtrace and
|
395
|
+
@bulk_threshold == other.bulk_threshold and
|
396
|
+
@verbose == other.verbose and
|
397
|
+
@update_sources == other.update_sources and
|
398
|
+
@hash == other.hash
|
370
399
|
end
|
371
400
|
|
372
|
-
protected
|
373
|
-
|
374
401
|
attr_reader :hash
|
402
|
+
protected :hash
|
375
403
|
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module Kernel
|
2
|
+
|
3
|
+
# REFACTOR: This should be pulled out into some kind of hacks file.
|
4
|
+
remove_method :gem if 'method' == defined? gem # from gem_prelude.rb on 1.9
|
5
|
+
|
6
|
+
##
|
7
|
+
# Use Kernel#gem to activate a specific version of +gem_name+.
|
8
|
+
#
|
9
|
+
# +requirements+ is a list of version requirements that the
|
10
|
+
# specified gem must match, most commonly "= example.version.number". See
|
11
|
+
# Gem::Requirement for how to specify a version requirement.
|
12
|
+
#
|
13
|
+
# If you will be activating the latest version of a gem, there is no need to
|
14
|
+
# call Kernel#gem, Kernel#require will do the right thing for you.
|
15
|
+
#
|
16
|
+
# Kernel#gem returns true if the gem was activated, otherwise false. If the
|
17
|
+
# gem could not be found, didn't match the version requirements, or a
|
18
|
+
# different version was already activated, an exception will be raised.
|
19
|
+
#
|
20
|
+
# Kernel#gem should be called *before* any require statements (otherwise
|
21
|
+
# RubyGems may load a conflicting library version).
|
22
|
+
#
|
23
|
+
# In older RubyGems versions, the environment variable GEM_SKIP could be
|
24
|
+
# used to skip activation of specified gems, for example to test out changes
|
25
|
+
# that haven't been installed yet. Now RubyGems defers to -I and the
|
26
|
+
# RUBYLIB environment variable to skip activation of a gem.
|
27
|
+
#
|
28
|
+
# Example:
|
29
|
+
#
|
30
|
+
# GEM_SKIP=libA:libB ruby -I../libA -I../libB ./mycode.rb
|
31
|
+
|
32
|
+
def gem(gem_name, *requirements) # :doc:
|
33
|
+
skip_list = (ENV['GEM_SKIP'] || "").split(/:/)
|
34
|
+
raise Gem::LoadError, "skipping #{gem_name}" if skip_list.include? gem_name
|
35
|
+
|
36
|
+
if gem_name.kind_of? Gem::Dependency
|
37
|
+
unless Gem::Deprecate.skip
|
38
|
+
warn "#{Gem.location_of_caller.join ':'}:Warning: Kernel.gem no longer "\
|
39
|
+
"accepts a Gem::Dependency object, please pass the name "\
|
40
|
+
"and requirements directly"
|
41
|
+
end
|
42
|
+
|
43
|
+
requirements = gem_name.requirement
|
44
|
+
gem_name = gem_name.name
|
45
|
+
end
|
46
|
+
|
47
|
+
spec = Gem::Dependency.new(gem_name, *requirements).to_spec
|
48
|
+
spec.activate if spec
|
49
|
+
end
|
50
|
+
|
51
|
+
private :gem
|
52
|
+
|
53
|
+
end
|
@@ -0,0 +1,119 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
|
3
|
+
# All rights reserved.
|
4
|
+
# See LICENSE.txt for permissions.
|
5
|
+
#++
|
6
|
+
|
7
|
+
module Kernel
|
8
|
+
|
9
|
+
if defined?(gem_original_require) then
|
10
|
+
# Ruby ships with a custom_require, override its require
|
11
|
+
remove_method :require
|
12
|
+
else
|
13
|
+
##
|
14
|
+
# The Kernel#require from before RubyGems was loaded.
|
15
|
+
|
16
|
+
alias gem_original_require require
|
17
|
+
private :gem_original_require
|
18
|
+
end
|
19
|
+
|
20
|
+
##
|
21
|
+
# When RubyGems is required, Kernel#require is replaced with our own which
|
22
|
+
# is capable of loading gems on demand.
|
23
|
+
#
|
24
|
+
# When you call <tt>require 'x'</tt>, this is what happens:
|
25
|
+
# * If the file can be loaded from the existing Ruby loadpath, it
|
26
|
+
# is.
|
27
|
+
# * Otherwise, installed gems are searched for a file that matches.
|
28
|
+
# If it's found in gem 'y', that gem is activated (added to the
|
29
|
+
# loadpath).
|
30
|
+
#
|
31
|
+
# The normal <tt>require</tt> functionality of returning false if
|
32
|
+
# that file has already been loaded is preserved.
|
33
|
+
|
34
|
+
def require path
|
35
|
+
spec = Gem.find_unresolved_default_spec(path)
|
36
|
+
if spec
|
37
|
+
Gem.remove_unresolved_default_spec(spec)
|
38
|
+
gem(spec.name)
|
39
|
+
end
|
40
|
+
|
41
|
+
# If there are no unresolved deps, then we can use just try
|
42
|
+
# normal require handle loading a gem from the rescue below.
|
43
|
+
|
44
|
+
if Gem::Specification.unresolved_deps.empty? then
|
45
|
+
return gem_original_require(path)
|
46
|
+
end
|
47
|
+
|
48
|
+
# If +path+ is for a gem that has already been loaded, don't
|
49
|
+
# bother trying to find it in an unresolved gem, just go straight
|
50
|
+
# to normal require.
|
51
|
+
#--
|
52
|
+
# TODO request access to the C implementation of this to speed up RubyGems
|
53
|
+
|
54
|
+
spec = Gem::Specification.find { |s|
|
55
|
+
s.activated? and s.contains_requirable_file? path
|
56
|
+
}
|
57
|
+
|
58
|
+
return gem_original_require(path) if spec
|
59
|
+
|
60
|
+
# Attempt to find +path+ in any unresolved gems...
|
61
|
+
|
62
|
+
found_specs = Gem::Specification.find_in_unresolved path
|
63
|
+
|
64
|
+
# If there are no directly unresolved gems, then try and find +path+
|
65
|
+
# in any gems that are available via the currently unresolved gems.
|
66
|
+
# For example, given:
|
67
|
+
#
|
68
|
+
# a => b => c => d
|
69
|
+
#
|
70
|
+
# If a and b are currently active with c being unresolved and d.rb is
|
71
|
+
# requested, then find_in_unresolved_tree will find d.rb in d because
|
72
|
+
# it's a dependency of c.
|
73
|
+
#
|
74
|
+
if found_specs.empty? then
|
75
|
+
found_specs = Gem::Specification.find_in_unresolved_tree path
|
76
|
+
|
77
|
+
found_specs.each do |found_spec|
|
78
|
+
found_spec.activate
|
79
|
+
end
|
80
|
+
|
81
|
+
# We found +path+ directly in an unresolved gem. Now we figure out, of
|
82
|
+
# the possible found specs, which one we should activate.
|
83
|
+
else
|
84
|
+
|
85
|
+
# Check that all the found specs are just different
|
86
|
+
# versions of the same gem
|
87
|
+
names = found_specs.map(&:name).uniq
|
88
|
+
|
89
|
+
if names.size > 1 then
|
90
|
+
raise Gem::LoadError, "#{path} found in multiple gems: #{names.join ', '}"
|
91
|
+
end
|
92
|
+
|
93
|
+
# Ok, now find a gem that has no conflicts, starting
|
94
|
+
# at the highest version.
|
95
|
+
valid = found_specs.select { |s| s.conflicts.empty? }.last
|
96
|
+
|
97
|
+
unless valid then
|
98
|
+
le = Gem::LoadError.new "unable to find a version of '#{names.first}' to activate"
|
99
|
+
le.name = names.first
|
100
|
+
raise le
|
101
|
+
end
|
102
|
+
|
103
|
+
valid.activate
|
104
|
+
end
|
105
|
+
|
106
|
+
gem_original_require path
|
107
|
+
rescue LoadError => load_error
|
108
|
+
if load_error.message.start_with?("Could not find") or
|
109
|
+
(load_error.message.end_with?(path) and Gem.try_activate(path)) then
|
110
|
+
return gem_original_require(path)
|
111
|
+
end
|
112
|
+
|
113
|
+
raise load_error
|
114
|
+
end
|
115
|
+
|
116
|
+
private :require
|
117
|
+
|
118
|
+
end
|
119
|
+
|