class Pronto::ConfigFile

Constants

DEFAULT_MESSAGE_FORMAT
DEFAULT_WARNINGS_PER_REVIEW
EMPTY

Attributes

path[R]

Public Class Methods

new(path = ENV.fetch('PRONTO_CONFIG_FILE', '.pronto.yml')) click to toggle source
# File lib/pronto/config_file.rb, line 45
def initialize(path = ENV.fetch('PRONTO_CONFIG_FILE', '.pronto.yml'))
  @path = path
end

Public Instance Methods

to_h() click to toggle source
# File lib/pronto/config_file.rb, line 49
def to_h
  hash = File.exist?(@path) ? YAML.load_file(@path) : {}
  deep_merge(hash)
end

Private Instance Methods

deep_merge(hash) click to toggle source
# File lib/pronto/config_file.rb, line 56
def deep_merge(hash)
  merger = proc do |_, oldval, newval|
    if oldval.is_a?(Hash) && newval.is_a?(Hash)
      oldval.merge(newval, &merger)
    else
      oldval.nil? ? newval : oldval
    end
  end

  hash.merge(EMPTY, &merger)
end