Module: Prmd::CLI::Stub
- Extended by:
- Base
- Defined in:
- lib/prmd/cli/stub.rb
Overview
‘stub’ command module’
Class Method Summary collapse
-
.execute(options = {}) ⇒ void
Executes the ‘stub’ command.
-
.make_parser(options = {}) ⇒ OptionParser
Returns a OptionParser for parsing ‘stub’ command options.
Methods included from Base
execute, make_parser, noop_execute, parse_options, run
Class Method Details
.execute(options = {}) ⇒ void
This method returns an undefined value.
Executes the ‘stub’ command.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/prmd/cli/stub.rb', line 28 def self.execute( = {}) require "committee" filename = .fetch(:argv).first _, schema = try_read(filename) app = Rack::Builder.new { use Committee::Middleware::RequestValidation, schema: schema use Committee::Middleware::ResponseValidation, schema: schema use Committee::Middleware::Stub, schema: schema run lambda { |_| [404, {}, ["Not found"]] } } Rack::Server.start(app: app) end |
.make_parser(options = {}) ⇒ OptionParser
Returns a OptionParser for parsing ‘stub’ command options.
13 14 15 16 17 18 19 |
# File 'lib/prmd/cli/stub.rb', line 13 def self.make_parser( = {}) binname = .fetch(:bin, 'prmd') OptionParser.new do |opts| opts. = "#{binname} stub [options] <combined schema>" end end |