# File lib/capistrano/configuration.rb, line 80 def primary(role) servers.fetch_primary(role) end
class Capistrano::Configuration
Attributes
backend[W]
variables[R]
Public Class Methods
env()
click to toggle source
# File lib/capistrano/configuration.rb, line 12 def self.env @env ||= new end
new(values={})
click to toggle source
# File lib/capistrano/configuration.rb, line 25 def initialize(values={}) @variables = Variables.new(values) end
reset!()
click to toggle source
# File lib/capistrano/configuration.rb, line 16 def self.reset! @env = new end
Public Instance Methods
add_cmdline_filter(type, values)
click to toggle source
# File lib/capistrano/configuration.rb, line 119 def add_cmdline_filter(type, values) cmdline_filters << Filter.new(type, values) end
any?(key)
click to toggle source
# File lib/capistrano/configuration.rb, line 46 def any?(key) value = fetch(key) if value && value.respond_to?(:any?) value.any? else !fetch(key).nil? end end
append(key, *values)
click to toggle source
# File lib/capistrano/configuration.rb, line 38 def append(key, *values) set(key, Array(fetch(key)).concat(values)) end
ask(key, default=nil, options={})
click to toggle source
# File lib/capistrano/configuration.rb, line 29 def ask(key, default=nil, options={}) question = Question.new(key, default, options) set(key, question) end
backend()
click to toggle source
# File lib/capistrano/configuration.rb, line 84 def backend @backend ||= SSHKit end
configure_backend()
click to toggle source
# File lib/capistrano/configuration.rb, line 90 def configure_backend backend.configure do |sshkit| configure_sshkit_output(sshkit) sshkit.output_verbosity = fetch(:log_level) sshkit.default_env = fetch(:default_env) sshkit.backend = fetch(:sshkit_backend, SSHKit::Backend::Netssh) sshkit.backend.configure do |backend| backend.pty = fetch(:pty) backend.connection_timeout = fetch(:connection_timeout) backend.ssh_options = (backend.ssh_options || {}).merge(fetch(:ssh_options, {})) end end end
dry_run?()
click to toggle source
# File lib/capistrano/configuration.rb, line 128 def dry_run? fetch(:sshkit_backend) == SSHKit::Backend::Printer end
filter(list)
click to toggle source
# File lib/capistrano/configuration.rb, line 123 def filter(list) setup_filters if @filters.nil? @filters.reduce(list) { |l, f| f.filter l } end
install_plugin(plugin, load_hooks:true)
click to toggle source
# File lib/capistrano/configuration.rb, line 132 def install_plugin(plugin, load_hooks:true) installer.install(plugin, load_hooks: load_hooks) end
is_question?(key)
click to toggle source
# File lib/capistrano/configuration.rb, line 55 def is_question?(key) value = fetch_for(key, nil) !value.nil? && value.is_a?(Question) end
primary(role)
click to toggle source
remove(key, *values)
click to toggle source
# File lib/capistrano/configuration.rb, line 42 def remove(key, *values) set(key, Array(fetch(key)) - values) end
role(name, hosts, options={})
click to toggle source
# File lib/capistrano/configuration.rb, line 60 def role(name, hosts, options={}) if name == :all raise ArgumentError, "#{name} reserved name for role. Please choose another name" end servers.add_role(name, hosts, options) end
role_properties_for(names, &block)
click to toggle source
# File lib/capistrano/configuration.rb, line 76 def role_properties_for(names, &block) servers.role_properties_for(names, &block) end
roles_for(names)
click to toggle source
# File lib/capistrano/configuration.rb, line 72 def roles_for(names) servers.roles_for(names) end
server(name, properties={})
click to toggle source
# File lib/capistrano/configuration.rb, line 68 def server(name, properties={}) servers.add_host(name, properties) end
set_if_empty(key, value=nil, &block)
click to toggle source
# File lib/capistrano/configuration.rb, line 34 def set_if_empty(key, value=nil, &block) set(key, value, &block) unless keys.include?(key) end
setup_filters()
click to toggle source
# File lib/capistrano/configuration.rb, line 108 def setup_filters @filters = cmdline_filters.clone @filters << Filter.new(:role, ENV["ROLES"]) if ENV["ROLES"] @filters << Filter.new(:host, ENV["HOSTS"]) if ENV["HOSTS"] fh = fetch_for(:filter, {}) || {} @filters << Filter.new(:host, fh[:hosts]) if fh[:hosts] @filters << Filter.new(:role, fh[:roles]) if fh[:roles] @filters << Filter.new(:host, fh[:host]) if fh[:host] @filters << Filter.new(:role, fh[:role]) if fh[:role] end
timestamp()
click to toggle source
# File lib/capistrano/configuration.rb, line 104 def timestamp @timestamp ||= Time.now.utc end
Private Instance Methods
cmdline_filters()
click to toggle source
# File lib/capistrano/configuration.rb, line 138 def cmdline_filters @cmdline_filters ||= [] end
configure_sshkit_output(sshkit)
click to toggle source
# File lib/capistrano/configuration.rb, line 150 def configure_sshkit_output(sshkit) format_args = [fetch(:format)] format_args.push(fetch(:format_options)) if any?(:format_options) sshkit.use_format(*format_args) end
installer()
click to toggle source
# File lib/capistrano/configuration.rb, line 146 def installer @installer ||= PluginInstaller.new end
servers()
click to toggle source
# File lib/capistrano/configuration.rb, line 142 def servers @servers ||= Servers.new end