class Capistrano::Doctor::VariablesDoctor

Prints a table of all Capistrano variables and their current values. If there are unrecognized variables, print warnings for them.

Constants

WHITELIST

These are keys that have no default values in Capistrano, but are nonetheless expected to be set.

Attributes

env[R]

Public Class Methods

new(env=Capistrano::Configuration.env) click to toggle source
# File lib/capistrano/doctor/variables_doctor.rb, line 15
def initialize(env=Capistrano::Configuration.env)
  @env = env
end

Public Instance Methods

call() click to toggle source
# File lib/capistrano/doctor/variables_doctor.rb, line 19
def call
  title("Variables")
  values = inspect_all_values

  table(variables.keys.sort) do |key, row|
    row.yellow if suspicious_keys.include?(key)
    row << ":#{key}"
    row << values[key]
  end

  puts if suspicious_keys.any?

  suspicious_keys.sort.each do |key|
    warning(
      ":#{key} is not a recognized Capistrano setting (#{location(key)})"
    )
  end
end

Private Instance Methods

inspect_all_values() click to toggle source
# File lib/capistrano/doctor/variables_doctor.rb, line 46
def inspect_all_values
  variables.keys.each_with_object({}) do |key, inspected|
    inspected[key] = if env.is_question?(key)
                       "<ask>"
                     else
                       variables.peek(key).inspect
                     end
  end
end
location(key) click to toggle source
# File lib/capistrano/doctor/variables_doctor.rb, line 60
def location(key)
  loc = variables.source_locations(key).first
  loc && loc.sub(/^#{Regexp.quote(Dir.pwd)}/, "").sub(/:in.*/, "")
end
suspicious_keys() click to toggle source
# File lib/capistrano/doctor/variables_doctor.rb, line 56
def suspicious_keys
  (variables.untrusted_keys & variables.unused_keys) - WHITELIST
end
variables() click to toggle source
# File lib/capistrano/doctor/variables_doctor.rb, line 42
def variables
  env.variables
end