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.
-
#source_path ⇒ Object
readonly
Returns the value of attribute source_path.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Class Method Summary collapse
Instance Method Summary collapse
- #github_tag? ⇒ Boolean
-
#initialize(source_path:, stack_name:, stack_version: '0', github_tag: false) ⇒ Definition
constructor
A new instance of Definition.
Constructor Details
#initialize(source_path:, stack_name:, stack_version: '0', github_tag: false) ⇒ Definition
Returns a new instance of Definition.
11 12 13 14 15 16 |
# File 'lib/cloudspin/stack/definition.rb', line 11 def initialize(source_path:, stack_name:, stack_version: '0', github_tag: false) @source_path = source_path @name = stack_name @version = stack_version @github_tag = !github_tag.nil? && (github_tag || /^(true|yes|1)$/i.match(github_tag)) 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 |
#source_path ⇒ Object (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 |
#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
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/cloudspin/stack/definition.rb', line 18 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'), github_tag: spec_hash.dig('stack', 'github_tag') ) end |
.from_folder(definition_folder) ⇒ Object
30 31 32 |
# File 'lib/cloudspin/stack/definition.rb', line 30 def self.from_folder(definition_folder) from_file("#{definition_folder}/stack-definition.yaml") end |
Instance Method Details
#github_tag? ⇒ Boolean
34 35 36 |
# File 'lib/cloudspin/stack/definition.rb', line 34 def github_tag? @github_tag end |