class Pronto::Config
Public Class Methods
new(config_hash = ConfigFile.new.to_h)
click to toggle source
# File lib/pronto/config.rb, line 3 def initialize(config_hash = ConfigFile.new.to_h) @config_hash = config_hash end
Public Instance Methods
bitbucket_hostname()
click to toggle source
# File lib/pronto/config.rb, line 57 def bitbucket_hostname URI.parse(bitbucket_web_endpoint).host end
consolidate_comments?()
click to toggle source
# File lib/pronto/config.rb, line 21 def consolidate_comments? consolidated = ENV['PRONTO_CONSOLIDATE_COMMENTS'] || @config_hash.fetch('consolidate_comments', false) consolidated end
default_commit()
click to toggle source
# File lib/pronto/config.rb, line 14 def default_commit default_commit = ENV['PRONTO_DEFAULT_COMMIT'] || @config_hash.fetch('default_commit', 'master') default_commit end
excluded_files(runner)
click to toggle source
# File lib/pronto/config.rb, line 40 def excluded_files(runner) files = if runner == 'all' ENV['PRONTO_EXCLUDE'] || @config_hash['all']['exclude'] else @config_hash.fetch(runner, {})['exclude'] end Array(files) .flat_map { |path| Dir[path.to_s] } .map { |path| File.expand_path(path) } end
github_hostname()
click to toggle source
# File lib/pronto/config.rb, line 53 def github_hostname URI.parse(github_web_endpoint).host end
github_review_type()
click to toggle source
# File lib/pronto/config.rb, line 28 def github_review_type review_type = ENV['PRONTO_GITHUB_REVIEW_TYPE'] || @config_hash.fetch('github_review_type', false) if review_type == 'request_changes' 'REQUEST_CHANGES' else 'COMMENT' end end
logger()
click to toggle source
# File lib/pronto/config.rb, line 86 def logger @logger ||= begin verbose = fetch_value('verbose') verbose ? Logger.new($stdout) : Logger.silent end end
max_warnings()
click to toggle source
# File lib/pronto/config.rb, line 65 def max_warnings fetch_integer('max_warnings') end
message_format(formatter)
click to toggle source
# File lib/pronto/config.rb, line 69 def message_format(formatter) formatter_config = @config_hash[formatter] if formatter_config && formatter_config.key?('format') formatter_config['format'] else fetch_value('format') end end
runners()
click to toggle source
# File lib/pronto/config.rb, line 82 def runners fetch_list('runners') end
skip_runners()
click to toggle source
# File lib/pronto/config.rb, line 78 def skip_runners fetch_list('skip_runners') end
warnings_per_review()
click to toggle source
# File lib/pronto/config.rb, line 61 def warnings_per_review fetch_integer('warnings_per_review') end
Private Instance Methods
env_key(key)
click to toggle source
# File lib/pronto/config.rb, line 105 def env_key(key) "PRONTO_#{key.upcase}" end
fetch_integer(key)
click to toggle source
# File lib/pronto/config.rb, line 95 def fetch_integer(key) full_key = env_key(key) (ENV[full_key] && Integer(ENV[full_key])) || @config_hash[key] end
fetch_list(key)
click to toggle source
# File lib/pronto/config.rb, line 109 def fetch_list(key) Array(fetch_value(key)).flat_map do |runners| runners.split(',') end end
fetch_value(key)
click to toggle source
# File lib/pronto/config.rb, line 101 def fetch_value(key) ENV[env_key(key)] || @config_hash[key] end