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



38
39
40
# File 'lib/pronto/config.rb', line 38

def bitbucket_hostname
  URI.parse(bitbucket_web_endpoint).host
end

#consolidate_comments?Boolean

Returns:

  • (Boolean)


14
15
16
17
18
19
# File 'lib/pronto/config.rb', line 14

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

#excluded_files(runner) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/pronto/config.rb', line 21

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



34
35
36
# File 'lib/pronto/config.rb', line 34

def github_hostname
  URI.parse(github_web_endpoint).host
end

#loggerObject



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

def logger
  @logger ||= begin
    verbose = ENV['PRONTO_VERBOSE'] || @config_hash['verbose']
    verbose ? Logger.new($stdout) : Logger.silent
  end
end

#max_warningsObject



42
43
44
# File 'lib/pronto/config.rb', line 42

def max_warnings
  ENV['PRONTO_MAX_WARNINGS'] || @config_hash['max_warnings']
end

#message_format(formatter) ⇒ Object



46
47
48
49
50
51
52
53
# File 'lib/pronto/config.rb', line 46

def message_format(formatter)
  formatter_config = @config_hash[formatter]
  if formatter_config && formatter_config.key?('format')
    formatter_config['format']
  else
    ENV['PRONTO_FORMAT'] || @config_hash['format']
  end
end