Module: Awsome
- Defined in:
- lib/awsome.rb,
lib/awsome/ec2.rb,
lib/awsome/elb.rb,
lib/awsome/r53.rb,
lib/awsome/ssh.rb,
lib/awsome/debian.rb,
lib/awsome/executor.rb,
lib/awsome/matchmaker.rb,
lib/awsome/ec2/instance.rb,
lib/awsome/requirements.rb,
lib/awsome/elb/load_balancer.rb,
lib/awsome/instance_requirement.rb,
lib/awsome/requirements_options.rb
Defined Under Namespace
Modules: Debian, Ec2, Elb, R53, Ssh
Classes: Config, Executor, InstanceRequirement, Matchmaker, Requirements, RequirementsOptions
Class Method Summary
collapse
Class Method Details
.config ⇒ Object
2
3
4
|
# File 'lib/awsome.rb', line 2
def self.config
@@config ||= Config.new
end
|
.execute(command, options = {}) ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/awsome.rb', line 6
def self.execute(command, options={})
command = command.join(' ') if command.is_a?(Array)
if config.verbose
puts
puts command
puts '='*command.length
end
if options[:system]
result = system(command)
else
result = `#{command}`
result = options[:preprocess].call(result) if options[:preprocess]
result = map_table(result, options)
end
ensure
if config.verbose
case result
when String then puts result
else ap result
end
end
if config.stacks
ap Kernel.caller
end
end
|
.map_table(table, options) ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/awsome.rb', line 32
def self.map_table(table, options)
return table unless options[:columns]
rows = table.split("\n")
rows.select! { |row| row =~ options[:filter] } if options[:filter]
rows.collect do |row|
properties = {}
values = options[:delimiter] ? row.split(options[:delimiter]) : row.split
values.each_with_index { |value, index|
field = options[:columns][index]
properties[field] = value
}
properties
end
end
|
.wait_until(opts = {}, &block) ⇒ Object
47
48
49
50
51
52
53
54
55
|
# File 'lib/awsome.rb', line 47
def self.wait_until(opts={}, &block)
retries = opts[:retries] || 5
interval = opts[:interval] || 5
while !yield && retries > 0
puts "block returned false (#{retries} more retries)..." if Awsome.config.verbose
sleep interval
retries -= 1
end
end
|