Sha256: 55c0d382ea90d569c3d28955c04d50200f4b07d71cfb3c55ce387cefc56ea227
Contents?: true
Size: 1.6 KB
Versions: 3
Compression:
Stored size: 1.6 KB
Contents
require 'ostruct' require 'logger' module Pact class Configuration attr_accessor :pact_dir attr_accessor :log_dir attr_accessor :logger attr_accessor :tmp_dir attr_accessor :reports_dir attr_writer :pactfile_write_mode attr_accessor :error_stream attr_accessor :output_stream def log_path log_dir + "/pact.log" end def pactfile_write_mode if @pactfile_write_mode == :smart is_rake_running? ? :overwrite : :update else @pactfile_write_mode end end private #Would love a better way of determining this! It sure won't work on windows. def is_rake_running? `ps -ef | grep rake | grep #{Process.ppid} | grep -v 'grep'`.size > 0 end end def self.configuration @configuration ||= default_configuration end def self.configure yield configuration FileUtils::mkdir_p configuration.tmp_dir end def self.clear_configuration @configuration = default_configuration end private def self.default_configuration c = Configuration.new c.pact_dir = File.expand_path('./spec/pacts') c.tmp_dir = File.expand_path('./tmp/pacts') c.log_dir = default_log_dir c.logger = default_logger c.log_path c.pactfile_write_mode = :overwrite c.reports_dir = File.expand_path('./reports/pacts') c.output_stream = $stdout c.error_stream = $stderr c end def self.default_log_dir File.expand_path("./log") end def self.default_logger path FileUtils::mkdir_p File.dirname(path) logger = Logger.new(path) logger.level = Logger::DEBUG logger end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
pact-1.0.39 | lib/pact/configuration.rb |
pact-1.1.0.rc2 | lib/pact/configuration.rb |
pact-1.0.38 | lib/pact/configuration.rb |