Sha256: 54278371756b86bd82ed777dd46c6c292fbe57309a0628c8292595f346f6283d

Contents?: true

Size: 898 Bytes

Versions: 7

Compression:

Stored size: 898 Bytes

Contents

# frozen_string_literal: true

require 'hako/error'
require 'hako/jsonnet_loader'
require 'hako/yaml_loader'
require 'pathname'

module Hako
  class Application
    # @!attribute [r] id
    #   @return [String]
    # @!attribute [r] root_path
    #   @return [Pathname]
    # @!attribute [r] definition
    #   @return [Hash]
    attr_reader :id, :root_path, :definition

    def initialize(yaml_path, expand_variables: true, ask_keys: false)
      path = Pathname.new(yaml_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
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
hako-2.3.0 lib/hako/application.rb
hako-2.2.0 lib/hako/application.rb
hako-2.1.0 lib/hako/application.rb
hako-2.0.4 lib/hako/application.rb
hako-2.0.3 lib/hako/application.rb
hako-2.0.2 lib/hako/application.rb
hako-2.0.1 lib/hako/application.rb