Sha256: ac32d60c3bdba5ee3c242008e11e551b9689d4d1c1a04e246c3ff50fdee06b45

Contents?: true

Size: 812 Bytes

Versions: 1

Compression:

Stored size: 812 Bytes

Contents

#!/usr/bin/env ruby

require 'slop'
require 'fakeit'

usage = nil
begin
  opts = Slop.parse do |o|
    o.string '--spec', 'spec file uri (required)', required: true
    o.integer '-p', '--port', 'custom port'
    o.bool '-q', '--quiet', 'mute request and response log'
    o.separator ''
    o.separator 'other options:'
    o.on '-v', '--version' do
      puts Fakeit::VERSION
      exit
    end
    o.on '-h', '--help' do
      puts o
      exit
    end

    usage = o
  end
rescue Slop::Error => e
  puts e.message
  puts usage
  exit
end

server = Rack::Handler::WEBrick

trap(:INT) do
  if server.respond_to?(:shutdown)
    server.shutdown
  else
    exit
  end
end

app = Fakeit.build(opts[:spec])
app.use(Fakeit::Middleware::Logger) unless opts[:quiet]
server.run(app, Port: opts[:port], Host: '0.0.0.0')

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fakeit-0.1.1 bin/fakeit