committee 1.0.9 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/committee-stub +14 -7
- metadata +2 -2
data/bin/committee-stub
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
+
require "multi_json"
|
3
4
|
require 'optparse'
|
4
5
|
|
5
6
|
require_relative "../lib/committee"
|
6
7
|
|
7
8
|
args = ARGV.dup
|
8
|
-
options = {
|
9
|
+
options = { port: 9292, tolerant: false }
|
9
10
|
opt_parser = OptionParser.new do |opts|
|
10
11
|
opts.banner = "Usage: rackup [options] [JSON Schema file]"
|
11
12
|
|
@@ -17,8 +18,12 @@ opt_parser = OptionParser.new do |opts|
|
|
17
18
|
exit
|
18
19
|
}
|
19
20
|
|
21
|
+
opts.on("-t", "--tolerant", "don't perform request/response validations") {
|
22
|
+
options[:tolerant] = true
|
23
|
+
}
|
24
|
+
|
20
25
|
opts.on("-p", "--port PORT", "use PORT (default: 9292)") { |port|
|
21
|
-
options[:
|
26
|
+
options[:port] = port
|
22
27
|
}
|
23
28
|
end
|
24
29
|
opt_parser.parse!(args)
|
@@ -28,16 +33,18 @@ unless args.count == 1
|
|
28
33
|
exit
|
29
34
|
end
|
30
35
|
|
31
|
-
schema = File.read(args[0])
|
36
|
+
schema = MultiJson.decode(File.read(args[0]))
|
32
37
|
|
33
38
|
app = Rack::Builder.new {
|
34
|
-
|
35
|
-
|
39
|
+
unless options[:tolerant]
|
40
|
+
use Committee::Middleware::RequestValidation, schema: schema
|
41
|
+
use Committee::Middleware::ResponseValidation, schema: schema
|
42
|
+
end
|
43
|
+
|
36
44
|
use Committee::Middleware::Stub, schema: schema
|
37
45
|
run lambda { |_|
|
38
46
|
[404, {}, ["Not found"]]
|
39
47
|
}
|
40
48
|
}
|
41
49
|
|
42
|
-
options[:
|
43
|
-
Rack::Server.start(options)
|
50
|
+
Rack::Server.start(app: app, Port: options[:port])
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: committee
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-05-
|
13
|
+
date: 2014-05-28 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: json_schema
|