Sha256: 3d9c027ce5deb79dc9ea3534ae80cb429cc8385d86ac5ed0a472d63e95471347

Contents?: true

Size: 1.02 KB

Versions: 5

Compression:

Stored size: 1.02 KB

Contents

module PactBroker

  def self.configuration
    @@configuration ||= Configuration.default_configuration
  end

  class Configuration

    attr_accessor :log_dir, :database_connection, :auto_migrate_db, :use_hal_browser, :html_pact_renderer
    attr_writer :logger

    def logger
      @logger ||= create_logger log_path
    end

    def self.default_configuration
      config = Configuration.new
      config.log_dir = File.expand_path("./log")
      config.auto_migrate_db = true
      config.use_hal_browser = true
      config.html_pact_renderer = default_html_pact_render
      config
    end

    def self.default_html_pact_render
      lambda { |pact|
        require 'pact_broker/api/renderers/html_pact_renderer'
        PactBroker::Api::Renderers::HtmlPactRenderer.call pact
      }
    end

    private

    def create_logger path
      FileUtils::mkdir_p File.dirname(path)
      logger = Logger.new(path)
      logger.level = Logger::DEBUG
      logger
    end

    def log_path
      log_dir + "/pact_broker.log"
    end

  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
pact_broker-1.4.0 lib/pact_broker/configuration.rb
pact_broker-1.3.2.rc1 lib/pact_broker/configuration.rb
pact_broker-1.3.1 lib/pact_broker/configuration.rb
pact_broker-1.3.0 lib/pact_broker/configuration.rb
pact_broker-1.2.0 lib/pact_broker/configuration.rb