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.11.1 lib/capistrano/doctor/gems_doctor.rb
capistrano-3.11.0 lib/capistrano/doctor/gems_doctor.rb
capistrano-3.10.2 lib/capistrano/doctor/gems_doctor.rb
capistrano-3.10.1 lib/capistrano/doctor/gems_doctor.rb
capistrano-3.10.0 lib/capistrano/doctor/gems_doctor.rb
capistrano-3.9.1 lib/capistrano/doctor/gems_doctor.rb
capistrano-3.9.0 lib/capistrano/doctor/gems_doctor.rb
capistrano-3.8.2 lib/capistrano/doctor/gems_doctor.rb
capistrano-3.8.1 lib/capistrano/doctor/gems_doctor.rb
capistrano-3.8.0 lib/capistrano/doctor/gems_doctor.rb
capistrano-3.7.2 lib/capistrano/doctor/gems_doctor.rb
capistrano-3.7.1 lib/capistrano/doctor/gems_doctor.rb
capistrano-3.7.0 lib/capistrano/doctor/gems_doctor.rb
capistrano-3.7.0.beta1 lib/capistrano/doctor/gems_doctor.rb
capistrano-3.6.1 lib/capistrano/doctor/gems_doctor.rb
capistrano-3.6.0 lib/capistrano/doctor/gems_doctor.rb