rubygems-update 3.0.0 → 3.0.9

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.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -0
  3. data/.travis.yml +2 -0
  4. data/CODE_OF_CONDUCT.md +10 -8
  5. data/CONTRIBUTING.md +7 -0
  6. data/History.txt +180 -0
  7. data/Manifest.txt +5 -3
  8. data/README.md +6 -0
  9. data/Rakefile +33 -7
  10. data/bundler/CHANGELOG.md +11 -0
  11. data/bundler/lib/bundler/build_metadata.rb +2 -2
  12. data/bundler/lib/bundler/rubygems_gem_installer.rb +7 -0
  13. data/bundler/lib/bundler/source/metadata.rb +2 -3
  14. data/bundler/lib/bundler/version.rb +1 -1
  15. data/bundler/man/bundle.ronn +3 -0
  16. data/lib/rubygems/command_manager.rb +12 -4
  17. data/lib/rubygems/commands/build_command.rb +28 -13
  18. data/lib/rubygems/commands/owner_command.rb +6 -1
  19. data/lib/rubygems/commands/push_command.rb +2 -0
  20. data/lib/rubygems/commands/setup_command.rb +14 -16
  21. data/lib/rubygems/commands/uninstall_command.rb +16 -6
  22. data/lib/rubygems/commands/which_command.rb +1 -3
  23. data/lib/rubygems/defaults.rb +1 -8
  24. data/lib/rubygems/dependency.rb +1 -1
  25. data/lib/rubygems/dependency_installer.rb +1 -2
  26. data/lib/rubygems/dependency_list.rb +1 -1
  27. data/lib/rubygems/exceptions.rb +0 -4
  28. data/lib/rubygems/gemcutter_utilities.rb +14 -7
  29. data/lib/rubygems/install_update_options.rb +1 -1
  30. data/lib/rubygems/installer.rb +37 -15
  31. data/lib/rubygems/installer_test_case.rb +2 -2
  32. data/lib/rubygems/package/old.rb +1 -1
  33. data/lib/rubygems/package/tar_header.rb +11 -2
  34. data/lib/rubygems/package.rb +12 -2
  35. data/lib/rubygems/rdoc.rb +2 -2
  36. data/lib/rubygems/remote_fetcher.rb +15 -54
  37. data/lib/rubygems/request.rb +1 -1
  38. data/lib/rubygems/request_set/gem_dependency_api.rb +11 -10
  39. data/lib/rubygems/requirement.rb +16 -5
  40. data/lib/rubygems/resolver.rb +4 -1
  41. data/lib/rubygems/s3_uri_signer.rb +183 -0
  42. data/lib/rubygems/security_option.rb +0 -1
  43. data/lib/rubygems/specification.rb +21 -23
  44. data/lib/rubygems/ssl_certs/rubygems.org/GlobalSignRootCA_R3.pem +21 -0
  45. data/lib/rubygems/stub_specification.rb +1 -2
  46. data/lib/rubygems/test_case.rb +23 -12
  47. data/lib/rubygems/uninstaller.rb +1 -1
  48. data/lib/rubygems/user_interaction.rb +4 -1
  49. data/lib/rubygems/util.rb +13 -1
  50. data/lib/rubygems.rb +8 -13
  51. data/rubygems-update.gemspec +1 -1
  52. data/test/rubygems/ca_cert.pem +74 -65
  53. data/test/rubygems/client.pem +103 -45
  54. data/test/rubygems/ssl_cert.pem +78 -17
  55. data/test/rubygems/ssl_key.pem +25 -13
  56. data/test/rubygems/test_bundled_ca.rb +8 -5
  57. data/test/rubygems/test_gem.rb +55 -13
  58. data/test/rubygems/test_gem_bundler_version_finder.rb +4 -0
  59. data/test/rubygems/test_gem_command_manager.rb +10 -0
  60. data/test/rubygems/test_gem_commands_build_command.rb +1 -0
  61. data/test/rubygems/test_gem_commands_push_command.rb +15 -0
  62. data/test/rubygems/test_gem_commands_setup_command.rb +11 -7
  63. data/test/rubygems/test_gem_commands_uninstall_command.rb +80 -1
  64. data/test/rubygems/test_gem_ext_cmake_builder.rb +1 -1
  65. data/test/rubygems/test_gem_indexer.rb +15 -8
  66. data/test/rubygems/test_gem_installer.rb +191 -22
  67. data/test/rubygems/test_gem_package.rb +37 -0
  68. data/test/rubygems/test_gem_package_tar_header.rb +41 -0
  69. data/test/rubygems/test_gem_package_tar_writer.rb +3 -0
  70. data/test/rubygems/test_gem_rdoc.rb +1 -135
  71. data/test/rubygems/test_gem_remote_fetcher.rb +133 -14
  72. data/test/rubygems/test_gem_request.rb +4 -4
  73. data/test/rubygems/test_gem_request_set_gem_dependency_api.rb +80 -57
  74. data/test/rubygems/test_gem_requirement.rb +6 -0
  75. data/test/rubygems/test_gem_security_policy.rb +1 -1
  76. data/test/rubygems/test_gem_specification.rb +32 -0
  77. data/test/rubygems/test_gem_stream_ui.rb +2 -2
  78. data/test/rubygems/test_gem_text.rb +5 -0
  79. data/test/rubygems/test_gem_uninstaller.rb +21 -2
  80. data/test/rubygems/test_gem_util.rb +25 -0
  81. data/util/ci +6 -1
  82. data/util/cops/deprecations.rb +52 -0
  83. data/util/create_certs.sh +27 -0
  84. data/util/create_encrypted_key.rb +4 -4
  85. data/util/update_bundled_ca_certificates.rb +1 -3
  86. metadata +12 -10
  87. data/lib/rubygems/ssl_certs/rubygems.global.ssl.fastly.net/DigiCertHighAssuranceEVRootCA.pem +0 -23
  88. data/lib/rubygems/ssl_certs/rubygems.org/AddTrustExternalCARoot.pem +0 -25
  89. /data/lib/rubygems/ssl_certs/{index.rubygems.org → rubygems.org}/GlobalSignRootCA.pem +0 -0
