Class: Bundler::CLI::Show
- Inherits:
-
Object
- Object
- Bundler::CLI::Show
- Defined in:
- lib/bundler/cli/show.rb
Instance Attribute Summary collapse
-
#gem_name ⇒ Object
readonly
Returns the value of attribute gem_name.
-
#latest_specs ⇒ Object
readonly
Returns the value of attribute latest_specs.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(options, gem_name) ⇒ Show
constructor
A new instance of Show.
- #run ⇒ Object
Constructor Details
#initialize(options, gem_name) ⇒ Show
Returns a new instance of Show.
6 7 8 9 10 11 |
# File 'lib/bundler/cli/show.rb', line 6 def initialize(, gem_name) @options = @gem_name = gem_name @verbose = [:verbose] || [:outdated] @latest_specs = fetch_latest_specs if @verbose end |
Instance Attribute Details
#gem_name ⇒ Object (readonly)
Returns the value of attribute gem_name.
5 6 7 |
# File 'lib/bundler/cli/show.rb', line 5 def gem_name @gem_name end |
#latest_specs ⇒ Object (readonly)
Returns the value of attribute latest_specs.
5 6 7 |
# File 'lib/bundler/cli/show.rb', line 5 def latest_specs @latest_specs end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/bundler/cli/show.rb', line 5 def @options end |
Instance Method Details
#run ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/bundler/cli/show.rb', line 13 def run Bundler.ui.silence do Bundler.definition.validate_runtime! Bundler.load.lock end if gem_name if gem_name == "bundler" path = File.("../../..", __dir__) else spec = Bundler::CLI::Common.select_spec(gem_name, :regex_match) return unless spec path = spec.full_gem_path unless File.directory?(path) return Bundler.ui.warn "The gem #{gem_name} has been deleted. It was installed at: #{path}" end end return Bundler.ui.info(path) end if [:paths] Bundler.load.specs.sort_by(&:name).map do |s| Bundler.ui.info s.full_gem_path end else Bundler.ui.info "Gems included by the bundle:" Bundler.load.specs.sort_by(&:name).each do |s| desc = " * #{s.name} (#{s.version}#{s.git_version})" if @verbose latest = latest_specs.find {|l| l.name == s.name } Bundler.ui.info <<~END #{desc.lstrip} \tSummary: #{s.summary || "No description available."} \tHomepage: #{s.homepage || "No website available."} \tStatus: #{outdated?(s, latest) ? "Outdated - #{s.version} < #{latest.version}" : "Up to date"} END else Bundler.ui.info desc end end end end |