[前][次][番号順一覧][スレッド一覧]

ruby-changes:54126

From: hsbt <ko1@a...>
Date: Wed, 12 Dec 2018 14:07:57 +0900 (JST)
Subject: [ruby-changes:54126] hsbt:r66347 (trunk): Merge rubygems@21f12a8 from upstream.

hsbt	2018-12-12 14:07:50 +0900 (Wed, 12 Dec 2018)

  New Revision: 66347

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=66347

  Log:
    Merge rubygems@21f12a8 from upstream.
    
      * [BudlerVersionFinder] set .filter! and .compatible? to match only on major versions https://github.com/rubygems/rubygems/pull/2515
      * Fix broken symlink that points to ../* https://github.com/rubygems/rubygems/pull/2516

  Modified files:
    trunk/lib/rubygems/bundler_version_finder.rb
    trunk/lib/rubygems/commands/build_command.rb
    trunk/lib/rubygems/package.rb
    trunk/lib/rubygems/request.rb
    trunk/lib/rubygems/specification.rb
    trunk/lib/rubygems/specification_policy.rb
    trunk/test/rubygems/test_bundled_ca.rb
    trunk/test/rubygems/test_gem_bundler_version_finder.rb
    trunk/test/rubygems/test_gem_commands_build_command.rb
    trunk/test/rubygems/test_gem_package.rb
    trunk/test/rubygems/test_gem_remote_fetcher.rb
    trunk/test/rubygems/test_gem_specification.rb
Index: lib/rubygems/specification.rb
===================================================================
--- lib/rubygems/specification.rb	(revision 66346)
+++ lib/rubygems/specification.rb	(revision 66347)
@@ -156,7 +156,6 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L156
     :required_ruby_version     => Gem::Requirement.default,
     :required_rubygems_version => Gem::Requirement.default,
     :requirements              => [],
-    :rubyforge_project         => nil,
     :rubygems_version          => Gem::VERSION,
     :signing_key               => nil,
     :specification_version     => CURRENT_SPECIFICATION_VERSION,
@@ -730,12 +729,11 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L729
   attr_writer :original_platform # :nodoc:
 
   ##
-  # The rubyforge project this gem lives under.  i.e. RubyGems'
-  # rubyforge_project is "rubygems".
+  # Deprecated and ignored.
   #
-  # This option is deprecated.
+  # Formerly used to set rubyforge project.
 
-  attr_accessor :rubyforge_project
+  attr_writer :rubyforge_project
 
   ##
   # The Gem::Specification version of this gemspec.
@@ -1347,7 +1345,7 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L1345
     spec.instance_variable_set :@required_rubygems_version, array[7]
     spec.instance_variable_set :@original_platform,         array[8]
     spec.instance_variable_set :@dependencies,              array[9]
-    spec.instance_variable_set :@rubyforge_project,         array[10]
+    # offset due to rubyforge_project removal
     spec.instance_variable_set :@email,                     array[11]
     spec.instance_variable_set :@authors,                   array[12]
     spec.instance_variable_set :@description,               array[13]
@@ -1392,7 +1390,7 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L1390
       @required_rubygems_version,
       @original_platform,
       @dependencies,
-      @rubyforge_project,
+      '', # rubyforge_project
       @email,
       @authors,
       @description,
Index: lib/rubygems/commands/build_command.rb
===================================================================
--- lib/rubygems/commands/build_command.rb	(revision 66346)
+++ lib/rubygems/commands/build_command.rb	(revision 66347)
@@ -14,6 +14,10 @@ class Gem::Commands::BuildCommand < Gem: https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/build_command.rb#L14
     add_option '--strict', 'consider warnings as errors when validating the spec' do |value, options|
       options[:strict] = true
     end
+
+    add_option '-o', '--output FILE', 'output gem with the given filename' do |value, options|
+      options[:output] = value
+    end
   end
 
   def arguments # :nodoc:
@@ -36,6 +40,11 @@ with gem spec: https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/build_command.rb#L40
   $ cd my_gem-1.0
   [edit gem contents]
   $ gem build my_gem-1.0.gemspec
+
+Gems can be saved to a specified filename with the output option:
+
+  $ gem build my_gem-1.0.gemspec --output=release.gem
+
     EOF
   end
 
@@ -58,7 +67,8 @@ with gem spec: https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/build_command.rb#L67
           Gem::Package.build(
             spec,
             options[:force],
-            options[:strict]
+            options[:strict],
+            options[:output]
           )
         else
           alert_error "Error loading gemspec. Aborting."
Index: lib/rubygems/request.rb
===================================================================
--- lib/rubygems/request.rb	(revision 66346)
+++ lib/rubygems/request.rb	(revision 66347)
@@ -45,7 +45,6 @@ class Gem::Request https://github.com/ruby/ruby/blob/trunk/lib/rubygems/request.rb#L45
   end
 
   def self.configure_connection_for_https(connection, cert_files)
-    require 'net/https'
     connection.use_ssl = true
     connection.verify_mode =
       Gem.configuration.ssl_verify_mode || OpenSSL::SSL::VERIFY_PEER
Index: lib/rubygems/bundler_version_finder.rb
===================================================================
--- lib/rubygems/bundler_version_finder.rb	(revision 66346)
+++ lib/rubygems/bundler_version_finder.rb	(revision 66347)
@@ -37,20 +37,14 @@ To install the missing version, run `gem https://github.com/ruby/ruby/blob/trunk/lib/rubygems/bundler_version_finder.rb#L37
   def self.compatible?(spec)
     return true unless spec.name == "bundler".freeze
     return true unless bundler_version = self.bundler_version
-    if bundler_version.segments.first >= 2
-      spec.version == bundler_version
-    else # 1.x
-      spec.version.segments.first < 2
-    end
+
+    spec.version.segments.first == bundler_version.segments.first
   end
 
   def self.filter!(specs)
     return unless bundler_version = self.bundler_version
-    if bundler_version.segments.first >= 2
-      specs.reject! { |spec| spec.version != bundler_version }
-    else # 1.x
-      specs.reject! { |spec| spec.version.segments.first >= 2}
-    end
+
+    specs.reject! { |spec| spec.version.segments.first != bundler_version.segments.first }
   end
 
   def self.bundle_update_bundler_version
Index: lib/rubygems/package.rb
===================================================================
--- lib/rubygems/package.rb	(revision 66346)
+++ lib/rubygems/package.rb	(revision 66347)
@@ -119,8 +119,8 @@ class Gem::Package https://github.com/ruby/ruby/blob/trunk/lib/rubygems/package.rb#L119
   # Permission for other files
   attr_accessor :data_mode
 
-  def self.build(spec, skip_validation = false, strict_validation = false)
-    gem_file = spec.file_name
+  def self.build(spec, skip_validation = false, strict_validation = false, file_name = nil)
+    gem_file = file_name || spec.file_name
 
     package = new gem_file
     package.spec = spec
@@ -223,8 +223,13 @@ class Gem::Package https://github.com/ruby/ruby/blob/trunk/lib/rubygems/package.rb#L223
       stat = File.lstat file
 
       if stat.symlink?
-        relative_dir = File.dirname(file).sub("#{Dir.pwd}/", '')
-        target_path = File.join(relative_dir, File.readlink(file))
+        target_path = File.readlink(file)
+
+        unless target_path.start_with? '.'
+          relative_dir = File.dirname(file).sub("#{Dir.pwd}/", '')
+          target_path = File.join(relative_dir, target_path)
+        end
+
         tar.add_symlink file, target_path, stat.mode
       end
 
@@ -281,7 +286,7 @@ class Gem::Package https://github.com/ruby/ruby/blob/trunk/lib/rubygems/package.rb#L286
   Successfully built RubyGem
   Name: #{@spec.name}
   Version: #{@spec.version}
-  File: #{File.basename @spec.cache_file}
+  File: #{File.basename @gem.path}
 EOM
   ensure
     @signer = nil
Index: lib/rubygems/specification_policy.rb
===================================================================
--- lib/rubygems/specification_policy.rb	(revision 66346)
+++ lib/rubygems/specification_policy.rb	(revision 66347)
@@ -150,19 +150,24 @@ duplicate dependency on #{dep}, (#{prev. https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification_policy.rb#L150
       if open_ended
         op, dep_version = dep.requirement.requirements.first
 
-        base = dep_version.segments.first 2
+        segments = dep_version.segments
 
-        bugfix = if op == '>'
-                   ", '> #{dep_version}'"
-                 elsif op == '>=' and base != dep_version.segments
-                   ", '>= #{dep_version}'"
-                 end
+        base = segments.first 2
 
-        warning_messages << <<-WARNING
-open-ended dependency on #{dep} is not recommended
-  if #{dep.name} is semantically versioned, use:
-    add_#{dep.type}_dependency '#{dep.name}', '~> #{base.join '.'}'#{bugfix}
-        WARNING
+        recommendation = if (op == '>' || op == '>=') && segments == [0]
+                           "  use a bounded requirement, such as '~> x.y'"
+                         else
+                           bugfix = if op == '>'
+                                      ", '> #{dep_version}'"
+                                    elsif op == '>=' and base != segments
+                                      ", '>= #{dep_version}'"
+                                    end
+
+                           "  if #{dep.name} is semantically versioned, use:\n" \
+                           "    add_#{dep.type}_dependency '#{dep.name}', '~> #{base.join '.'}'#{bugfix}"
+                         end
+
+        warning_messages << ["open-ended dependency on #{dep} is not recommended", recommendation].join("\n") + "\n"
       end
     end
     if error_messages.any?
Index: test/rubygems/test_gem_package.rb
===================================================================
--- test/rubygems/test_gem_package.rb	(revision 66346)
+++ test/rubygems/test_gem_package.rb	(revision 66347)
@@ -151,7 +151,7 @@ class TestGemPackage < Gem::Package::Tar https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_package.rb#L151
 
   def test_add_files_symlink
     spec = Gem::Specification.new
-    spec.files = %w[lib/code.rb lib/code_sym.rb]
+    spec.files = %w[lib/code.rb lib/code_sym.rb lib/code_sym2.rb]
 
     FileUtils.mkdir_p 'lib'
     File.open 'lib/code.rb',  'w' do |io| io.write '# lib/code.rb'  end
@@ -159,6 +159,7 @@ class TestGemPackage < Gem::Package::Tar https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_package.rb#L159
     # NOTE: 'code.rb' is correct, because it's relative to lib/code_sym.rb
     begin
       File.symlink('code.rb', 'lib/code_sym.rb')
+      File.symlink('../lib/code.rb', 'lib/code_sym2.rb')
     rescue Errno::EACCES => e
       if win_platform?
         skip "symlink - must be admin with no UAC on Windows"
@@ -189,7 +190,7 @@ class TestGemPackage < Gem::Package::Tar https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_package.rb#L190
     end
 
     assert_equal %w[lib/code.rb], files
-    assert_equal [{'lib/code_sym.rb' => 'lib/code.rb'}], symlinks
+    assert_equal [{'lib/code_sym.rb' => 'lib/code.rb'}, {'lib/code_sym2.rb' => '../lib/code.rb'}], symlinks
   end
 
   def test_build
Index: test/rubygems/test_gem_remote_fetcher.rb
===================================================================
--- test/rubygems/test_gem_remote_fetcher.rb	(revision 66346)
+++ test/rubygems/test_gem_remote_fetcher.rb	(revision 66347)
@@ -51,7 +51,6 @@ gems: https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_remote_fetcher.rb#L51
     author: Jim Weirich
     email: jim@w...
     homepage: http://rake.rubyforge.org
-    rubyforge_project: rake
     description: Rake is a Make-like program implemented in Ruby. Tasks and dependencies are specified in standard Ruby syntax.
     autorequire:
     default_executable: rake
Index: test/rubygems/test_gem_specification.rb
===================================================================
--- test/rubygems/test_gem_specification.rb	(revision 66346)
+++ test/rubygems/test_gem_specification.rb	(revision 66347)
@@ -48,7 +48,6 @@ end https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_specification.rb#L48
       s.extensions << 'ext/a/extconf.rb'
       s.test_file = 'test/suite.rb'
       s.requirements << 'A working computer'
-      s.rubyforge_project = 'example'
       s.license = 'MIT'
 
       s.add_dependency 'rake', '> 0.4'
@@ -80,7 +79,6 @@ end https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_specification.rb#L79
       s.executable = 'exec'
       s.test_file = 'test/suite.rb'
       s.requirements << 'A working computer'
-      s.rubyforge_project = 'example'
       s.license = 'MIT'
 
       s.mark_version
@@ -701,7 +699,6 @@ end https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_specification.rb#L699
       required_ruby_version
       required_rubygems_version
       requirements
-      rubyforge_project
       rubygems_version
       signing_key
       specification_version
@@ -871,7 +868,6 @@ require_paths: https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_specification.rb#L868
 author: Austin Ziegler
 email: diff-lcs@h...
 homepage: http://rubyforge.org/projects/ruwiki/
-rubyforge_project: ruwiki
 description: "Test"
 bindir: bin
 has_rdoc: true
@@ -1215,7 +1211,7 @@ dependencies: [] https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_specification.rb#L1211
 
     data = Marshal.load Gem::Util.inflate(Gem.read_binary(path))
 
-    assert_nil data.rubyforge_project
+    assert_nil data.signing_key
   end
 
   def test_initialize
@@ -2506,7 +2502,6 @@ Gem::Specification.new do |s| https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_specification.rb#L2502
   s.homepage = "http://example.com".freeze
   s.licenses = ["MIT".freeze]
   s.requirements = ["A working computer".freeze]
-  s.rubyforge_project = "example".freeze
   s.rubygems_version = "#{Gem::VERSION}".freeze
   s.summary = "this is a summary".freeze
   s.test_files = ["test/suite.rb".freeze]
@@ -2699,6 +2694,7 @@ end https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_specification.rb#L2694
       @a1.add_runtime_dependency     'l', '> 1.2.3'
       @a1.add_runtime_dependency     'm', '~> 2.1.0'
       @a1.add_runtime_dependency     'n', '~> 0.1.0'
+      @a1.add_runtime_dependency     'o'
 
       use_ui @ui do
         @a1.validate
@@ -2719,6 +2715,8 @@ end https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_specification.rb#L2715
 #{w}:  open-ended dependency on l (> 1.2.3) is not recommended
   if l is semantically versioned, use:
     add_runtime_dependency 'l', '~> 1.2', '> 1.2.3'
+#{w}:  open-ended dependency on o (>= 0) is not recommended
+  use a bounded requirement, such as '~> x.y'
 #{w}:  See http://guides.rubygems.org/specification-reference/ for help
       EXPECTED
 
Index: test/rubygems/test_gem_commands_build_command.rb
===================================================================
--- test/rubygems/test_gem_commands_build_command.rb	(revision 66346)
+++ test/rubygems/test_gem_commands_build_command.rb	(revision 66347)
@@ -22,7 +22,6 @@ class TestGemCommandsBuildCommand < Gem: https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_build_command.rb#L22
     end
 
     @gem = util_spec 'some_gem' do |s|
-      s.rubyforge_project = 'example'
       s.license = 'AGPL-3.0'
       s.files = ['README.md']
     end
@@ -37,11 +36,39 @@ class TestGemCommandsBuildCommand < Gem: https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_build_command.rb#L36
     assert @cmd.options[:strict]
   end
 
+  def test_options_filename
+    gemspec_file = File.join(@tempdir, @gem.spec_name)
+
+    File.open gemspec_file, 'w' do |gs|
+      gs.write @gem.to_ruby
+    end
+
+    @cmd.options[:args] = [gemspec_file]
+    @cmd.options[:output] = "test.gem"
+
+    use_ui @ui do
+      Dir.chdir @tempdir do
+        @cmd.execute
+      end
+    end
+
+    file = File.join(@tempdir, File::SEPARATOR, "test.gem")
+    assert File.exist?(file)
+
+    output = @ui.output.split "\n"
+    assert_equal "  Successfully built RubyGem", output.shift
+    assert_equal "  Name: some_gem", output.shift
+    assert_equal "  Version: 2", output.shift
+    assert_equal "  File: test.gem", output.shift
+    assert_equal [], output
+  end
+
   def test_handle_options_defaults
     @cmd.handle_options []
 
     refute @cmd.options[:force]
     refute @cmd.options[:strict]
+    assert_nil @cmd.options[:output]
   end
 
   def test_execute
@@ -97,7 +124,6 @@ class TestGemCommandsBuildCommand < Gem: https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_build_command.rb#L124
 
   def test_execute_strict_with_warnings
     bad_gem = util_spec 'some_bad_gem' do |s|
-      s.rubyforge_project = 'example'
       s.files = ['README.md']
     end
 
Index: test/rubygems/test_gem_bundler_version_finder.rb
===================================================================
--- test/rubygems/test_gem_bundler_version_finder.rb	(revision 66346)
+++ test/rubygems/test_gem_bundler_version_finder.rb	(revision 66347)
@@ -88,20 +88,21 @@ class TestGemBundlerVersionFinder < Gem: https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_bundler_version_finder.rb#L88
     bvf.stub(:bundler_version, v("2.1.1.1")) do
       assert bvf.compatible?(util_spec("foo"))
       assert bvf.compatible?(util_spec("bundler", "2.1.1.1"))
-      refute bvf.compatible?(util_spec("bundler", "2.1.1.a"))
+      assert bvf.compatible?(util_spec("bundler", "2.1.1.a"))
+      assert bvf.compatible?(util_spec("bundler", "2.999"))
       refute bvf.compatible?(util_spec("bundler", "1.999"))
-      refute bvf.compatible?(util_spec("bundler", "2.999"))
+      refute bvf.compatible?(util_spec("bundler", "3.0.0"))
     end
   end
 
   def test_filter
-    versions = %w[1 1.0 1.0.1.1 2.a 3 3.0]
+    versions = %w[1 1.0 1.0.1.1 2 2.a 2.0 2.1.1 3 3.a 3.0 3.1.1]
     specs = versions.map { |v| util_spec("bundler", v) }
 
-    assert_equal %w[1 1.0 1.0.1.1 2.a 3 3.0], util_filter_specs(specs).map(&:version).map(&:to_s)
+    assert_equal %w[1 1.0 1.0.1.1 2 2.a 2.0 2.1.1 3 3.a 3.0 3.1.1], util_filter_specs(specs).map(&:version).map(&:to_s)
 
     bvf.stub(:bundler_version, v("2.1.1.1")) do
-      assert_empty util_filter_specs(specs).map(&:version).map(&:to_s)
+      assert_equal %w[2 2.a 2.0 2.1.1], util_filter_specs(specs).map(&:version).map(&:to_s)
     end
     bvf.stub(:bundler_version, v("1.1.1.1")) do
       assert_equal %w[1 1.0 1.0.1.1], util_filter_specs(specs).map(&:version).map(&:to_s)
@@ -110,10 +111,10 @@ class TestGemBundlerVersionFinder < Gem: https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_bundler_version_finder.rb#L111
       assert_equal %w[1 1.0 1.0.1.1], util_filter_specs(specs).map(&:version).map(&:to_s)
     end
     bvf.stub(:bundler_version, v("2.a")) do
-      assert_equal %w[2.a], util_filter_specs(specs).map(&:version).map(&:to_s)
+      assert_equal %w[2 2.a 2.0 2.1.1], util_filter_specs(specs).map(&:version).map(&:to_s)
     end
     bvf.stub(:bundler_version, v("3")) do
-      assert_equal %w[3 3.0], util_filter_specs(specs).map(&:version).map(&:to_s)
+      assert_equal %w[3 3.a 3.0 3.1.1], util_filter_specs(specs).map(&:version).map(&:to_s)
     end
   end
 
Index: test/rubygems/test_bundled_ca.rb
===================================================================
--- test/rubygems/test_bundled_ca.rb	(revision 66346)
+++ test/rubygems/test_bundled_ca.rb	(revision 66347)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_bundled_ca.rb#L1
 # frozen_string_literal: true
 require 'rubygems/test_case'
-require 'net/https'
+require 'net/http'
 require 'rubygems/request'
 
 # = Testing Bundled CA

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]