Class: Awsome::Requirements
- Inherits:
-
Object
- Object
- Awsome::Requirements
- Defined in:
- lib/awsome/requirements.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
- #filters ⇒ Object
-
#initialize(requirements_hash) ⇒ Requirements
constructor
A new instance of Requirements.
- #instances ⇒ Object
- #traits ⇒ Object
Constructor Details
#initialize(requirements_hash) ⇒ Requirements
Returns a new instance of Requirements.
8 9 10 11 |
# File 'lib/awsome/requirements.rb', line 8 def initialize(requirements_hash) @requirements = requirements_hash.clone @options = Awsome::RequirementsOptions.new(@requirements) end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/awsome/requirements.rb', line 6 def @options end |
Class Method Details
.from_yaml_file(filename) ⇒ Object
13 14 15 |
# File 'lib/awsome/requirements.rb', line 13 def self.from_yaml_file(filename) new(YAML::load(File.open(filename, 'r').read)) end |
.to_table(requirements, title = 'Requirements') ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/awsome/requirements.rb', line 33 def self.to_table(requirements, title='Requirements') rows = [] #add requirement rows requirements.each do |req| rows << [ req..collect { |v| "#{v[0]}: #{v[1]}" }.join("\n"), req.packages.to_a.join("\n"), req.volumes.to_a.join("\n"), req.elbs.join("\n"), req.elastic_ips.join("\n"), req.cnames.collect{|c|c['names']}.flatten.join("\n"), req.ami_id, req.key, req.instance_type, req.availability_zone, req.security_group_ids ] rows << :separator end # remove last unnecessary separator rows.pop if rows.any? headings = %w(tags packages volumes elbs elasticips cnames ami key type zone secgroup) Terminal::Table.new :headings => headings, :rows => rows, :title => title end |
Instance Method Details
#filters ⇒ Object
25 26 27 |
# File 'lib/awsome/requirements.rb', line 25 def filters @requirements['filters'] || {} end |
#instances ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/awsome/requirements.rb', line 17 def instances @instances ||= @requirements['instances'].collect do |req| instance = req.clone instance = inflate(instance, instance.delete('traits')) Awsome::InstanceRequirement.new(instance, @options) end end |
#traits ⇒ Object
29 30 31 |
# File 'lib/awsome/requirements.rb', line 29 def traits @requirements['traits'] || {} end |