Sha256: aaa66f6121074f9c7e4e03b069ad2a9e4524886210e042192d938db574ad3b3d

Contents?: true

Size: 1.02 KB

Versions: 2

Compression:

Stored size: 1.02 KB

Contents

module Pronto
  class Config
    def initialize(config_hash = ConfigFile.new.to_h)
      @config_hash = config_hash
    end

    %w(github gitlab bitbucket).each do |service|
      ConfigFile::EMPTY[service].each do |key, _|
        name = "#{service}_#{key}"
        define_method(name) { ENV[name.upcase] || @config_hash[service][key] }
      end
    end

    def consolidate_comments?
      !@config_hash['consolidate_comments'].nil?
    end

    def excluded_files
      @excluded_files ||= Array(exclude)
        .flat_map { |path| Dir[path.to_s] }
        .map { |path| File.expand_path(path) }
    end

    def github_hostname
      URI.parse(github_web_endpoint).host
    end

    def bitbucket_hostname
      URI.parse(bitbucket_web_endpoint).host
    end

    def max_warnings
      @config_hash['max_warnings']
    end

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

    private

    def exclude
      @config_hash['all']['exclude']
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pronto-0.7.1 lib/pronto/config.rb
pronto-0.7.0 lib/pronto/config.rb