Class: Cloudspin::Stack::Definition

Inherits:
Object
  • Object
show all
Defined in:
lib/cloudspin/stack/definition.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source_path:, stack_name:, stack_version: '0') ⇒ Definition

Returns a new instance of Definition.



11
12
13
14
15
# File 'lib/cloudspin/stack/definition.rb', line 11

def initialize(source_path:, stack_name:, stack_version: '0')
  @source_path = source_path
  @name = stack_name
  @version = stack_version
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/cloudspin/stack/definition.rb', line 7

def name
  @name
end

#source_pathObject (readonly)

Returns the value of attribute source_path.



9
10
11
# File 'lib/cloudspin/stack/definition.rb', line 9

def source_path
  @source_path
end

#versionObject (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



17
18
19
20
21
22
23
24
25
26
# File 'lib/cloudspin/stack/definition.rb', line 17

def self.from_file(specfile)
  raise NoStackDefinitionConfigurationFileError, specfile unless File.exists?(specfile)
  source_path = File.dirname(specfile)
  spec_hash = YAML.load_file(specfile)
  self.new(
    source_path: source_path,
    stack_name: spec_hash.dig('stack', 'name'),
    stack_version: spec_hash.dig('stack', 'version')
  )
end

.from_folder(definition_folder) ⇒ Object



28
29
30
# File 'lib/cloudspin/stack/definition.rb', line 28

def self.from_folder(definition_folder)
  from_file("#{definition_folder}/stack-definition.yaml")
end