api_sim 0.1.0 → 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.
- checksums.yaml +4 -4
- data/config.example.ru +1 -0
- data/lib/api_sim/matchers/static_request_matcher.rb +10 -1
- data/lib/api_sim/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b15c7a6cedd1f3b8c3544986dce19a917911ea9
|
4
|
+
data.tar.gz: daaac2cab53393e6ade881e389108d1ff3e15540
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3177ab13b83c0dd6a952a42d8cd9c863e87ac1f235e5c03fbf79788e9c2b1905824e2bf133b5b89e7220e9640a2bada03e8c767cfa4c899d48a73418eb0fd684
|
7
|
+
data.tar.gz: f0310976ccd8c1a41e7754034d77083caff7b3b139a441a7516c03a4f1c32abb430fff2e59d1a36acdd7dd9901e7e6755aacf2baa2d2096d7154d99f741f4351
|
data/config.example.ru
CHANGED
@@ -4,6 +4,7 @@ ENDPOINT_JSON_SCHEMA = {"type": "object", "properties": {"a": {"type": "integer"
|
|
4
4
|
|
5
5
|
app = ApiSim.build_app do
|
6
6
|
configure_endpoint 'GET', '/endpoint', 'Hi!', 200, {'X-CUSTOM-HEADER' => 'easy as abc'}, ENDPOINT_JSON_SCHEMA
|
7
|
+
configure_endpoint 'GET', '/begin/:middle/end', 'You found an any-value path', 200, {'CONTENT-TYPE' => 'application/json'}
|
7
8
|
|
8
9
|
configure_dynamic_endpoint 'GET', '/dynamic', ->(req) {
|
9
10
|
[201, {'X-CUSTOM-HEADER' => '123'}, 'Howdy!']
|
@@ -18,7 +18,7 @@ module ApiSim
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def matches?(request)
|
21
|
-
request
|
21
|
+
matches_dynamic_path?(request) && request.request_method == http_method && matcher.call(request)
|
22
22
|
end
|
23
23
|
|
24
24
|
def custom_matcher?
|
@@ -51,6 +51,15 @@ module ApiSim
|
|
51
51
|
request.body.rewind
|
52
52
|
requests.push(RecordedRequest.new(body: request.body.read, request_env: request.env))
|
53
53
|
end
|
54
|
+
|
55
|
+
def matches_dynamic_path?(request)
|
56
|
+
route_tokens = route.split('/')
|
57
|
+
request_tokens = request.path.split('/')
|
58
|
+
|
59
|
+
route_tokens.zip(request_tokens).all? do |matcher_part, request_part|
|
60
|
+
matcher_part == request_part || matcher_part.start_with?(':')
|
61
|
+
end
|
62
|
+
end
|
54
63
|
end
|
55
64
|
end
|
56
65
|
end
|
data/lib/api_sim/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: api_sim
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TJ Taylor
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sinatra
|
@@ -164,7 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
164
164
|
version: '0'
|
165
165
|
requirements: []
|
166
166
|
rubyforge_project:
|
167
|
-
rubygems_version: 2.5.
|
167
|
+
rubygems_version: 2.5.0
|
168
168
|
signing_key:
|
169
169
|
specification_version: 4
|
170
170
|
summary: A DSL on top of sinatra for building application simulators
|