Sha256: 1e1fcf51fece3d3f1b60976d9dc00ad4a4fbaa9b4464c1ab0d98cd4fbf9647f8
Contents?: true
Size: 941 Bytes
Versions: 4
Compression:
Stored size: 941 Bytes
Contents
module Pronto class ConfigFile 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' => nil }, 'runners' => [], 'formatters' => [] } 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 || newval end end hash.merge(EMPTY, &merger) end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
pronto-0.5.3 | lib/pronto/config_file.rb |
pronto-0.5.2 | lib/pronto/config_file.rb |
pronto-0.5.1 | lib/pronto/config_file.rb |
pronto-0.5.0 | lib/pronto/config_file.rb |