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

ruby-changes:70078

From: Josef <ko1@a...>
Date: Mon, 6 Dec 2021 18:04:05 +0900 (JST)
Subject: [ruby-changes:70078] 25423f0918 (master): [rubygems/rubygems] Add --version parameter to bundle info command.

https://git.ruby-lang.org/ruby.git/commit/?id=25423f0918

From 25423f0918eb31477a9ef72a4c14b0c5c5b78bc6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Josef=20=C5=A0im=C3=A1nek?= <josef.simanek@g...>
Date: Mon, 6 Dec 2021 01:42:43 +0100
Subject: [rubygems/rubygems] Add --version parameter to bundle info command.

https://github.com/rubygems/rubygems/commit/7d9fdd908d
---
 lib/bundler/cli.rb                 | 1 +
 lib/bundler/cli/info.rb            | 5 +++++
 spec/bundler/commands/info_spec.rb | 5 +++++
 3 files changed, 11 insertions(+)

diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb
index f1785609380..d271086b254 100644
--- a/lib/bundler/cli.rb
+++ b/lib/bundler/cli.rb
@@ -331,6 +331,7 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/cli.rb#L331
 
     desc "info GEM [OPTIONS]", "Show information for the given gem"
     method_option "path", :type => :boolean, :banner => "Print full path to gem"
+    method_option "version", :type => :boolean, :banner => "Print gem version"
     def info(gem_name)
       require_relative "cli/info"
       Info.new(options, gem_name).run
diff --git a/lib/bundler/cli/info.rb b/lib/bundler/cli/info.rb
index 6ecc842b4c6..76c8cf60c01 100644
--- a/lib/bundler/cli/info.rb
+++ b/lib/bundler/cli/info.rb
@@ -18,6 +18,7 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/cli/info.rb#L18
 
       if spec
         return print_gem_path(spec) if @options[:path]
+        return print_gem_version(spec) if @options[:version]
         print_gem_info(spec)
       end
     end
@@ -39,6 +40,10 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/cli/info.rb#L40
       raise GemNotFound, Bundler::CLI::Common.gem_not_found_message(gem_name, Bundler.definition.dependencies)
     end
 
+    def print_gem_version(spec)
+      Bundler.ui.info spec.version.to_s
+    end
+
     def print_gem_path(spec)
       name = spec.name
       if name == "bundler"
diff --git a/spec/bundler/commands/info_spec.rb b/spec/bundler/commands/info_spec.rb
index dbfb800c4c7..7f618b5f6cc 100644
--- a/spec/bundler/commands/info_spec.rb
+++ b/spec/bundler/commands/info_spec.rb
@@ -50,6 +50,11 @@ RSpec.describe "bundle info" do https://github.com/ruby/ruby/blob/trunk/spec/bundler/commands/info_spec.rb#L50
       expect(out).to eq(root.to_s)
     end
 
+    it "prints gem version if exists in bundle" do
+      bundle "info rails --version"
+      expect(out).to eq("2.3.2")
+    end
+
     it "doesn't claim that bundler has been deleted, even if using a custom path without bundler there" do
       bundle "config set --local path vendor/bundle"
       bundle "install"
-- 
cgit v1.2.1


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

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