Sha256: 7acea1ff0aa3856bf4fb6402c57372e211e985693b7250b78d8df41cd7c1c388

Contents?: true

Size: 922 Bytes

Versions: 4

Compression:

Stored size: 922 Bytes

Contents

# frozen_string_literal: true

require "pathname"
require "refinements/hashes"
require "refinements/structs"
require "runcom"
require "yaml"

module SublimeTextKit
  module CLI
    module Configuration
      # Represents the fully assembled Command Line Interface (CLI) configuration.
      class Loader
        using Refinements::Hashes
        using Refinements::Structs

        DEFAULTS = YAML.load_file(Pathname(__dir__).join("defaults.yml")).freeze
        HANDLER = Runcom::Config.new "#{Identity::NAME}/configuration.yml", defaults: DEFAULTS

        def self.call = new.call

        def self.with_defaults = new(handler: DEFAULTS)

        def initialize content: Content.new, handler: HANDLER
          @content = content
          @handler = handler
        end

        def call = content.merge(**handler.to_h.flatten_keys)

        private

        attr_reader :content, :handler
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
sublime_text_kit-11.0.3 lib/sublime_text_kit/cli/configuration/loader.rb
sublime_text_kit-11.0.2 lib/sublime_text_kit/cli/configuration/loader.rb
sublime_text_kit-11.0.1 lib/sublime_text_kit/cli/configuration/loader.rb
sublime_text_kit-11.0.0 lib/sublime_text_kit/cli/configuration/loader.rb