rubygems-update 3.0.3 → 3.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -0
- data/.travis.yml +2 -0
- data/CODE_OF_CONDUCT.md +10 -8
- data/CONTRIBUTING.md +7 -0
- data/History.txt +152 -0
- data/Manifest.txt +5 -3
- data/README.md +6 -0
- data/Rakefile +27 -7
- data/bundler/lib/bundler/build_metadata.rb +2 -2
- data/lib/rubygems.rb +7 -12
- data/lib/rubygems/command_manager.rb +6 -0
- data/lib/rubygems/commands/build_command.rb +28 -13
- data/lib/rubygems/commands/owner_command.rb +2 -0
- data/lib/rubygems/commands/push_command.rb +2 -0
- data/lib/rubygems/commands/setup_command.rb +9 -11
- data/lib/rubygems/commands/uninstall_command.rb +16 -6
- data/lib/rubygems/commands/which_command.rb +1 -3
- data/lib/rubygems/defaults.rb +1 -8
- data/lib/rubygems/dependency.rb +1 -1
- data/lib/rubygems/dependency_installer.rb +1 -2
- data/lib/rubygems/dependency_list.rb +1 -1
- data/lib/rubygems/exceptions.rb +0 -4
- data/lib/rubygems/gemcutter_utilities.rb +9 -5
- data/lib/rubygems/installer.rb +8 -5
- data/lib/rubygems/installer_test_case.rb +2 -2
- data/lib/rubygems/package/tar_header.rb +11 -2
- data/lib/rubygems/rdoc.rb +2 -2
- data/lib/rubygems/remote_fetcher.rb +15 -54
- data/lib/rubygems/request.rb +1 -1
- data/lib/rubygems/request_set/gem_dependency_api.rb +11 -10
- data/lib/rubygems/requirement.rb +0 -4
- data/lib/rubygems/resolver.rb +4 -1
- data/lib/rubygems/s3_uri_signer.rb +183 -0
- data/lib/rubygems/security_option.rb +0 -1
- data/lib/rubygems/specification.rb +21 -23
- data/lib/rubygems/ssl_certs/{index.rubygems.org → rubygems.org}/GlobalSignRootCA.pem +0 -0
- data/lib/rubygems/ssl_certs/rubygems.org/GlobalSignRootCA_R3.pem +21 -0
- data/lib/rubygems/stub_specification.rb +1 -2
- data/lib/rubygems/test_case.rb +22 -12
- data/lib/rubygems/uninstaller.rb +1 -1
- data/lib/rubygems/util.rb +12 -0
- data/rubygems-update.gemspec +1 -1
- data/test/rubygems/ca_cert.pem +74 -65
- data/test/rubygems/client.pem +103 -45
- data/test/rubygems/ssl_cert.pem +78 -17
- data/test/rubygems/ssl_key.pem +25 -13
- data/test/rubygems/test_bundled_ca.rb +8 -5
- data/test/rubygems/test_gem.rb +45 -11
- data/test/rubygems/test_gem_bundler_version_finder.rb +4 -0
- data/test/rubygems/test_gem_command_manager.rb +10 -0
- data/test/rubygems/test_gem_commands_build_command.rb +1 -0
- data/test/rubygems/test_gem_commands_push_command.rb +15 -0
- data/test/rubygems/test_gem_commands_setup_command.rb +11 -7
- data/test/rubygems/test_gem_commands_uninstall_command.rb +80 -1
- data/test/rubygems/test_gem_ext_cmake_builder.rb +1 -1
- data/test/rubygems/test_gem_indexer.rb +15 -8
- data/test/rubygems/test_gem_installer.rb +85 -22
- data/test/rubygems/test_gem_package_tar_header.rb +41 -0
- data/test/rubygems/test_gem_rdoc.rb +1 -135
- data/test/rubygems/test_gem_remote_fetcher.rb +133 -14
- data/test/rubygems/test_gem_request.rb +4 -4
- data/test/rubygems/test_gem_request_set_gem_dependency_api.rb +80 -57
- data/test/rubygems/test_gem_security_policy.rb +1 -1
- data/test/rubygems/test_gem_specification.rb +29 -0
- data/test/rubygems/test_gem_stream_ui.rb +2 -2
- data/test/rubygems/test_gem_uninstaller.rb +21 -2
- data/test/rubygems/test_gem_util.rb +8 -0
- data/util/ci +6 -1
- data/util/cops/deprecations.rb +52 -0
- data/util/create_certs.sh +27 -0
- data/util/create_encrypted_key.rb +4 -4
- data/util/update_bundled_ca_certificates.rb +1 -3
- metadata +12 -57
- data/bundler/man/bundle-add.1 +0 -58
- data/bundler/man/bundle-binstubs.1 +0 -40
- data/bundler/man/bundle-check.1 +0 -31
- data/bundler/man/bundle-clean.1 +0 -24
- data/bundler/man/bundle-config.1 +0 -497
- data/bundler/man/bundle-doctor.1 +0 -44
- data/bundler/man/bundle-exec.1 +0 -165
- data/bundler/man/bundle-gem.1 +0 -80
- data/bundler/man/bundle-info.1 +0 -20
- data/bundler/man/bundle-init.1 +0 -25
- data/bundler/man/bundle-inject.1 +0 -33
- data/bundler/man/bundle-install.1 +0 -308
- data/bundler/man/bundle-list.1 +0 -50
- data/bundler/man/bundle-lock.1 +0 -84
- data/bundler/man/bundle-open.1 +0 -32
- data/bundler/man/bundle-outdated.1 +0 -155
- data/bundler/man/bundle-package.1 +0 -55
- data/bundler/man/bundle-platform.1 +0 -61
- data/bundler/man/bundle-pristine.1 +0 -34
- data/bundler/man/bundle-remove.1 +0 -31
- data/bundler/man/bundle-show.1 +0 -23
- data/bundler/man/bundle-update.1 +0 -394
- data/bundler/man/bundle-viz.1 +0 -39
- data/bundler/man/bundle.1 +0 -136
- data/lib/rubygems/ssl_certs/rubygems.global.ssl.fastly.net/DigiCertHighAssuranceEVRootCA.pem +0 -23
- data/lib/rubygems/ssl_certs/rubygems.org/AddTrustExternalCARoot.pem +0 -25
data/lib/rubygems/request.rb
CHANGED
@@ -43,11 +43,12 @@ class Gem::RequestSet::GemDependencyAPI
|
|
43
43
|
:mri_20 => %w[ruby],
|
44
44
|
:mri_21 => %w[ruby],
|
45
45
|
:rbx => %w[rbx],
|
46
|
-
:
|
47
|
-
:
|
48
|
-
:
|
49
|
-
:
|
50
|
-
:
|
46
|
+
:truffleruby => %w[truffleruby],
|
47
|
+
:ruby => %w[ruby rbx maglev truffleruby],
|
48
|
+
:ruby_18 => %w[ruby rbx maglev truffleruby],
|
49
|
+
:ruby_19 => %w[ruby rbx maglev truffleruby],
|
50
|
+
:ruby_20 => %w[ruby rbx maglev truffleruby],
|
51
|
+
:ruby_21 => %w[ruby rbx maglev truffleruby],
|
51
52
|
}.freeze
|
52
53
|
|
53
54
|
mswin = Gem::Platform.new 'x86-mswin32'
|
@@ -85,6 +86,7 @@ class Gem::RequestSet::GemDependencyAPI
|
|
85
86
|
:ruby_19 => Gem::Platform::RUBY,
|
86
87
|
:ruby_20 => Gem::Platform::RUBY,
|
87
88
|
:ruby_21 => Gem::Platform::RUBY,
|
89
|
+
:truffleruby => Gem::Platform::RUBY,
|
88
90
|
:x64_mingw => x64_mingw,
|
89
91
|
:x64_mingw_20 => x64_mingw,
|
90
92
|
:x64_mingw_21 => x64_mingw
|
@@ -126,6 +128,7 @@ class Gem::RequestSet::GemDependencyAPI
|
|
126
128
|
:ruby_19 => tilde_gt_1_9_0,
|
127
129
|
:ruby_20 => tilde_gt_2_0_0,
|
128
130
|
:ruby_21 => tilde_gt_2_1_0,
|
131
|
+
:truffleruby => gt_eq_0,
|
129
132
|
:x64_mingw => gt_eq_0,
|
130
133
|
:x64_mingw_20 => tilde_gt_2_0_0,
|
131
134
|
:x64_mingw_21 => tilde_gt_2_1_0,
|
@@ -779,7 +782,7 @@ Gem dependencies file #{@path} includes git reference for both ref/branch and ta
|
|
779
782
|
# You may also provide +engine:+ and +engine_version:+ options to restrict
|
780
783
|
# this gem dependencies file to a particular ruby engine and its engine
|
781
784
|
# version. This matching is performed by using the RUBY_ENGINE and
|
782
|
-
#
|
785
|
+
# RUBY_ENGINE_VERSION constants.
|
783
786
|
|
784
787
|
def ruby(version, options = {})
|
785
788
|
engine = options[:engine]
|
@@ -806,11 +809,9 @@ Gem dependencies file #{@path} includes git reference for both ref/branch and ta
|
|
806
809
|
end
|
807
810
|
|
808
811
|
if engine_version
|
809
|
-
|
810
|
-
|
811
|
-
if engine_version != my_engine_version
|
812
|
+
if engine_version != RUBY_ENGINE_VERSION
|
812
813
|
message =
|
813
|
-
"Your Ruby engine version is #{Gem.ruby_engine} #{
|
814
|
+
"Your Ruby engine version is #{Gem.ruby_engine} #{RUBY_ENGINE_VERSION}, " +
|
814
815
|
"but your #{gem_deps_file} requires #{engine} #{engine_version}"
|
815
816
|
|
816
817
|
raise Gem::RubyVersionMismatch, message
|
data/lib/rubygems/requirement.rb
CHANGED
@@ -2,10 +2,6 @@
|
|
2
2
|
require "rubygems/version"
|
3
3
|
require "rubygems/deprecate"
|
4
4
|
|
5
|
-
# If we're being loaded after yaml was already required, then
|
6
|
-
# load our yaml + workarounds now.
|
7
|
-
Gem.load_yaml if defined? ::YAML
|
8
|
-
|
9
5
|
##
|
10
6
|
# A Requirement is a set of one or more version restrictions. It supports a
|
11
7
|
# few (<tt>=, !=, >, <, >=, <=, ~></tt>) different restriction operators.
|
data/lib/rubygems/resolver.rb
CHANGED
@@ -124,7 +124,10 @@ class Gem::Resolver
|
|
124
124
|
|
125
125
|
data = yield
|
126
126
|
$stderr.printf "%10s (%d entries)\n", stage.to_s.upcase, data.size
|
127
|
-
|
127
|
+
unless data.empty?
|
128
|
+
require 'pp'
|
129
|
+
PP.pp data, $stderr
|
130
|
+
end
|
128
131
|
end
|
129
132
|
|
130
133
|
##
|
@@ -0,0 +1,183 @@
|
|
1
|
+
require 'base64'
|
2
|
+
require 'digest'
|
3
|
+
require 'openssl'
|
4
|
+
|
5
|
+
##
|
6
|
+
# S3URISigner implements AWS SigV4 for S3 Source to avoid a dependency on the aws-sdk-* gems
|
7
|
+
# More on AWS SigV4: https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-authenticating-requests.html
|
8
|
+
class Gem::S3URISigner
|
9
|
+
|
10
|
+
class ConfigurationError < Gem::Exception
|
11
|
+
|
12
|
+
def initialize(message)
|
13
|
+
super message
|
14
|
+
end
|
15
|
+
|
16
|
+
def to_s # :nodoc:
|
17
|
+
"#{super}"
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
class InstanceProfileError < Gem::Exception
|
23
|
+
|
24
|
+
def initialize(message)
|
25
|
+
super message
|
26
|
+
end
|
27
|
+
|
28
|
+
def to_s # :nodoc:
|
29
|
+
"#{super}"
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
attr_accessor :uri
|
35
|
+
|
36
|
+
def initialize(uri)
|
37
|
+
@uri = uri
|
38
|
+
end
|
39
|
+
|
40
|
+
##
|
41
|
+
# Signs S3 URI using query-params according to the reference: https://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-query-string-auth.html
|
42
|
+
def sign(expiration = 86400)
|
43
|
+
s3_config = fetch_s3_config
|
44
|
+
|
45
|
+
current_time = Time.now.utc
|
46
|
+
date_time = current_time.strftime("%Y%m%dT%H%m%SZ")
|
47
|
+
date = date_time[0,8]
|
48
|
+
|
49
|
+
credential_info = "#{date}/#{s3_config.region}/s3/aws4_request"
|
50
|
+
canonical_host = "#{uri.host}.s3.#{s3_config.region}.amazonaws.com"
|
51
|
+
|
52
|
+
query_params = generate_canonical_query_params(s3_config, date_time, credential_info, expiration)
|
53
|
+
canonical_request = generate_canonical_request(canonical_host, query_params)
|
54
|
+
string_to_sign = generate_string_to_sign(date_time, credential_info, canonical_request)
|
55
|
+
signature = generate_signature(s3_config, date, string_to_sign)
|
56
|
+
|
57
|
+
URI.parse("https://#{canonical_host}#{uri.path}?#{query_params}&X-Amz-Signature=#{signature}")
|
58
|
+
end
|
59
|
+
|
60
|
+
private
|
61
|
+
|
62
|
+
S3Config = Struct.new :access_key_id, :secret_access_key, :security_token, :region
|
63
|
+
|
64
|
+
def generate_canonical_query_params(s3_config, date_time, credential_info, expiration)
|
65
|
+
canonical_params = {}
|
66
|
+
canonical_params["X-Amz-Algorithm"] = "AWS4-HMAC-SHA256"
|
67
|
+
canonical_params["X-Amz-Credential"] = "#{s3_config.access_key_id}/#{credential_info}"
|
68
|
+
canonical_params["X-Amz-Date"] = date_time
|
69
|
+
canonical_params["X-Amz-Expires"] = expiration.to_s
|
70
|
+
canonical_params["X-Amz-SignedHeaders"] = "host"
|
71
|
+
canonical_params["X-Amz-Security-Token"] = s3_config.security_token if s3_config.security_token
|
72
|
+
|
73
|
+
# Sorting is required to generate proper signature
|
74
|
+
canonical_params.sort.to_h.map do |key, value|
|
75
|
+
"#{base64_uri_escape(key)}=#{base64_uri_escape(value)}"
|
76
|
+
end.join("&")
|
77
|
+
end
|
78
|
+
|
79
|
+
def generate_canonical_request(canonical_host, query_params)
|
80
|
+
[
|
81
|
+
"GET",
|
82
|
+
uri.path,
|
83
|
+
query_params,
|
84
|
+
"host:#{canonical_host}",
|
85
|
+
"", # empty params
|
86
|
+
"host",
|
87
|
+
"UNSIGNED-PAYLOAD",
|
88
|
+
].join("\n")
|
89
|
+
end
|
90
|
+
|
91
|
+
def generate_string_to_sign(date_time, credential_info, canonical_request)
|
92
|
+
[
|
93
|
+
"AWS4-HMAC-SHA256",
|
94
|
+
date_time,
|
95
|
+
credential_info,
|
96
|
+
Digest::SHA256.hexdigest(canonical_request)
|
97
|
+
].join("\n")
|
98
|
+
end
|
99
|
+
|
100
|
+
def generate_signature(s3_config, date, string_to_sign)
|
101
|
+
date_key = OpenSSL::HMAC.digest("sha256", "AWS4" + s3_config.secret_access_key, date)
|
102
|
+
date_region_key = OpenSSL::HMAC.digest("sha256", date_key, s3_config.region)
|
103
|
+
date_region_service_key = OpenSSL::HMAC.digest("sha256", date_region_key, "s3")
|
104
|
+
signing_key = OpenSSL::HMAC.digest("sha256", date_region_service_key, "aws4_request")
|
105
|
+
OpenSSL::HMAC.hexdigest("sha256", signing_key, string_to_sign)
|
106
|
+
end
|
107
|
+
|
108
|
+
##
|
109
|
+
# Extracts S3 configuration for S3 bucket
|
110
|
+
def fetch_s3_config
|
111
|
+
return S3Config.new(uri.user, uri.password, nil, "us-east-1") if uri.user && uri.password
|
112
|
+
|
113
|
+
s3_source = Gem.configuration[:s3_source] || Gem.configuration["s3_source"]
|
114
|
+
host = uri.host
|
115
|
+
raise ConfigurationError.new("no s3_source key exists in .gemrc") unless s3_source
|
116
|
+
|
117
|
+
auth = s3_source[host] || s3_source[host.to_sym]
|
118
|
+
raise ConfigurationError.new("no key for host #{host} in s3_source in .gemrc") unless auth
|
119
|
+
|
120
|
+
provider = auth[:provider] || auth["provider"]
|
121
|
+
case provider
|
122
|
+
when "env"
|
123
|
+
id = ENV["AWS_ACCESS_KEY_ID"]
|
124
|
+
secret = ENV["AWS_SECRET_ACCESS_KEY"]
|
125
|
+
security_token = ENV["AWS_SESSION_TOKEN"]
|
126
|
+
when "instance_profile"
|
127
|
+
credentials = ec2_metadata_credentials_json
|
128
|
+
id = credentials["AccessKeyId"]
|
129
|
+
secret = credentials["SecretAccessKey"]
|
130
|
+
security_token = credentials["Token"]
|
131
|
+
else
|
132
|
+
id = auth[:id] || auth["id"]
|
133
|
+
secret = auth[:secret] || auth["secret"]
|
134
|
+
security_token = auth[:security_token] || auth["security_token"]
|
135
|
+
end
|
136
|
+
|
137
|
+
raise ConfigurationError.new("s3_source for #{host} missing id or secret") unless id && secret
|
138
|
+
|
139
|
+
region = auth[:region] || auth["region"] || "us-east-1"
|
140
|
+
S3Config.new(id, secret, security_token, region)
|
141
|
+
end
|
142
|
+
|
143
|
+
def base64_uri_escape(str)
|
144
|
+
str.gsub(/[\+\/=\n]/, BASE64_URI_TRANSLATE)
|
145
|
+
end
|
146
|
+
|
147
|
+
def ec2_metadata_credentials_json
|
148
|
+
require 'net/http'
|
149
|
+
require 'rubygems/request'
|
150
|
+
require 'rubygems/request/connection_pools'
|
151
|
+
require 'json'
|
152
|
+
|
153
|
+
iam_info = ec2_metadata_request(EC2_IAM_INFO)
|
154
|
+
# Expected format: arn:aws:iam::<id>:instance-profile/<role_name>
|
155
|
+
role_name = iam_info['InstanceProfileArn'].split('/').last
|
156
|
+
ec2_metadata_request(EC2_IAM_SECURITY_CREDENTIALS + role_name)
|
157
|
+
end
|
158
|
+
|
159
|
+
def ec2_metadata_request(url)
|
160
|
+
uri = URI(url)
|
161
|
+
@request_pool ||= create_request_pool(uri)
|
162
|
+
request = Gem::Request.new(uri, Net::HTTP::Get, nil, @request_pool)
|
163
|
+
response = request.fetch
|
164
|
+
|
165
|
+
case response
|
166
|
+
when Net::HTTPOK then
|
167
|
+
JSON.parse(response.body)
|
168
|
+
else
|
169
|
+
raise InstanceProfileError.new("Unable to fetch AWS metadata from #{uri}: #{response.message} #{response.code}")
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
def create_request_pool(uri)
|
174
|
+
proxy_uri = Gem::Request.proxy_uri(Gem::Request.get_proxy_from_env(uri.scheme))
|
175
|
+
certs = Gem::Request.get_cert_files
|
176
|
+
Gem::Request::ConnectionPools.new(proxy_uri, certs).pool_for(uri)
|
177
|
+
end
|
178
|
+
|
179
|
+
BASE64_URI_TRANSLATE = { "+" => "%2B", "/" => "%2F", "=" => "%3D", "\n" => "" }.freeze
|
180
|
+
EC2_IAM_INFO = "http://169.254.169.254/latest/meta-data/iam/info".freeze
|
181
|
+
EC2_IAM_SECURITY_CREDENTIALS = "http://169.254.169.254/latest/meta-data/iam/security-credentials/".freeze
|
182
|
+
|
183
|
+
end
|
@@ -18,7 +18,7 @@ require 'rubygems/util/list'
|
|
18
18
|
require 'stringio'
|
19
19
|
|
20
20
|
##
|
21
|
-
# The Specification class contains the information for a
|
21
|
+
# The Specification class contains the information for a gem. Typically
|
22
22
|
# defined in a .gemspec file or a Rakefile, and looks like this:
|
23
23
|
#
|
24
24
|
# Gem::Specification.new do |s|
|
@@ -364,8 +364,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
364
364
|
|
365
365
|
##
|
366
366
|
# The metadata holds extra data for this gem that may be useful to other
|
367
|
-
# consumers and is settable by gem authors
|
368
|
-
# the rubygems software.
|
367
|
+
# consumers and is settable by gem authors.
|
369
368
|
#
|
370
369
|
# Metadata items have the following restrictions:
|
371
370
|
#
|
@@ -656,8 +655,8 @@ class Gem::Specification < Gem::BasicSpecification
|
|
656
655
|
# # This gem will work with 1.8.6 or greater...
|
657
656
|
# spec.required_ruby_version = '>= 1.8.6'
|
658
657
|
#
|
659
|
-
# # Only with
|
660
|
-
# spec.required_ruby_version = '~> 2.
|
658
|
+
# # Only with final releases of major version 2 where minor version is at least 3
|
659
|
+
# spec.required_ruby_version = '~> 2.3'
|
661
660
|
#
|
662
661
|
# # Only prereleases or final releases after 2.6.0.preview2
|
663
662
|
# spec.required_ruby_version = '> 2.6.0.preview2'
|
@@ -745,9 +744,6 @@ class Gem::Specification < Gem::BasicSpecification
|
|
745
744
|
def self._all # :nodoc:
|
746
745
|
unless defined?(@@all) && @@all
|
747
746
|
@@all = stubs.map(&:to_spec)
|
748
|
-
if @@all.any?(&:nil?) # TODO: remove once we're happy
|
749
|
-
raise "pid: #{$$} nil spec! included in #{stubs.inspect}"
|
750
|
-
end
|
751
747
|
|
752
748
|
# After a reset, make sure already loaded specs
|
753
749
|
# are still marked as activated.
|
@@ -940,7 +936,6 @@ class Gem::Specification < Gem::BasicSpecification
|
|
940
936
|
# -- wilsonb
|
941
937
|
|
942
938
|
def self.all=(specs)
|
943
|
-
raise "nil spec!" if specs.any?(&:nil?) # TODO: remove once we're happy
|
944
939
|
@@stubs_by_name = specs.group_by(&:name)
|
945
940
|
@@all = @@stubs = specs
|
946
941
|
end
|
@@ -1311,6 +1306,8 @@ class Gem::Specification < Gem::BasicSpecification
|
|
1311
1306
|
# Load custom marshal format, re-initializing defaults as needed
|
1312
1307
|
|
1313
1308
|
def self._load(str)
|
1309
|
+
Gem.load_yaml
|
1310
|
+
|
1314
1311
|
array = Marshal.load str
|
1315
1312
|
|
1316
1313
|
spec = Gem::Specification.new
|
@@ -2287,7 +2284,6 @@ class Gem::Specification < Gem::BasicSpecification
|
|
2287
2284
|
|
2288
2285
|
e = Gem::LoadError.new msg
|
2289
2286
|
e.name = self.name
|
2290
|
-
# TODO: e.requirement = dep.requirement
|
2291
2287
|
|
2292
2288
|
raise e
|
2293
2289
|
end
|
@@ -2352,18 +2348,18 @@ class Gem::Specification < Gem::BasicSpecification
|
|
2352
2348
|
|
2353
2349
|
def ruby_code(obj)
|
2354
2350
|
case obj
|
2355
|
-
when String
|
2356
|
-
when Array
|
2357
|
-
when Hash
|
2351
|
+
when String then obj.dump + ".freeze"
|
2352
|
+
when Array then '[' + obj.map { |x| ruby_code x }.join(", ") + ']'
|
2353
|
+
when Hash then
|
2358
2354
|
seg = obj.keys.sort.map { |k| "#{k.to_s.dump} => #{obj[k].to_s.dump}" }
|
2359
2355
|
"{ #{seg.join(', ')} }"
|
2360
|
-
when Gem::Version
|
2361
|
-
when DateLike
|
2362
|
-
when Time
|
2363
|
-
when Numeric
|
2364
|
-
when true, false, nil
|
2365
|
-
when Gem::Platform
|
2366
|
-
when Gem::Requirement
|
2356
|
+
when Gem::Version then obj.to_s.dump
|
2357
|
+
when DateLike then obj.strftime('%Y-%m-%d').dump
|
2358
|
+
when Time then obj.strftime('%Y-%m-%d').dump
|
2359
|
+
when Numeric then obj.inspect
|
2360
|
+
when true, false, nil then obj.inspect
|
2361
|
+
when Gem::Platform then "Gem::Platform.new(#{obj.to_a.inspect})"
|
2362
|
+
when Gem::Requirement then
|
2367
2363
|
list = obj.as_list
|
2368
2364
|
"Gem::Requirement.new(#{ruby_code(list.size == 1 ? obj.to_s : list)})"
|
2369
2365
|
else raise Gem::Exception, "ruby_code case not handled: #{obj.class}"
|
@@ -2482,6 +2478,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
2482
2478
|
# still have their default values are omitted.
|
2483
2479
|
|
2484
2480
|
def to_ruby
|
2481
|
+
require 'openssl'
|
2485
2482
|
mark_version
|
2486
2483
|
result = []
|
2487
2484
|
result << "# -*- encoding: utf-8 -*-"
|
@@ -2520,9 +2517,8 @@ class Gem::Specification < Gem::BasicSpecification
|
|
2520
2517
|
@@attributes.each do |attr_name|
|
2521
2518
|
next if handled.include? attr_name
|
2522
2519
|
current_value = self.send(attr_name)
|
2523
|
-
if current_value != default_value(attr_name)
|
2524
|
-
|
2525
|
-
result << " s.#{attr_name} = #{ruby_code current_value}"
|
2520
|
+
if current_value != default_value(attr_name) || self.class.required_attribute?(attr_name)
|
2521
|
+
result << " s.#{attr_name} = #{ruby_code current_value}" unless current_value.is_a?(OpenSSL::PKey::RSA)
|
2526
2522
|
end
|
2527
2523
|
end
|
2528
2524
|
|
@@ -2590,6 +2586,8 @@ class Gem::Specification < Gem::BasicSpecification
|
|
2590
2586
|
end
|
2591
2587
|
|
2592
2588
|
def to_yaml(opts = {}) # :nodoc:
|
2589
|
+
Gem.load_yaml
|
2590
|
+
|
2593
2591
|
# Because the user can switch the YAML engine behind our
|
2594
2592
|
# back, we have to check again here to make sure that our
|
2595
2593
|
# psych code was properly loaded, and load it if not.
|
File without changes
|
@@ -0,0 +1,21 @@
|
|
1
|
+
-----BEGIN CERTIFICATE-----
|
2
|
+
MIIDXzCCAkegAwIBAgILBAAAAAABIVhTCKIwDQYJKoZIhvcNAQELBQAwTDEgMB4G
|
3
|
+
A1UECxMXR2xvYmFsU2lnbiBSb290IENBIC0gUjMxEzARBgNVBAoTCkdsb2JhbFNp
|
4
|
+
Z24xEzARBgNVBAMTCkdsb2JhbFNpZ24wHhcNMDkwMzE4MTAwMDAwWhcNMjkwMzE4
|
5
|
+
MTAwMDAwWjBMMSAwHgYDVQQLExdHbG9iYWxTaWduIFJvb3QgQ0EgLSBSMzETMBEG
|
6
|
+
A1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2lnbjCCASIwDQYJKoZI
|
7
|
+
hvcNAQEBBQADggEPADCCAQoCggEBAMwldpB5BngiFvXAg7aEyiie/QV2EcWtiHL8
|
8
|
+
RgJDx7KKnQRfJMsuS+FggkbhUqsMgUdwbN1k0ev1LKMPgj0MK66X17YUhhB5uzsT
|
9
|
+
gHeMCOFJ0mpiLx9e+pZo34knlTifBtc+ycsmWQ1z3rDI6SYOgxXG71uL0gRgykmm
|
10
|
+
KPZpO/bLyCiR5Z2KYVc3rHQU3HTgOu5yLy6c+9C7v/U9AOEGM+iCK65TpjoWc4zd
|
11
|
+
QQ4gOsC0p6Hpsk+QLjJg6VfLuQSSaGjlOCZgdbKfd/+RFO+uIEn8rUAVSNECMWEZ
|
12
|
+
XriX7613t2Saer9fwRPvm2L7DWzgVGkWqQPabumDk3F2xmmFghcCAwEAAaNCMEAw
|
13
|
+
DgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFI/wS3+o
|
14
|
+
LkUkrk1Q+mOai97i3Ru8MA0GCSqGSIb3DQEBCwUAA4IBAQBLQNvAUKr+yAzv95ZU
|
15
|
+
RUm7lgAJQayzE4aGKAczymvmdLm6AC2upArT9fHxD4q/c2dKg8dEe3jgr25sbwMp
|
16
|
+
jjM5RcOO5LlXbKr8EpbsU8Yt5CRsuZRj+9xTaGdWPoO4zzUhw8lo/s7awlOqzJCK
|
17
|
+
6fBdRoyV3XpYKBovHd7NADdBj+1EbddTKJd+82cEHhXXipa0095MJ6RMG3NzdvQX
|
18
|
+
mcIfeg7jLQitChws/zyrVQ4PkX4268NXSb7hLi18YIvDQVETI53O9zJrlAGomecs
|
19
|
+
Mx86OyXShkDOOyyGeMlhLxS67ttVb9+E7gUJTb0o2HLO02JQZR7rkpeDMdmztcpH
|
20
|
+
WD9f
|
21
|
+
-----END CERTIFICATE-----
|
@@ -110,8 +110,7 @@ class Gem::StubSpecification < Gem::BasicSpecification
|
|
110
110
|
begin
|
111
111
|
saved_lineno = $.
|
112
112
|
|
113
|
-
|
114
|
-
open loaded_from, OPEN_MODE do |file|
|
113
|
+
File.open loaded_from, OPEN_MODE do |file|
|
115
114
|
begin
|
116
115
|
file.readline # discard encoding line
|
117
116
|
stubline = file.readline.chomp
|
data/lib/rubygems/test_case.rb
CHANGED
@@ -115,6 +115,8 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
|
|
115
115
|
|
116
116
|
attr_accessor :uri # :nodoc:
|
117
117
|
|
118
|
+
TEST_PATH = ENV.fetch('RUBYGEMS_TEST_PATH', File.expand_path('../../../test/rubygems', __FILE__))
|
119
|
+
|
118
120
|
def assert_activate(expected, *specs)
|
119
121
|
specs.each do |spec|
|
120
122
|
case spec
|
@@ -138,6 +140,12 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
|
|
138
140
|
assert File.exist?(path), msg
|
139
141
|
end
|
140
142
|
|
143
|
+
def assert_directory_exists(path, msg = nil)
|
144
|
+
msg = message(msg) { "Expected path '#{path}' to be a directory" }
|
145
|
+
assert_path_exists path
|
146
|
+
assert File.directory?(path), msg
|
147
|
+
end
|
148
|
+
|
141
149
|
##
|
142
150
|
# Sets the ENABLE_SHARED entry in RbConfig::CONFIG to +value+ and restores
|
143
151
|
# the original value when the block ends
|
@@ -254,6 +262,7 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
|
|
254
262
|
@orig_gem_env_requirements = ENV.to_hash
|
255
263
|
|
256
264
|
ENV['GEM_VENDOR'] = nil
|
265
|
+
ENV['GEMRC'] = nil
|
257
266
|
ENV['SOURCE_DATE_EPOCH'] = nil
|
258
267
|
|
259
268
|
@current_dir = Dir.pwd
|
@@ -744,13 +753,18 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
|
|
744
753
|
# Removes all installed gems from +@gemhome+.
|
745
754
|
|
746
755
|
def util_clear_gems
|
747
|
-
FileUtils.rm_rf File.join(@gemhome, "gems")
|
756
|
+
FileUtils.rm_rf File.join(@gemhome, "gems")
|
748
757
|
FileUtils.mkdir File.join(@gemhome, "gems")
|
749
758
|
FileUtils.rm_rf File.join(@gemhome, "specifications")
|
750
759
|
FileUtils.mkdir File.join(@gemhome, "specifications")
|
751
760
|
Gem::Specification.reset
|
752
761
|
end
|
753
762
|
|
763
|
+
def util_clear_default_gems
|
764
|
+
FileUtils.rm_rf @default_spec_dir
|
765
|
+
FileUtils.mkdir @default_spec_dir
|
766
|
+
end
|
767
|
+
|
754
768
|
##
|
755
769
|
# Install the provided specs
|
756
770
|
|
@@ -924,9 +938,6 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
|
|
924
938
|
# location are returned.
|
925
939
|
|
926
940
|
def util_gem(name, version, deps = nil, &block)
|
927
|
-
# TODO: deprecate
|
928
|
-
raise "deps or block, not both" if deps and block
|
929
|
-
|
930
941
|
if deps
|
931
942
|
block = proc do |s|
|
932
943
|
# Since Hash#each is unordered in 1.8, sort
|
@@ -1057,6 +1068,8 @@ Also, a list:
|
|
1057
1068
|
Gem.instance_variable_set :@platforms, nil
|
1058
1069
|
Gem::Platform.instance_variable_set :@local, nil
|
1059
1070
|
|
1071
|
+
yield if block_given?
|
1072
|
+
|
1060
1073
|
platform
|
1061
1074
|
end
|
1062
1075
|
|
@@ -1353,9 +1366,8 @@ Also, a list:
|
|
1353
1366
|
end
|
1354
1367
|
|
1355
1368
|
@@ruby = rubybin
|
1356
|
-
|
1357
|
-
@@
|
1358
|
-
@@bad_rake = "#{rubybin} #{escape_path(gempath, 'bad_rake.rb')}"
|
1369
|
+
@@good_rake = "#{rubybin} #{escape_path(TEST_PATH, 'good_rake.rb')}"
|
1370
|
+
@@bad_rake = "#{rubybin} #{escape_path(TEST_PATH, 'bad_rake.rb')}"
|
1359
1371
|
|
1360
1372
|
##
|
1361
1373
|
# Construct a new Gem::Dependency.
|
@@ -1543,14 +1555,12 @@ Also, a list:
|
|
1543
1555
|
|
1544
1556
|
def self.cert_path(cert_name)
|
1545
1557
|
if 32 == (Time.at(2**32) rescue 32)
|
1546
|
-
cert_file =
|
1547
|
-
File.expand_path "../../../test/rubygems/#{cert_name}_cert_32.pem",
|
1548
|
-
__FILE__
|
1558
|
+
cert_file = "#{TEST_PATH}/#{cert_name}_cert_32.pem"
|
1549
1559
|
|
1550
1560
|
return cert_file if File.exist? cert_file
|
1551
1561
|
end
|
1552
1562
|
|
1553
|
-
|
1563
|
+
"#{TEST_PATH}/#{cert_name}_cert.pem"
|
1554
1564
|
end
|
1555
1565
|
|
1556
1566
|
##
|
@@ -1568,7 +1578,7 @@ Also, a list:
|
|
1568
1578
|
# Returns the path to the key named +key_name+ from <tt>test/rubygems</tt>
|
1569
1579
|
|
1570
1580
|
def self.key_path(key_name)
|
1571
|
-
|
1581
|
+
"#{TEST_PATH}/#{key_name}_key.pem"
|
1572
1582
|
end
|
1573
1583
|
|
1574
1584
|
# :stopdoc:
|