Sha256: 115fccc2b1b70c743dfe3b42738da425f77974294b60ffb5929de6c9a923554c

Contents?: true

Size: 1.17 KB

Versions: 36

Compression:

Stored size: 1.17 KB

Contents

require "capistrano/doctor/output_helpers"

module Capistrano
  module Doctor
    # Prints table of all Capistrano-related gems and their version numbers. If
    # there is a newer version of a gem available, call attention to it.
    class GemsDoctor
      include Capistrano::Doctor::OutputHelpers

      def call
        title("Gems")
        table(all_gem_names) do |gem, row|
          row.yellow if update_available?(gem)
          row << gem
          row << installed_gem_version(gem)
          row << "(update available)" if update_available?(gem)
        end
      end

      private

      def installed_gem_version(gem_name)
        Gem.loaded_specs[gem_name].version
      end

      def update_available?(gem_name)
        latest = Gem.latest_version_for(gem_name)
        return false if latest.nil?
        latest > installed_gem_version(gem_name)
      end

      def all_gem_names
        core_gem_names + plugin_gem_names
      end

      def core_gem_names
        %w(capistrano airbrussh rake sshkit net-ssh) & Gem.loaded_specs.keys
      end

      def plugin_gem_names
        (Gem.loaded_specs.keys - ["capistrano"]).grep(/capistrano/).sort
      end
    end
  end
end

Version data entries

36 entries across 36 versions & 2 rubygems

Version Path
capistrano-3.19.2 lib/capistrano/doctor/gems_doctor.rb
capistrano-3.19.1 lib/capistrano/doctor/gems_doctor.rb
capistrano-3.19.0 lib/capistrano/doctor/gems_doctor.rb
capistrano-3.18.1 lib/capistrano/doctor/gems_doctor.rb
honeybadger-5.4.0 vendor/bundle/ruby/3.2.0/gems/capistrano-3.18.0/lib/capistrano/doctor/gems_doctor.rb
honeybadger-5.3.0 vendor/bundle/ruby/3.2.0/gems/capistrano-3.18.0/lib/capistrano/doctor/gems_doctor.rb
capistrano-3.18.0 lib/capistrano/doctor/gems_doctor.rb
capistrano-3.17.3 lib/capistrano/doctor/gems_doctor.rb
capistrano-3.17.2 lib/capistrano/doctor/gems_doctor.rb
capistrano-3.17.1 lib/capistrano/doctor/gems_doctor.rb
capistrano-3.17.0 lib/capistrano/doctor/gems_doctor.rb
capistrano-3.16.0 lib/capistrano/doctor/gems_doctor.rb
capistrano-3.15.0 lib/capistrano/doctor/gems_doctor.rb
capistrano-3.14.1 lib/capistrano/doctor/gems_doctor.rb
capistrano-3.14.0 lib/capistrano/doctor/gems_doctor.rb
capistrano-3.13.0 lib/capistrano/doctor/gems_doctor.rb
capistrano-3.12.1 lib/capistrano/doctor/gems_doctor.rb
capistrano-3.12.0 lib/capistrano/doctor/gems_doctor.rb
honeybadger-4.5.3 vendor/bundle/ruby/2.6.0/gems/capistrano-3.11.0/lib/capistrano/doctor/gems_doctor.rb
capistrano-3.11.2 lib/capistrano/doctor/gems_doctor.rb