Sha256: aaa0674b2ef9d437caaca6db0bc4a5be25c401421ac36808e0380c93d1ef4cf4
Contents?: true
Size: 1.38 KB
Versions: 4
Compression:
Stored size: 1.38 KB
Contents
module Pronto class ConfigFile DEFAULT_MESSAGE_FORMAT = '%{msg}'.freeze EMPTY = { 'all' => { 'exclude' => [], 'include' => [] }, 'github' => { 'slug' => nil, 'access_token' => nil, 'api_endpoint' => 'https://api.github.com/', 'web_endpoint' => 'https://github.com/' }, 'gitlab' => { 'slug' => nil, 'api_private_token' => nil, 'api_endpoint' => 'https://gitlab.com/api/v3' }, 'bitbucket' => { 'slug' => nil, 'username' => nil, 'password' => nil, 'api_endpoint' => nil, 'web_endpoint' => 'https://bitbucket.org/' }, 'text' => { 'format' => '%{color_location} %{color_level}: %{msg}' }, 'runners' => [], 'formatters' => [], 'max_warnings' => nil, 'verbose' => false, 'format' => DEFAULT_MESSAGE_FORMAT }.freeze def initialize(path = '.pronto.yml') @path = path end def to_h hash = File.exist?(@path) ? YAML.load_file(@path) : {} deep_merge(hash) end private 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 end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
pronto-0.9.5 | lib/pronto/config_file.rb |
pronto-0.9.4 | lib/pronto/config_file.rb |
pronto-0.9.3 | lib/pronto/config_file.rb |
pronto-0.9.2 | lib/pronto/config_file.rb |