Class: Pronto::Config

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

Instance Method Summary collapse

Constructor Details

#initialize(config_hash = ConfigFile.new.to_h) ⇒ Config

Returns a new instance of Config.



3
4
5
# File 'lib/pronto/config.rb', line 3

def initialize(config_hash = ConfigFile.new.to_h)
  @config_hash = config_hash
end

Instance Method Details

#bitbucket_hostnameObject



57
58
59
# File 'lib/pronto/config.rb', line 57

def bitbucket_hostname
  URI.parse(bitbucket_web_endpoint).host
end

#consolidate_comments?Boolean

Returns:

  • (Boolean)


21
22
23
24
25
26
# File 'lib/pronto/config.rb', line 21

def consolidate_comments?
  consolidated =
    ENV['PRONTO_CONSOLIDATE_COMMENTS'] ||
    @config_hash.fetch('consolidate_comments', false)
  consolidated
end

#default_commitObject



14
15
16
17
18
19
# 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) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
# 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_hostnameObject



53
54
55
# File 'lib/pronto/config.rb', line 53

def github_hostname
  URI.parse(github_web_endpoint).host
end

#github_review_typeObject



28
29
30
31
32
33
34
35
36
37
38
# 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

#loggerObject



86
87
88
89
90
91
# File 'lib/pronto/config.rb', line 86

def logger
  @logger ||= begin
    verbose = fetch_value('verbose')
    verbose ? Logger.new($stdout) : Logger.silent
  end
end

#max_warningsObject



65
66
67
# File 'lib/pronto/config.rb', line 65

def max_warnings
  fetch_integer('max_warnings')
end

#message_format(formatter) ⇒ Object



69
70
71
72
73
74
75
76
# 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

#runnersObject



82
83
84
# File 'lib/pronto/config.rb', line 82

def runners
  fetch_list('runners')
end

#skip_runnersObject



78
79
80
# File 'lib/pronto/config.rb', line 78

def skip_runners
  fetch_list('skip_runners')
end

#warnings_per_reviewObject



61
62
63
# File 'lib/pronto/config.rb', line 61

def warnings_per_review
  fetch_integer('warnings_per_review')
end