Sha256: cdaad9b9eef2b06e02ba595d232fd74fce648d3934053e600ca87f4162dd1c0d
Contents?: true
Size: 1.71 KB
Versions: 1
Compression:
Stored size: 1.71 KB
Contents
require "capistrano/doctor/output_helpers" module Capistrano module Doctor # Prints a table of all Capistrano variables and their current values. If # there are unrecognized variables, print warnings for them. class VariablesDoctor # These are keys that have no default values in Capistrano, but are # nonetheless expected to be set. WHITELIST = [:application, :repo_url].freeze private_constant :WHITELIST include Capistrano::Doctor::OutputHelpers def initialize(env=Capistrano::Configuration.env) @env = env end 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 attr_reader :env def variables env.variables end 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 def suspicious_keys (variables.untrusted_keys & variables.unused_keys) - WHITELIST end def location(key) loc = variables.source_locations(key).first loc && loc.sub(/^#{Regexp.quote(Dir.pwd)}/, "").sub(/:in.*/, "") end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
capistrano-3.5.0 | lib/capistrano/doctor/variables_doctor.rb |