Class: Definition
- Inherits:
-
Object
- Object
- Definition
- Defined in:
- lib/sproutr/definition.rb
Constant Summary collapse
- FILE_PREFIX =
"~/Sprout_configs/machine_definitions/"
Instance Attribute Summary collapse
-
#ami ⇒ Object
Returns the value of attribute ami.
-
#availability_zone ⇒ Object
Returns the value of attribute availability_zone.
-
#chef_cookbooks ⇒ Object
Returns the value of attribute chef_cookbooks.
-
#chef_install ⇒ Object
Returns the value of attribute chef_install.
-
#chef_recipes ⇒ Object
Returns the value of attribute chef_recipes.
-
#gems ⇒ Object
Returns the value of attribute gems.
-
#key_name ⇒ Object
Returns the value of attribute key_name.
-
#name ⇒ Object
Returns the value of attribute name.
-
#packages ⇒ Object
Returns the value of attribute packages.
-
#size ⇒ Object
Returns the value of attribute size.
-
#tags ⇒ Object
Returns the value of attribute tags.
-
#user_data ⇒ Object
Returns the value of attribute user_data.
-
#volume_size ⇒ Object
Returns the value of attribute volume_size.
-
#volumes ⇒ Object
Returns the value of attribute volumes.
Instance Method Summary collapse
-
#initialize {|_self| ... } ⇒ Definition
constructor
A new instance of Definition.
- #load_from_file(filename) ⇒ Object
- #save_to_file(filename) ⇒ Object
Constructor Details
#initialize {|_self| ... } ⇒ Definition
Returns a new instance of Definition.
8 9 10 |
# File 'lib/sproutr/definition.rb', line 8 def initialize yield self if block_given? end |
Instance Attribute Details
#ami ⇒ Object
Returns the value of attribute ami.
6 7 8 |
# File 'lib/sproutr/definition.rb', line 6 def ami @ami end |
#availability_zone ⇒ Object
Returns the value of attribute availability_zone.
6 7 8 |
# File 'lib/sproutr/definition.rb', line 6 def availability_zone @availability_zone end |
#chef_cookbooks ⇒ Object
Returns the value of attribute chef_cookbooks.
6 7 8 |
# File 'lib/sproutr/definition.rb', line 6 def chef_cookbooks @chef_cookbooks end |
#chef_install ⇒ Object
Returns the value of attribute chef_install.
6 7 8 |
# File 'lib/sproutr/definition.rb', line 6 def chef_install @chef_install end |
#chef_recipes ⇒ Object
Returns the value of attribute chef_recipes.
6 7 8 |
# File 'lib/sproutr/definition.rb', line 6 def chef_recipes @chef_recipes end |
#gems ⇒ Object
Returns the value of attribute gems.
6 7 8 |
# File 'lib/sproutr/definition.rb', line 6 def gems @gems end |
#key_name ⇒ Object
Returns the value of attribute key_name.
6 7 8 |
# File 'lib/sproutr/definition.rb', line 6 def key_name @key_name end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/sproutr/definition.rb', line 6 def name @name end |
#packages ⇒ Object
Returns the value of attribute packages.
6 7 8 |
# File 'lib/sproutr/definition.rb', line 6 def packages @packages end |
#size ⇒ Object
Returns the value of attribute size.
6 7 8 |
# File 'lib/sproutr/definition.rb', line 6 def size @size end |
#tags ⇒ Object
Returns the value of attribute tags.
6 7 8 |
# File 'lib/sproutr/definition.rb', line 6 def @tags end |
#user_data ⇒ Object
Returns the value of attribute user_data.
6 7 8 |
# File 'lib/sproutr/definition.rb', line 6 def user_data @user_data end |
#volume_size ⇒ Object
Returns the value of attribute volume_size.
6 7 8 |
# File 'lib/sproutr/definition.rb', line 6 def volume_size @volume_size end |
#volumes ⇒ Object
Returns the value of attribute volumes.
6 7 8 |
# File 'lib/sproutr/definition.rb', line 6 def volumes @volumes end |
Instance Method Details
#load_from_file(filename) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/sproutr/definition.rb', line 12 def load_from_file(filename) definition_file = File.open(FILE_PREFIX + filename, 'r') JSON.parse(definition_file.read).each do |element, value| instance_variable_set(element, value) end end |
#save_to_file(filename) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/sproutr/definition.rb', line 19 def save_to_file(filename) hash_of_definition = Hash.new instance_variables.each do |var| hash_of_definition[var.to_s.gsub("@","")] = instance_variable_get(var) end File.open(FILE_PREFIX + filename, 'w') {|f| f.write(hash_of_definition.to_json) } end |