Class: Minfra::Cli::StackM::ClientTemplate
- Inherits:
-
Object
- Object
- Minfra::Cli::StackM::ClientTemplate
- Includes:
- Logging
- Defined in:
- lib/minfra/cli/commands/stack/client_template.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #exist? ⇒ Boolean
-
#initialize(stack_name, client_name, config) ⇒ ClientTemplate
constructor
A new instance of ClientTemplate.
- #read ⇒ Object
- #to_s ⇒ Object
Methods included from Logging
#debug, #deprecated, #error, #exit_error, #info, #warn
Constructor Details
#initialize(stack_name, client_name, config) ⇒ ClientTemplate
Returns a new instance of ClientTemplate.
13 14 15 16 17 18 19 |
# File 'lib/minfra/cli/commands/stack/client_template.rb', line 13 def initialize(stack_name, client_name, config) @stack_name = stack_name @client_name = client_name @config = OpenStruct.new @path = config.stacks_path.join(stack_name, "fxnet-client-#{client_name}-#{config.orch_env}.json") read end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
11 12 13 |
# File 'lib/minfra/cli/commands/stack/client_template.rb', line 11 def content @content end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
11 12 13 |
# File 'lib/minfra/cli/commands/stack/client_template.rb', line 11 def path @path end |
Instance Method Details
#exist? ⇒ Boolean
21 22 23 |
# File 'lib/minfra/cli/commands/stack/client_template.rb', line 21 def exist? @path.exist? end |
#read ⇒ Object
25 26 27 28 29 30 |
# File 'lib/minfra/cli/commands/stack/client_template.rb', line 25 def read return unless exist? t = Minfra::Cli::Templater.new(File.read(@path)) @content = Hashie::Mash.new(JSON.parse(t.render({}))) end |
#to_s ⇒ Object
32 33 34 |
# File 'lib/minfra/cli/commands/stack/client_template.rb', line 32 def to_s JSON.generate(@content, { indent: ' ', object_nl: "\n" }) end |