Class: Bundler::CLI::Show
Relationships & Source Files | |
Inherits: | Object |
Defined in: | lib/bundler/cli/show.rb |
Class Method Summary
- .new(options, gem_name) ⇒ Show constructor
Instance Attribute Summary
- #gem_name readonly
- #latest_specs readonly
- #options readonly
Instance Method Summary
- #run
- #fetch_latest_specs private
- #outdated?(current, latest) ⇒ Boolean private
Constructor Details
.new(options, gem_name) ⇒ Show
# 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 (readonly)
[ GitHub ]# File 'lib/bundler/cli/show.rb', line 5
attr_reader :, :gem_name, :latest_specs
#latest_specs (readonly)
[ GitHub ]# File 'lib/bundler/cli/show.rb', line 5
attr_reader :, :gem_name, :latest_specs
#options (readonly)
[ GitHub ]# File 'lib/bundler/cli/show.rb', line 5
attr_reader :, :gem_name, :latest_specs
Instance Method Details
#fetch_latest_specs (private)
[ GitHub ]# File 'lib/bundler/cli/show.rb', line 58
def fetch_latest_specs definition = Bundler.definition(true) if [:outdated] Bundler.ui.info "Fetching remote specs for outdated check...\n\n" Bundler.ui.silence { definition.resolve_remotely! } else definition.resolve_with_cache! end Bundler.reset! definition.specs end
#outdated?(current, latest) ⇒ Boolean
(private)
#run
[ GitHub ]# 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. ("../../../..", __FILE__) else spec = Bundler::CLI::Common.select_spec(gem_name, :regex_match) return unless spec path = spec.full_gem_path unless File.directory?(path) Bundler.ui.warn "The gem #{gem_name} has been deleted. It was installed at:" 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.gsub(/^ +/, "") #{desc} \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