PHP 8.2.31
Preview: show.rb Size: 2.11 KB
/proc/thread-self/root/opt/alt/ruby40/share/gems/gems/bundler-4.0.10/lib/bundler/cli/show.rb

# frozen_string_literal: true

module Bundler
  class CLI::Show
    attr_reader :options, :gem_name, :latest_specs
    def initialize(options, gem_name)
      @options = options
      @gem_name = gem_name
      @verbose = options[:verbose]
      @latest_specs = fetch_latest_specs if @verbose
    end

    def run
      Bundler.ui.silence do
        Bundler.definition.validate_runtime!
        Bundler.load.lock
      end

      if gem_name
        if gem_name == "bundler"
          path = File.expand_path("../../..", __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} is missing. It should be installed at #{path}, but was not found"
          end
        end
        return Bundler.ui.info(path)
      end

      if options[: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

    private

    def fetch_latest_specs
      definition = Bundler.definition(true)
      Bundler.ui.info "Fetching remote specs for outdated check...\n\n"
      Bundler.ui.silence { definition.remotely! }
      Bundler.reset!
      definition.specs
    end

    def outdated?(current, latest)
      return false unless latest
      Gem::Version.new(current.version) < Gem::Version.new(latest.version)
    end
  end
end

Directory Contents

Dirs: 1 × Files: 26

Name Size Perms Modified Actions
doctor DIR
- drwxr-xr-x 2026-06-09 07:03:24
Edit Download
2.06 KB lrw-r--r-- 2026-05-21 12:15:22
Edit Download
1.77 KB lrw-r--r-- 2026-05-21 12:15:22
Edit Download
711 B lrw-r--r-- 2026-05-21 12:15:22
Edit Download
1.21 KB lrw-r--r-- 2026-05-21 12:15:22
Edit Download
608 B lrw-r--r-- 2026-05-21 12:15:22
Edit Download
5.23 KB lrw-r--r-- 2026-05-21 12:15:22
Edit Download
6.01 KB lrw-r--r-- 2026-05-21 12:15:22
Edit Download
1.10 KB lrw-r--r-- 2026-05-21 12:15:22
Edit Download
1.44 KB lrw-r--r-- 2026-05-21 12:15:22
Edit Download
3.10 KB lrw-r--r-- 2026-05-21 12:15:22
Edit Download
902 B lrw-r--r-- 2026-05-21 12:15:22
Edit Download
16.97 KB lrw-r--r-- 2026-05-21 12:15:22
Edit Download
2.89 KB lrw-r--r-- 2026-05-21 12:15:22
Edit Download
1.28 KB lrw-r--r-- 2026-05-21 12:15:22
Edit Download
4.61 KB lrw-r--r-- 2026-05-21 12:15:22
Edit Download
1.31 KB lrw-r--r-- 2026-05-21 12:15:22
Edit Download
2.75 KB lrw-r--r-- 2026-05-21 12:15:22
Edit Download
2.81 KB lrw-r--r-- 2026-05-21 12:15:22
Edit Download
1.14 KB lrw-r--r-- 2026-05-21 12:15:22
Edit Download
9.11 KB lrw-r--r-- 2026-05-21 12:15:22
Edit Download
1.27 KB lrw-r--r-- 2026-05-21 12:15:22
Edit Download
1.83 KB lrw-r--r-- 2026-05-21 12:15:22
Edit Download
2.13 KB lrw-r--r-- 2026-05-21 12:15:22
Edit Download
351 B lrw-r--r-- 2026-05-21 12:15:22
Edit Download
2.11 KB lrw-r--r-- 2026-05-21 12:15:22
Edit Download
4.16 KB lrw-r--r-- 2026-05-21 12:15:22
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).