@@ -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
- :ruby => %w[ruby rbx maglev],
47
- :ruby_18 => %w[ruby rbx maglev],
48
- :ruby_19 => %w[ruby rbx maglev],
49
- :ruby_20 => %w[ruby rbx maglev],
50
- :ruby_21 => %w[ruby rbx maglev],
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
- # engine_specific VERSION constants. (For JRuby, JRUBY_VERSION).
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
- my_engine_version = Object.const_get "#{Gem.ruby_engine.upcase}_VERSION"
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} #{my_engine_version}, " +
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
@@ -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.
@@ -267,7 +263,22 @@ class Gem::Requirement
267
263
 
268
264
  def ==(other) # :nodoc:
269
265
  return unless Gem::Requirement === other
270
- requirements == other.requirements
266
+
267
+ # An == check is always necessary
268
+ return false unless requirements == other.requirements
269
+
270
+ # An == check is sufficient unless any requirements use ~>
271
+ return true unless _tilde_requirements.any?
272
+
273
+ # If any requirements use ~> we use the stricter `#eql?` that also checks
274
+ # that version precision is the same
275
+ _tilde_requirements.eql?(other._tilde_requirements)
276
+ end
277
+
278
+ protected
279
+
280
+ def _tilde_requirements
281
+ requirements.select { |r| r.first == "~>" }
271
282
  end
272
283
 
273
284
  private
@@ -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
- PP.pp data, $stderr unless data.empty?
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
@@ -19,7 +19,6 @@ end
19
19
 
20
20
  module Gem::SecurityOption
21
21
  def add_security_option
22
- # TODO: use @parser.accept
23
22
  OptionParser.accept Gem::Security::Policy do |value|
24
23
  require 'rubygems/security'
25
24
 
@@ -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 Gem. Typically
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 without requiring an update to
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 ruby 2.0.x
660
- # spec.required_ruby_version = '~> 2.0'
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 then obj.dump + ".freeze"
2356
- when Array then '[' + obj.map { |x| ruby_code x }.join(", ") + ']'
2357
- when Hash then
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 then obj.to_s.dump
2361
- when DateLike then obj.strftime('%Y-%m-%d').dump
2362
- when Time then obj.strftime('%Y-%m-%d').dump
2363
- when Numeric then obj.inspect
2364
- when true, false, nil then obj.inspect
2365
- when Gem::Platform then "Gem::Platform.new(#{obj.to_a.inspect})"
2366
- when Gem::Requirement then
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) or
2524
- self.class.required_attribute? attr_name
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.
@@ -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
- # TODO It should be use `File.open`, but bundler-1.16.1 example expects Kernel#open.
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
@@ -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,8 @@ 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
266
+ ENV['SOURCE_DATE_EPOCH'] = nil
257
267
 
