Skip to content

Commit 741a677

Browse files
simideivid-rodriguez
authored andcommitted
Merge pull request #5137 from rubygems/bundle-info-version
Add --version parameter to bundle info command. (cherry picked from commit 5768c2b)
1 parent 5e3df7e commit 741a677

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

bundler/lib/bundler/cli.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ def list
331331

332332
desc "info GEM [OPTIONS]", "Show information for the given gem"
333333
method_option "path", :type => :boolean, :banner => "Print full path to gem"
334+
method_option "version", :type => :boolean, :banner => "Print gem version"
334335
def info(gem_name)
335336
require_relative "cli/info"
336337
Info.new(options, gem_name).run

bundler/lib/bundler/cli/info.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ def run
1818

1919
if spec
2020
return print_gem_path(spec) if @options[:path]
21+
return print_gem_version(spec) if @options[:version]
2122
print_gem_info(spec)
2223
end
2324
end
@@ -39,6 +40,10 @@ def spec_not_found(gem_name)
3940
raise GemNotFound, Bundler::CLI::Common.gem_not_found_message(gem_name, Bundler.definition.dependencies)
4041
end
4142

43+
def print_gem_version(spec)
44+
Bundler.ui.info spec.version.to_s
45+
end
46+
4247
def print_gem_path(spec)
4348
name = spec.name
4449
if name == "bundler"

bundler/spec/commands/info_spec.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@
5050
expect(out).to eq(root.to_s)
5151
end
5252

53+
it "prints gem version if exists in bundle" do
54+
bundle "info rails --version"
55+
expect(out).to eq("2.3.2")
56+
end
57+
5358
it "doesn't claim that bundler has been deleted, even if using a custom path without bundler there" do
5459
bundle "config set --local path vendor/bundle"
5560
bundle "install"

0 commit comments

Comments
 (0)