Sha256: 834ed9b00216dd8affae63f29971a9f0d7196cf0beb6ef37d4699e486e13c2bd

Contents?: true

Size: 1.04 KB

Versions: 5

Compression:

Stored size: 1.04 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 { |json_content|
        require 'pact_broker/api/renderers/html_pact_renderer'
        PactBroker::Api::Renderers::HtmlPactRenderer.call json_content
      }
    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.1.0 lib/pact_broker/configuration.rb
pact_broker-1.0.0 lib/pact_broker/configuration.rb
pact_broker-1.0.0.alpha3 lib/pact_broker/configuration.rb
pact_broker-1.0.0.alpha2 lib/pact_broker/configuration.rb
pact_broker-1.0.0.alpha1 lib/pact_broker/configuration.rb