Sha256: 2e36f5fad9733fe2b14ff5fb93ef97635f39ced5672ec566c80b7c5752c8a6e4

Contents?: true

Size: 599 Bytes

Versions: 26

Compression:

Stored size: 599 Bytes

Contents

# frozen_string_literal: true

require 'erb'
require 'yaml'
require_relative 'configurable'

module Branch
  module Name
    module Loadable
      include Configurable

      def load_options(defaults: {})
        options = {}

        options.merge!(load_config(global_config_file))
        options.merge!(load_config(local_config_file))

        options.presence || defaults
      end

      def load_config(config_file)
        return {} unless File.exist? config_file

        yaml_options = File.read(config_file)
        YAML.safe_load ERB.new(yaml_options).result
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
branch-name-3.5.0 lib/branch/name/loadable.rb
branch-name-3.4.0 lib/branch/name/loadable.rb
branch-name-3.3.0 lib/branch/name/loadable.rb
branch-name-3.2.2 lib/branch/name/loadable.rb
branch-name-3.2.1 lib/branch/name/loadable.rb
branch-name-3.0.0 lib/branch/name/loadable.rb