Sha256: a752aa2a52c4e5eb07c426fb9364a3c4cb2f16359b1bdf64644434c3cdd751ed

Contents?: true

Size: 1.67 KB

Versions: 4

Compression:

Stored size: 1.67 KB

Contents

require 'pact/configuration'
require 'pact/doc/markdown/generator'

module Pact
  module Consumer
    module Configuration

      module ConfigurationExtensions

        DOC_GENERATORS = { markdown: Pact::Doc::Markdown::Generator }

        def doc_dir
          @doc_dir ||= File.expand_path("./doc/pacts")
        end

        def doc_dir= doc_dir
          @doc_dir = doc_dir
        end

        def add_provider_verification &block
          provider_verifications << block
        end

        def provider_verifications
          @provider_verifications ||= []
        end

        def doc_generator= doc_generator
          doc_generators << begin
            if DOC_GENERATORS[doc_generator]
              DOC_GENERATORS[doc_generator]
            elsif doc_generator.respond_to?(:call)
              doc_generator
            else
              raise "Pact.configuration.doc_generator needs to respond to call, or be in the preconfigured list: #{DOC_GENERATORS.keys}"
            end
          end
        end

        def doc_generators
          @doc_generators  ||= []
        end

        def pactfile_write_mode
          @pactfile_write_mode ||= :overwrite
          if @pactfile_write_mode == :smart
            is_rake_running? ? :overwrite : :update
          else
            @pactfile_write_mode
          end
        end

        def pactfile_write_mode= pactfile_write_mode
          @pactfile_write_mode = pactfile_write_mode
        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
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pact-1.4.0 lib/pact/consumer/configuration/configuration_extensions.rb
pact-1.4.0.rc4 lib/pact/consumer/configuration/configuration_extensions.rb
pact-1.4.0.rc3 lib/pact/consumer/configuration/configuration_extensions.rb
pact-1.4.0.rc2 lib/pact/consumer/configuration/configuration_extensions.rb