Sha256: d1bbc2cfd914b5bb7544adaf0b48e8fb8f8047c44b31a3c1c0105a4be3502c4a

Contents?: true

Size: 879 Bytes

Versions: 31

Compression:

Stored size: 879 Bytes

Contents

require 'find_a_port'
require 'thor'
require 'thin'
require 'thwait'
require 'pact/consumer'

module Pact
  class App < Thor

    desc 'service', "starts a mock service"
    method_option :port, aliases: "-p", desc: "Port on which to run the service"
    method_option :log, aliases: "-l", desc: "File to which to log output"
    method_option :quiet, aliases: "-q", desc: "If true, no admin messages will be shown"

    def service
      service_options = {}
      if options[:log]
        log = File.open(options[:log], 'w')
        log.sync = true
        service_options[:log_file] = log
      end
      port = options[:port] || FindAPort.available_port
      mock_service = Consumer::MockService.new(service_options)
      Thin::Server.start("0.0.0.0", port, mock_service)
    end

    private
    def log message
      puts message unless options[:quiet]
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
pact-1.0.30 lib/pact/app.rb
pact-1.0.29 lib/pact/app.rb
pact-1.0.28 lib/pact/app.rb
pact-1.0.27 lib/pact/app.rb
pact-1.0.26 lib/pact/app.rb
pact-1.0.25 lib/pact/app.rb
pact-1.0.24 lib/pact/app.rb
pact-1.0.23 lib/pact/app.rb
pact-1.0.22 lib/pact/app.rb
pact-1.0.21 lib/pact/app.rb
pact-1.0.20 lib/pact/app.rb
pact-1.0.19 lib/pact/app.rb
pact-1.0.18 lib/pact/app.rb
pact-1.0.15 lib/pact/app.rb
pact-1.0.13 lib/pact/app.rb
pact-1.0.12 lib/pact/app.rb
pact-1.0.11 lib/pact/app.rb
pact-1.0.10 lib/pact/app.rb
pact-1.0.9 lib/pact/app.rb
pact-1.0.8 lib/pact/app.rb