258
268
  @current_dir = Dir.pwd
259
269
  @fetcher = nil
@@ -743,13 +753,18 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
743
753
  # Removes all installed gems from +@gemhome+.
744
754
 
745
755
  def util_clear_gems
746
- FileUtils.rm_rf File.join(@gemhome, "gems") # TODO: use Gem::Dirs
756
+ FileUtils.rm_rf File.join(@gemhome, "gems")
747
757
  FileUtils.mkdir File.join(@gemhome, "gems")
748
758
  FileUtils.rm_rf File.join(@gemhome, "specifications")
749
759
  FileUtils.mkdir File.join(@gemhome, "specifications")
750
760
  Gem::Specification.reset
751
761
  end
752
762
 
763
+ def util_clear_default_gems
764
+ FileUtils.rm_rf @default_spec_dir
765
+ FileUtils.mkdir @default_spec_dir
766
+ end
767
+
753
768
  ##
754
769
  # Install the provided specs
755
770
 
@@ -923,9 +938,6 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
923
938
  # location are returned.
924
939
 
925
940
  def util_gem(name, version, deps = nil, &block)
926
- # TODO: deprecate
927
- raise "deps or block, not both" if deps and block
928
-
929
941
  if deps
930
942
  block = proc do |s|
931
943
  # Since Hash#each is unordered in 1.8, sort
@@ -1056,6 +1068,8 @@ Also, a list:
1056
1068
  Gem.instance_variable_set :@platforms, nil
1057
1069
  Gem::Platform.instance_variable_set :@local, nil
1058
1070
 
1071
+ yield if block_given?
1072
+
1059
1073
  platform
1060
1074
  end
1061
1075
 
@@ -1352,9 +1366,8 @@ Also, a list:
1352
1366
  end
1353
1367
 
1354
1368
  @@ruby = rubybin
1355
- gempath = File.expand_path('../../../test/rubygems', __FILE__)
1356
- @@good_rake = "#{rubybin} #{escape_path(gempath, 'good_rake.rb')}"
1357
- @@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')}"
1358
1371
 
1359
1372
  ##
1360
1373
  # Construct a new Gem::Dependency.
@@ -1542,14 +1555,12 @@ Also, a list:
1542
1555
 
1543
1556
  def self.cert_path(cert_name)
1544
1557
  if 32 == (Time.at(2**32) rescue 32)
1545
- cert_file =
1546
- File.expand_path "../../../test/rubygems/#{cert_name}_cert_32.pem",
1547
- __FILE__
1558
+ cert_file = "#{TEST_PATH}/#{cert_name}_cert_32.pem"
1548
1559
 
1549
1560
  return cert_file if File.exist? cert_file
1550
1561
  end
1551
1562
 
1552
- File.expand_path "../../../test/rubygems/#{cert_name}_cert.pem", __FILE__
1563
+ "#{TEST_PATH}/#{cert_name}_cert.pem"
1553
1564
  end
1554
1565
 
1555
1566
  ##
@@ -1567,7 +1578,7 @@ Also, a list:
1567
1578
  # Returns the path to the key named +key_name+ from <tt>test/rubygems</tt>
1568
1579
 
1569
1580
  def self.key_path(key_name)
1570
- File.expand_path "../../../test/rubygems/#{key_name}_key.pem", __FILE__
1581
+ "#{TEST_PATH}/#{key_name}_key.pem"
1571
1582
  end
1572
1583
 
1573
1584
  # :stopdoc:
@@ -46,7 +46,7 @@ class Gem::Uninstaller
46
46
  # TODO document the valid options
47
47
  @gem = gem
48
48
  @version = options[:version] || Gem::Requirement.default
49
- @gem_home = File.expand_path(options[:install_dir] || Gem.dir)
49
+ @gem_home = File.realpath(options[:install_dir] || Gem.dir)
50
50
  @force_executables = options[:executables]
51
51
  @force_all = options[:all]
52
52
  @force_ignore = options[:ignore]
