Class: Pronto::Config
- Inherits:
-
Object
- Object
- Pronto::Config
- Defined in:
- lib/pronto/config.rb
Instance Method Summary collapse
- #bitbucket_hostname ⇒ Object
- #consolidate_comments? ⇒ Boolean
- #excluded_files(runner) ⇒ Object
- #github_hostname ⇒ Object
- #github_review_type ⇒ Object
-
#initialize(config_hash = ConfigFile.new.to_h) ⇒ Config
constructor
A new instance of Config.
- #logger ⇒ Object
- #max_warnings ⇒ Object
- #message_format(formatter) ⇒ Object
- #warnings_per_review ⇒ Object
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_hostname ⇒ Object
50 51 52 |
# File 'lib/pronto/config.rb', line 50 def bitbucket_hostname URI.parse(bitbucket_web_endpoint).host end |
#consolidate_comments? ⇒ 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
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/pronto/config.rb', line 33 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.(path) } end |
#github_hostname ⇒ Object
46 47 48 |
# File 'lib/pronto/config.rb', line 46 def github_hostname URI.parse(github_web_endpoint).host end |
#github_review_type ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/pronto/config.rb', line 21 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 ⇒ Object
71 72 73 74 75 76 |
# File 'lib/pronto/config.rb', line 71 def logger @logger ||= begin verbose = ENV['PRONTO_VERBOSE'] || @config_hash['verbose'] verbose ? Logger.new($stdout) : Logger.silent end end |
#max_warnings ⇒ Object
58 59 60 |
# File 'lib/pronto/config.rb', line 58 def max_warnings ENV['PRONTO_MAX_WARNINGS'] && Integer(ENV['PRONTO_MAX_WARNINGS']) || @config_hash['max_warnings'] end |
#message_format(formatter) ⇒ Object
62 63 64 65 66 67 68 69 |
# File 'lib/pronto/config.rb', line 62 def (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 |
#warnings_per_review ⇒ Object
54 55 56 |
# File 'lib/pronto/config.rb', line 54 def warnings_per_review ENV['PRONTO_WARNINGS_PER_REVIEW'] && Integer(ENV['PRONTO_WARNINGS_PER_REVIEW']) || @config_hash['warnings_per_review'] end |