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-4.0.3 lib/branch/name/loadable.rb
branch-name-4.0.2 lib/branch/name/loadable.rb
branch-name-4.0.1 lib/branch/name/loadable.rb
branch-name-4.0.0 lib/branch/name/loadable.rb
branch-name-3.10.10 lib/branch/name/loadable.rb
branch-name-3.10.9 lib/branch/name/loadable.rb
branch-name-3.10.8 lib/branch/name/loadable.rb
branch-name-3.10.7 lib/branch/name/loadable.rb
branch-name-3.10.6 lib/branch/name/loadable.rb
branch-name-3.10.5 lib/branch/name/loadable.rb
branch-name-3.10.4 lib/branch/name/loadable.rb
branch-name-3.10.3 lib/branch/name/loadable.rb
branch-name-3.10.2 lib/branch/name/loadable.rb
branch-name-3.10.1 lib/branch/name/loadable.rb
branch-name-3.10.0 lib/branch/name/loadable.rb
branch-name-3.9.0 lib/branch/name/loadable.rb
branch-name-3.8.0 lib/branch/name/loadable.rb
branch-name-3.7.0 lib/branch/name/loadable.rb
branch-name-3.6.0 lib/branch/name/loadable.rb
branch-name-3.5.1 lib/branch/name/loadable.rb