@@ -7,6 +7,7 @@
7
7
 
8
8
  require 'rubygems/util'
9
9
  require 'rubygems/deprecate'
10
+ require 'rubygems/text'
10
11
 
11
12
  ##
12
13
  # Module that defines the default UserInteraction. Any class including this
@@ -14,6 +15,8 @@ require 'rubygems/deprecate'
14
15
 
15
16
  module Gem::DefaultUserInteraction
16
17
 
18
+ include Gem::Text
19
+
17
20
  ##
18
21
  # The default UI is a class variable of the singleton class for this
19
22
  # module.
@@ -162,7 +165,7 @@ module Gem::UserInteraction
162
165
  # is true.
163
166
 
164
167
  def verbose(msg = nil)
165
- say(msg || yield) if Gem.configuration.really_verbose
168
+ say(clean_text(msg || yield)) if Gem.configuration.really_verbose
166
169
  end
167
170
  end
168
171
 
data/lib/rubygems/util.rb CHANGED
@@ -122,10 +122,22 @@ module Gem::Util
122
122
 
123
123
  def self.glob_files_in_dir(glob, base_path)
124
124
  if RUBY_VERSION >= "2.5"
125
- Dir.glob(glob, base: base_path).map! {|f| File.join(base_path, f) }
125
+ Dir.glob(glob, base: base_path).map! {|f| File.expand_path(f, base_path) }
126
126
  else
127
127
  Dir.glob(File.expand_path(glob, base_path))
128
128
  end
129
129
  end
130
130
 
131
+ ##
132
+ # Corrects +path+ (usually returned by `URI.parse().path` on Windows), that
133
+ # comes with a leading slash.
134
+
135
+ def self.correct_for_windows_path(path)
136
+ if path[0].chr == '/' && path[1].chr =~ /[a-z]/i && path[2].chr == ':'
137
+ path[1..-1]
138
+ else
139
+ path
140
+ end
141
+ end
142
+
131
143
  end
data/lib/rubygems.rb CHANGED
@@ -9,7 +9,7 @@
9
9
  require 'rbconfig'
10
10
 
11
11
  module Gem
12
- VERSION = "3.0.0".freeze
12
+ VERSION = "3.0.9".freeze
13
13
  end
14
14
 
15
15
  # Must be first since it unloads the prelude from 1.9.2
@@ -18,6 +18,7 @@ require 'rubygems/compatibility'
18
18
  require 'rubygems/defaults'
19
19
  require 'rubygems/deprecate'
20
20
  require 'rubygems/errors'
21
+ require 'rubygems/path_support'
21
22
 
22
23
  ##
23
24
  # RubyGems is the Ruby standard for publishing and managing third party
@@ -567,12 +568,10 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
567
568
  #++
568
569
  #--
569
570
  #
570
- # FIXME move to pathsupport
571
- #
572
571
  #++
573
572
 
574
573
  def self.find_home
575
- Dir.home
574
+ Dir.home.dup
576
575
  rescue
577
576
  if Gem.win_platform?
578
577
  File.expand_path File.join(ENV['HOMEDRIVE'] || ENV['SystemDrive'], '/')
@@ -641,14 +640,12 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
641
640
  # <tt>https://rubygems.org</tt>.
642
641
 
643
642
  def self.host
644
- # TODO: move to utils
645
643
  @host ||= Gem::DEFAULT_HOST
646
644
  end
647
645
 
648
646
  ## Set the default RubyGems API host.
649
647
 
650
648
  def self.host=(host)
651
- # TODO: move to utils
652
649
  @host = host
653
650
  end
654
651
 
@@ -1376,14 +1373,12 @@ begin
1376
1373
  rescue LoadError
1377
1374
  end
1378
1375
 
1379
- if defined?(RUBY_ENGINE)
1380
- begin
1381
- ##
1382
- # Defaults the Ruby implementation wants to provide for RubyGems
1376
+ begin
1377
+ ##
1378
+ # Defaults the Ruby implementation wants to provide for RubyGems
1383
1379
 
1384
- require "rubygems/defaults/#{RUBY_ENGINE}"
1385
- rescue LoadError
1386
- end
1380
+ require "rubygems/defaults/#{RUBY_ENGINE}"
1381
+ rescue LoadError
1387
1382
  end
1388
1383
 
1389
1384
  ##