Class: Alphonse::Operator

Inherits:
Object
  • Object
show all
Includes:
Configs::Bundler, Configs::Tasks
Defined in:
lib/alphonse/operator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Configs::Bundler

#bundle_exec, #bundle_install, #rake

Methods included from Configs::Tasks

#branch, #bundle, #cd_to_parent_path, #cd_to_path, #db_migrate, #db_setup, #git_clone, #git_pull, #list, #mkdir_path, #repository, #restart_app, #set_path_variable, #source_shell_rc, #start_app

Constructor Details

#initialize(config = {}) ⇒ Operator

Returns a new instance of Operator.



11
12
13
# File 'lib/alphonse/operator.rb', line 11

def initialize(config = {})
  @config = config
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



9
10
11
# File 'lib/alphonse/operator.rb', line 9

def config
  @config
end

Instance Method Details

#execute(command) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/alphonse/operator.rb', line 15

def execute(command)
  hosts.each do |host_connection|
    begin
      Alphonse.logger.info "\e[4mRunning on #{host_connection.connection_string}\e[0m"
      
      host_connection.send_and_execute send(command)

      Alphonse.logger.success "Aaaaaay! All Actions Completed"
    rescue Exception => e
      Alphonse.logger.error "#{e.class.to_s} : #{e.message}\n\n#{e.backtrace.join("\n")}"
      break
    ensure
      host_connection.close
    end
  end
end