Module: Capistrano::Configuration::Namespaces
- Defined in:
- lib/borg/configuration.rb
Instance Method Summary collapse
- #filter_hosts(hosts, &block) ⇒ Object
- #filter_task(name, options = {}, &block) ⇒ Object
- #hosts_failing_remote_condition(bash_cmd) ⇒ Object
- #on_hosts_failing_remote_condition(bash_cmd, &block) ⇒ Object
- #on_hosts_passing_remote_condition(bash_cmd, &block) ⇒ Object
- #remote_condition(bash_cmd) ⇒ Object
Instance Method Details
#filter_hosts(hosts, &block) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/borg/configuration.rb', line 16 def filter_hosts(hosts, &block) original_hostfilter = ENV['HOSTFILTER'] ENV['HOSTFILTER'] = hosts logger.info "changing HOSTFILTER from #{original_hostfilter} to #{hosts}".cyan block.call logger.info "resetting HOSTFILTER to #{original_hostfilter}".cyan ENV['HOSTFILTER'] = original_hostfilter end |
#filter_task(name, options = {}, &block) ⇒ Object
10 11 12 13 14 |
# File 'lib/borg/configuration.rb', line 10 def filter_task(name, ={}, &block) task(name, ) do filter_hosts find_servers_for_task(current_task).join(','), &block end end |
#hosts_failing_remote_condition(bash_cmd) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/borg/configuration.rb', line 32 def hosts_failing_remote_condition(bash_cmd) failing_hosts = [] begin run bash_cmd rescue NoMethodError => e raise e rescue Exception => e failing_hosts = e.hosts end failing_hosts end |
#on_hosts_failing_remote_condition(bash_cmd, &block) ⇒ Object
49 50 51 52 |
# File 'lib/borg/configuration.rb', line 49 def on_hosts_failing_remote_condition(bash_cmd, &block) failing_hosts = hosts_failing_remote_condition bash_cmd filter_hosts failing_hosts.join(','), &block end |
#on_hosts_passing_remote_condition(bash_cmd, &block) ⇒ Object
44 45 46 47 |
# File 'lib/borg/configuration.rb', line 44 def on_hosts_passing_remote_condition(bash_cmd, &block) failing_hosts = hosts_failing_remote_condition bash_cmd filter_hosts find_servers_for_task(current_task).reject{|h| failing_hosts.include?(h)}.join(','), &block end |
#remote_condition(bash_cmd) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/borg/configuration.rb', line 25 def remote_condition(bash_cmd) run bash_cmd true rescue false end |