Sha256: 84c597fc5205a179b138e649ef5c0a1a49c66dcb0b395f30c592c9b0633bcb33

Contents?: true

Size: 859 Bytes

Versions: 2

Compression:

Stored size: 859 Bytes

Contents

# frozen_string_literal: true

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

module SublimeTextKit
  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
      CLIENT = Runcom::Config.new "#{Identity::NAME}/configuration.yml", defaults: DEFAULTS

      def self.call = new.call

      def self.with_defaults = new(client: DEFAULTS)

      def initialize content: Content.new, client: CLIENT
        @content = content
        @client = client
      end

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

      private

      attr_reader :content, :client
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sublime_text_kit-12.0.1 lib/sublime_text_kit/configuration/loader.rb
sublime_text_kit-12.0.0 lib/sublime_text_kit/configuration/loader.rb