Class: Pronto::ConfigFile

Inherits:
Object
  • Object
show all
Defined in:
lib/pronto/config_file.rb

Constant Summary collapse

DEFAULT_MESSAGE_FORMAT =
'%{msg}'.freeze
DEFAULT_WARNINGS_PER_REVIEW =
30
EMPTY =
{
  'all' => {
    'exclude' => [],
    'include' => []
  },
  'github' => {
    'slug' => nil,
    'access_token' => nil,
    'api_endpoint' => 'https://api.github.com/',
    'web_endpoint' => 'https://github.com/',
    'review_type' => 'request_changes'
  },
  'gitlab' => {
    'slug' => nil,
    'api_private_token' => nil,
    'api_endpoint' => 'https://gitlab.com/api/v4'
  },
  'bitbucket' => {
    'slug' => nil,
    'username' => nil,
    'password' => nil,
    'api_endpoint' => nil,
    'auto_approve' => false,
    'web_endpoint' => 'https://bitbucket.org/'
  },
  'text' => {
    'format' => '%{color_location} %{color_level}: %{msg}'
  },
  'default_commit' => 'master',
  'runners' => [],
  'formatters' => [],
  'max_warnings' => nil,
  'warnings_per_review' => DEFAULT_WARNINGS_PER_REVIEW,
  'verbose' => false,
  'format' => DEFAULT_MESSAGE_FORMAT
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path = ENV.fetch('PRONTO_CONFIG_FILE', '.pronto.yml')) ⇒ ConfigFile

Returns a new instance of ConfigFile.



45
46
47
# File 'lib/pronto/config_file.rb', line 45

def initialize(path = ENV.fetch('PRONTO_CONFIG_FILE', '.pronto.yml'))
  @path = path
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



43
44
45
# File 'lib/pronto/config_file.rb', line 43

def path
  @path
end

Instance Method Details

#to_hObject



49
50
51
52
# File 'lib/pronto/config_file.rb', line 49

def to_h
  hash = File.exist?(@path) ? YAML.load_file(@path) : {}
  deep_merge(hash)
end