Class: AlertMachine
- Inherits:
-
Object
show all
- Defined in:
- lib/run_task.rb,
lib/process.rb,
lib/alert_machine.rb,
lib/rails_environment.rb
Overview
A single watch and it’s life cycle.
Defined Under Namespace
Classes: Caller, Process, RailsEnvironment, RunTask, Watcher
Constant Summary
collapse
- CONFIG_FILE =
Configure your machine before running it.
'config/alert_machine.yml'
- @@config =
nil
- @@tasks =
[]
- @@em_invoked =
false
- @@current_task =
nil
Class Method Summary
collapse
Class Method Details
.config(config_file = CONFIG_FILE) ⇒ Object
80
81
82
83
84
|
# File 'lib/alert_machine.rb', line 80
def self.config(config_file = CONFIG_FILE)
@@config ||= YAML::load(File.open(config_file))
rescue
{}
end
|
.current_task ⇒ Object
148
149
150
|
# File 'lib/alert_machine.rb', line 148
def self.current_task
@@current_task
end
|
.current_task=(task) ⇒ Object
152
153
154
|
# File 'lib/alert_machine.rb', line 152
def self.current_task=(task)
@@current_task = task
end
|
.disable(disabled = true) ⇒ Object
107
108
109
|
# File 'lib/alert_machine.rb', line 107
def self.disable(disabled = true)
@@em_invoked = disabled
end
|
.reset ⇒ Object
156
157
158
|
# File 'lib/alert_machine.rb', line 156
def self.reset
@@tasks = []
end
|
.run ⇒ Object
Invoke this whenever you are ready to enter the AlertMachine loop.
87
88
89
90
91
92
93
94
95
96
97
|
# File 'lib/alert_machine.rb', line 87
def self.run
unless @@em_invoked
@@em_invoked = true
EM::run do
@@tasks.each do |t|
t.schedule
end
yield if block_given?
end
end
end
|
.ssh_config ⇒ Object
99
100
101
102
103
104
105
|
# File 'lib/alert_machine.rb', line 99
def self.ssh_config
res = {}
config['ssh'].each_pair do |k, v|
res[k.to_sym] = v
end
return res
end
|
.tasks ⇒ Object
144
145
146
|
# File 'lib/alert_machine.rb', line 144
def self.tasks
@@tasks
end
|