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