Sha256: 77e77be27b872200d00c92e1ad65b73a3d3ce7194a00af92789c0d230f8935fc

Contents?: true

Size: 910 Bytes

Versions: 22

Compression:

Stored size: 910 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(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
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
hako-2.17.0 lib/hako/application.rb
hako-2.16.0 lib/hako/application.rb
hako-2.15.1 lib/hako/application.rb
hako-2.15.0 lib/hako/application.rb
hako-2.14.0 lib/hako/application.rb
hako-2.13.0 lib/hako/application.rb
hako-2.12.0 lib/hako/application.rb
hako-2.11.1 lib/hako/application.rb
hako-2.11.0 lib/hako/application.rb
hako-2.10.0 lib/hako/application.rb
hako-2.9.2 lib/hako/application.rb
hako-2.9.1 lib/hako/application.rb
hako-2.9.0 lib/hako/application.rb
hako-2.8.0 lib/hako/application.rb
hako-2.7.0 lib/hako/application.rb
hako-2.6.2 lib/hako/application.rb
hako-2.6.1 lib/hako/application.rb
hako-2.6.0 lib/hako/application.rb
hako-2.5.1 lib/hako/application.rb
hako-2.5.0 lib/hako/application.rb