Class: Lono::Inspector::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/lono/inspector/base.rb

Direct Known Subclasses

Graph, Summary

Instance Method Summary collapse

Constructor Details

#initialize(stack_name, options) ⇒ Base

Returns a new instance of Base.



2
3
4
5
# File 'lib/lono/inspector/base.rb', line 2

def initialize(stack_name, options)
  @stack_name = stack_name
  @options = options
end

Instance Method Details

#check_template_exists(template_path) ⇒ Object

Check if the template exists and print friendly error message. Exits if it does not exist.



25
26
27
28
29
30
# File 'lib/lono/inspector/base.rb', line 25

def check_template_exists(template_path)
  unless File.exist?(template_path)
    puts "The template #{template_path} does not exist. Are you sure you use the right template name?  The template name does not require the extension.".colorize(:red)
    exit 1
  end
end

#dataObject



16
17
18
19
20
21
# File 'lib/lono/inspector/base.rb', line 16

def data
  return @data if @data
  template_path = "#{Lono.config.output_path}/templates/#{@stack_name}.yml"
  check_template_exists(template_path)
  @data = YAML.load(IO.read(template_path))
end

#generate_templatesObject



7
8
9
# File 'lib/lono/inspector/base.rb', line 7

def generate_templates
  Lono::Template::DSL.new(@options.clone.merge(quiet: true)).run
end

#runObject



11
12
13
14
# File 'lib/lono/inspector/base.rb', line 11

def run
  generate_templates
  perform
end