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

ruby-changes:61221

From: Hiroshi <ko1@a...>
Date: Wed, 13 May 2020 07:55:07 +0900 (JST)
Subject: [ruby-changes:61221] 0e60b59d58 (master): Update the bundler version with master branch

https://git.ruby-lang.org/ruby.git/commit/?id=0e60b59d58

From 0e60b59d5884edb8f9aea023efd9b24f1ff02049 Mon Sep 17 00:00:00 2001
From: Hiroshi SHIBATA <hsbt@r...>
Date: Fri, 8 May 2020 14:19:04 +0900
Subject: Update the bundler version with master branch


diff --git a/lib/bundler.rb b/lib/bundler.rb
index df34553..610cc48 100644
--- a/lib/bundler.rb
+++ b/lib/bundler.rb
@@ -34,9 +34,9 @@ require_relative "bundler/build_metadata" https://github.com/ruby/ruby/blob/trunk/lib/bundler.rb#L34
 # of loaded and required modules.
 #
 module Bundler
-  environment_preserver = EnvironmentPreserver.new(ENV, EnvironmentPreserver::BUNDLER_KEYS)
+  environment_preserver = EnvironmentPreserver.from_env
   ORIGINAL_ENV = environment_preserver.restore
-  ENV.replace(environment_preserver.backup)
+  environment_preserver.replace_with_backup
   SUDO_MUTEX = Mutex.new
 
   autoload :Definition,             File.expand_path("bundler/definition", __dir__)
@@ -285,7 +285,13 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler.rb#L285
 
     def app_config_path
       if app_config = ENV["BUNDLE_APP_CONFIG"]
-        Pathname.new(app_config).expand_path(root)
+        app_config_pathname = Pathname.new(app_config)
+
+        if app_config_pathname.absolute?
+          app_config_pathname
+        else
+          app_config_pathname.expand_path(root)
+        end
       else
         root.join(".bundle")
       end
@@ -451,6 +457,10 @@ EOF https://github.com/ruby/ruby/blob/trunk/lib/bundler.rb#L457
       Bundler.settings[:system_bindir] || Bundler.rubygems.gem_bindir
     end
 
+    def preferred_gemfile_name
+      Bundler.settings[:init_gems_rb] ? "gems.rb" : "Gemfile"
+    end
+
     def use_system_gems?
       configured_bundle_path.use_system_gems?
     end
@@ -512,7 +522,8 @@ EOF https://github.com/ruby/ruby/blob/trunk/lib/bundler.rb#L522
         Your user account isn't allowed to install to the system RubyGems.
         You can cancel this installation and run:
 
-            bundle install --path vendor/bundle
+            bundle config set --local path 'vendor/bundle'
+            bundle install
 
         to install the gems into ./vendor/bundle/, or you can enter your password
         and install the bundled gems to RubyGems using sudo.
diff --git a/lib/bundler/bundler.gemspec b/lib/bundler/bundler.gemspec
index 30a21f1..27a7f1e 100644
--- a/lib/bundler/bundler.gemspec
+++ b/lib/bundler/bundler.gemspec
@@ -24,21 +24,24 @@ Gem::Specification.new do |s| https://github.com/ruby/ruby/blob/trunk/lib/bundler/bundler.gemspec#L24
 
   if s.respond_to?(:metadata=)
     s.metadata = {
-      "bug_tracker_uri" => "https://github.com/bundler/bundler/issues",
-      "changelog_uri" => "https://github.com/bundler/bundler/blob/master/CHANGELOG.md",
+      "bug_tracker_uri" => "https://github.com/rubygems/bundler/issues",
+      "changelog_uri" => "https://github.com/rubygems/bundler/blob/master/CHANGELOG.md",
       "homepage_uri" => "https://bundler.io/",
-      "source_code_uri" => "https://github.com/bundler/bundler/",
+      "source_code_uri" => "https://github.com/rubygems/bundler/",
     }
   end
 
   s.required_ruby_version     = ">= 2.3.0"
   s.required_rubygems_version = ">= 2.5.2"
 
-  s.files = (Dir.glob("lib/bundler/**/*", File::FNM_DOTMATCH) + Dir.glob("man/bundler*") + Dir.glob("libexec/bundle*")).reject {|f| File.directory?(f) }
+  s.files = Dir.glob("{lib,man,exe}/**/*", File::FNM_DOTMATCH).reject {|f| File.directory?(f) }
 
-  s.files += ["lib/bundler.rb"]
+  # Include the CHANGELOG.md, LICENSE.md, README.md manually
+  s.files += %w[CHANGELOG.md LICENSE.md README.md]
+  # include the gemspec itself because warbler breaks w/o it
+  s.files += %w[bundler.gemspec]
 
-  s.bindir        = "libexec"
+  s.bindir        = "exe"
   s.executables   = %w[bundle bundler]
   s.require_paths = ["lib"]
 end
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb
index 9ff918a..d679482 100644
--- a/lib/bundler/cli.rb
+++ b/lib/bundler/cli.rb
@@ -345,8 +345,8 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/cli.rb#L345
 
     desc "list", "List all gems in the bundle"
     method_option "name-only", :type => :boolean, :banner => "print only the gem names"
-    method_option "only-group", :type => :string, :banner => "print gems from a particular group"
-    method_option "without-group", :type => :string, :banner => "print all gems except from a group"
+    method_option "only-group", :type => :array, :default => [], :banner => "print gems from a given set of groups"
+    method_option "without-group", :type => :array, :default => [], :banner => "print all gems except from a given set of groups"
     method_option "paths", :type => :boolean, :banner => "print the path to each gem in the bundle"
     def list
       require_relative "cli/list"
