webspicy 0.8.3 → 0.8.4
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d4beb76e573d7d42f8a85e65608ad59c83038a63
|
4
|
+
data.tar.gz: d1c2cb823fa50d41573b3a9116bc5125ef5fc98c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73bf0132edf5214d7c0209202987f87e837765f68ff1916fc60e2924e2e4e620825100bf4347b5393d6b348b1bf475905f23e38ccd0fb9a3f79894adf08ed8f2
|
7
|
+
data.tar.gz: cd4f8964ccae0a8979a6610dac9aa972f00243f8f421017f536aba75fdba037947d3fca97b8f653a4543554bd8859eae0f2dbef88dbf92ad6ecf6e7d16893f05
|
data/lib/webspicy/resource.rb
CHANGED
@@ -19,19 +19,14 @@ module Webspicy
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def url_placeholders
|
22
|
-
url.scan(/\{([a-zA-Z]+)\}/).map{|x| x.first
|
22
|
+
url.scan(/\{([a-zA-Z]+(\.[a-zA-Z]+)*)\}/).map{|x| x.first }
|
23
23
|
end
|
24
24
|
|
25
25
|
def instantiate_url(params)
|
26
26
|
url, rest = self.url, params.dup
|
27
27
|
url_placeholders.each do |placeholder|
|
28
|
-
|
29
|
-
|
30
|
-
url = url.gsub("{#{placeholder}}", params[key].to_s)
|
31
|
-
rest.delete(placeholder)
|
32
|
-
else
|
33
|
-
raise "Missing URL parameter `#{placeholder}`\n\t(#{params.inspect})"
|
34
|
-
end
|
28
|
+
value, rest = extract_placeholder_value(params, placeholder)
|
29
|
+
url = url.gsub("{#{placeholder}}", value.to_s)
|
35
30
|
end
|
36
31
|
[ url, rest ]
|
37
32
|
end
|
@@ -42,6 +37,20 @@ module Webspicy
|
|
42
37
|
|
43
38
|
private
|
44
39
|
|
40
|
+
def extract_placeholder_value(params, placeholder, split = nil)
|
41
|
+
return extract_placeholder_value(params, placeholder, placeholder.split(".")) unless split
|
42
|
+
|
43
|
+
key = [ split.first, split.first.to_sym ].find{|k| params.has_key?(k) }
|
44
|
+
raise "Missing URL parameter `#{placeholder}`" unless key
|
45
|
+
|
46
|
+
if split.size == 1
|
47
|
+
[ params[key], params.dup.delete_if{|k| k == key } ]
|
48
|
+
else
|
49
|
+
value, rest = extract_placeholder_value(params[key], placeholder, split[1..-1])
|
50
|
+
[ value, params.merge(key => rest) ]
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
45
54
|
def bind_services
|
46
55
|
(@raw[:services] ||= []).each do |s|
|
47
56
|
s.resource = self
|
data/lib/webspicy/version.rb
CHANGED
@@ -16,5 +16,12 @@ module Webspicy
|
|
16
16
|
expect(params).to eq(baz: "coz")
|
17
17
|
end
|
18
18
|
|
19
|
+
it 'supports placeholders corresponding to subentities' do
|
20
|
+
r = Resource.new(url: "/test/{foo.id}/url")
|
21
|
+
url, params = r.instantiate_url(foo: {id: "bar"}, baz: "coz")
|
22
|
+
expect(url).to eq("/test/bar/url")
|
23
|
+
expect(params).to eq(foo: {}, baz: "coz")
|
24
|
+
end
|
25
|
+
|
19
26
|
end
|
20
27
|
end
|
@@ -9,7 +9,12 @@ module Webspicy
|
|
9
9
|
|
10
10
|
it 'returns all placeholders' do
|
11
11
|
r = Resource.new(url: "/test/{foo}/url/{bar}")
|
12
|
-
expect(r.url_placeholders).to eq([
|
12
|
+
expect(r.url_placeholders).to eq(["foo", "bar"])
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'returns all placeholders expr' do
|
16
|
+
r = Resource.new(url: "/test/{foo.id}/url/{bar}")
|
17
|
+
expect(r.url_placeholders).to eq(["foo.id", "bar"])
|
13
18
|
end
|
14
19
|
|
15
20
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webspicy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bernard Lambeau
|
@@ -195,7 +195,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
195
195
|
version: '0'
|
196
196
|
requirements: []
|
197
197
|
rubyforge_project:
|
198
|
-
rubygems_version: 2.
|
198
|
+
rubygems_version: 2.5.2
|
199
199
|
signing_key:
|
200
200
|
specification_version: 4
|
201
201
|
summary: Webspicy helps testing web services as software operation black boxes!
|