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
-
#initialize(config_hash = ConfigFile.new.to_h) ⇒ Config
constructor
A new instance of Config.
- #logger ⇒ Object
- #max_warnings ⇒ Object
- #message_format(formatter) ⇒ 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
38 39 40 |
# File 'lib/pronto/config.rb', line 38 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
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.(path) } end |
#github_hostname ⇒ Object
34 35 36 |
# File 'lib/pronto/config.rb', line 34 def github_hostname URI.parse(github_web_endpoint).host end |
#logger ⇒ Object
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_warnings ⇒ Object
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 (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 |