@@ -570,8 +570,9 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/cli.rb#L570
     method_option :ext, :type => :boolean, :default => false, :desc => "Generate the boilerplate for C extension code"
     method_option :git, :type => :boolean, :default => true, :desc => "Initialize a git repo inside your library."
     method_option :mit, :type => :boolean, :desc => "Generate an MIT license file. Set a default with `bundle config set gem.mit true`."
+    method_option :rubocop, :type => :boolean, :desc => "Add rubocop to the generated Rakefile and gemspec. Set a default with `bundle config set gem.rubocop true`."
     method_option :test, :type => :string, :lazy_default => "rspec", :aliases => "-t", :banner => "rspec",
-                         :desc => "Generate a test directory for your library, either rspec or minitest. Set a default with `bundle config set gem.test rspec`."
+                         :desc => "Generate a test directory for your library, either rspec, minitest or test-unit. Set a default with `bundle config set gem.test rspec`."
     def gem(name)
     end
 
@@ -815,7 +816,7 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/cli.rb#L816
       option = current_command.options[name]
       flag_name = option.switch_name
 
-      name_index = ARGV.find {|arg| flag_name == arg }
+      name_index = ARGV.find {|arg| flag_name == arg.split("=")[0] }
       return unless name_index
 
       value = options[name]
diff --git a/lib/bundler/cli/console.rb b/lib/bundler/cli/console.rb
index c319833..97b8dc0 100644
--- a/lib/bundler/cli/console.rb
+++ b/lib/bundler/cli/console.rb
@@ -12,7 +12,7 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/cli/console.rb#L12
       Bundler::SharedHelpers.major_deprecation 2, "bundle console will be replaced " \
                            "by `bin/console` generated by `bundle gem <name>`"
 
-      group ? Bundler.require(:default, *group.split(' ').map!(&:to_sym)) : Bundler.require
+      group ? Bundler.require(:default, *group.split(" ").map!(&:to_sym)) : Bundler.require
       ARGV.clear
 
       console = get_console(Bundler.settings[:console] || "irb")
diff --git a/lib/bundler/cli/gem.rb b/lib/bundler/cli/gem.rb
index d3e5831..3fd67d9 100644
--- a/lib/bundler/cli/gem.rb
+++ b/lib/bundler/cli/gem.rb
@@ -12,6 +12,7 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/cli/gem.rb#L12
     TEST_FRAMEWORK_VERSIONS = {
       "rspec" => "3.0",
       "minitest" => "5.0",
+      "test-unit" => "3.0",
     }.freeze
 
     attr_reader :options, :gem_name, :thor, :name, :target
@@ -62,7 +63,7 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/cli/gem.rb#L63
       ensure_safe_gem_name(name, constant_array)
 
       templates = {
-        "Gemfile.tt" => "Gemfile",
+        "#{Bundler.preferred_gemfile_name}.tt" => Bundler.preferred_gemfile_name,
         "lib/newgem.rb.tt" => "lib/#{namespaced_path}.rb",
         "lib/newgem/version.rb.tt" => "lib/#{namespaced_path}/version.rb",
         "newgem.gemspec.tt" => "#{name}.gemspec",
@@ -92,16 +93,22 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/cli/gem.rb#L93
             "spec/spec_helper.rb.tt" => "spec/spec_helper.rb",
             "spec/newgem_spec.rb.tt" => "spec/#{namespaced_path}_spec.rb"
           )
+          config[:test_task] = :spec
         when "minitest"
           templates.merge!(
-            "test/test_helper.rb.tt" => "test/test_helper.rb",
-            "test/newgem_test.rb.tt" => "test/#{namespaced_path}_test.rb"
+            "test/minitest/test_helper.rb.tt" => "test/test_helper.rb",
+            "test/minitest/newgem_test.rb.tt" => "test/#{namespaced_path}_test.rb"
           )
+          config[:test_task] = :test
+        when "test-unit"
+          templates.merge!(
+            "test/test-unit/test_helper.rb.tt" => "test/test_helper.rb",
+            "test/test-unit/newgem_test.rb.tt" => "test/#{namespaced_path}_test.rb"
+          )
+          config[:test_task] = :test
         end
       end
 
-      config[:test_task] = config[:test] == "minitest" ? "test" : "spec"
-
       if ask_and_set(:mit, "Do you want to license your code permissively under the MIT license?",
         "This means that any other developer or company will be legally allowed to use your code " \
         "for free as long as they admit you created it. You can read more about the MIT license " \
@@ -124,6 +131,15 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/cli/gem.rb#L131
         templates.merge!("CODE_OF_CONDUCT.md.tt" => "CODE_OF_CONDUCT.md")
       end
 
+      if ask_and_set(:rubocop, "Do you want to add rubocop as a dependency for gems you generate?",
+        "RuboCop is a static code analyzer that has out-of-the-box rules for many " \
+        "of the guidelines in the community style guide. " \
+        "For more information, see the RuboCop docs (https://docs.rubocop.org/en/stable/) " \
+        "and the Ruby Style Guides (https://github.com/rubocop-hq/ruby-style-guide).")
+        config[:rubocop] = true
+        Bundler.ui.info "RuboCop enabled in config"
+      end
+
   (... truncated)

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

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