Class: Hako::Application

Inherits:
Object
  • Object
show all
Defined in:
lib/hako/application.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(definition_path, expand_variables: true, ask_keys: false) ⇒ Application

Returns a new instance of Application.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/hako/application.rb', line 18

def initialize(definition_path, expand_variables: true, ask_keys: false)
  path = Pathname.new(definition_path)
  @id = path.basename.sub_ext('').to_s
  @root_path = path.parent
  @definition =
    case path.extname
    when '.yml', '.yaml'
      YamlLoader.new.load(path)
    when '.jsonnet', '.json'
      JsonnetLoader.new(self, expand_variables: expand_variables, ask_keys: ask_keys).load(path)
    else
      raise Error.new("Unknown extension: #{path}")
    end
end

Instance Attribute Details

#definitionObject (readonly)

Returns the value of attribute definition.



16
# File 'lib/hako/application.rb', line 16

attr_reader :id, :root_path, :definition

#idString (readonly)

Returns:

  • (String)


16
17
18
# File 'lib/hako/application.rb', line 16

def id
  @id
end

#root_pathPathname (readonly)

Returns:

  • (Pathname)


16
# File 'lib/hako/application.rb', line 16

attr_reader :id, :root_path, :definition