Class: Cloudspin::Stack::Definition
- Inherits:
-
Object
- Object
- Cloudspin::Stack::Definition
- Defined in:
- lib/cloudspin/stack/definition.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#parameter_names ⇒ Object
readonly
Returns the value of attribute parameter_names.
-
#resource_names ⇒ Object
readonly
Returns the value of attribute resource_names.
-
#terraform_source_path ⇒ Object
readonly
Returns the value of attribute terraform_source_path.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(terraform_source_path: '', parameter_names: [], resource_names: [], stack: {}) ⇒ Definition
constructor
A new instance of Definition.
Constructor Details
#initialize(terraform_source_path: '', parameter_names: [], resource_names: [], stack: {}) ⇒ Definition
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/cloudspin/stack/definition.rb', line 13 def initialize(terraform_source_path: '', parameter_names: [], resource_names: [], stack: {}) @terraform_source_path = terraform_source_path @parameter_names = parameter_names @resource_names = resource_names @name = stack[:name] || 'NO_NAME' @version = stack[:version] || '0' end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/cloudspin/stack/definition.rb', line 7 def name @name end |
#parameter_names ⇒ Object (readonly)
Returns the value of attribute parameter_names.
9 10 11 |
# File 'lib/cloudspin/stack/definition.rb', line 9 def parameter_names @parameter_names end |
#resource_names ⇒ Object (readonly)
Returns the value of attribute resource_names.
10 11 12 |
# File 'lib/cloudspin/stack/definition.rb', line 10 def resource_names @resource_names end |
#terraform_source_path ⇒ Object (readonly)
Returns the value of attribute terraform_source_path.
11 12 13 |
# File 'lib/cloudspin/stack/definition.rb', line 11 def terraform_source_path @terraform_source_path end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
8 9 10 |
# File 'lib/cloudspin/stack/definition.rb', line 8 def version @version end |
Class Method Details
.from_file(specfile) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/cloudspin/stack/definition.rb', line 24 def self.from_file(specfile) raise "Cloudspin definition file not found: #{specfile}" unless File.exists?(specfile) spec_hash = YAML.load_file(specfile) stack_spec = symbolize(spec_hash) terraform_source_path = File.dirname(specfile) self.new(terraform_source_path: terraform_source_path, **stack_spec) end |
.symbolize(obj) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/cloudspin/stack/definition.rb', line 34 def self.symbolize(obj) return obj.inject({}){ |memo, (k,v)| memo[k.to_sym] = symbolize(v) memo } if obj.is_a? Hash return obj.inject([]) { |memo, v| memo << symbolize(v) memo } if obj.is_a? Array return obj end |