angelo 0.1.15 → 0.1.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/angelo.rb +2 -2
- data/lib/angelo/params_parser.rb +11 -1
- data/lib/angelo/version.rb +1 -1
- data/test/angelo/params_spec.rb +19 -0
- data/test/angelo_spec.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d2f38075ab97096f8975e0ad89df951f4043d21
|
4
|
+
data.tar.gz: c4c9c531ed3413aac23566e6fe32b1d8fd75ba46
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 02f605f138f53bd33fd55fbb2a45801a53819323efb64f5bddc00b82756877a89674d4349bb3271e13cefda21467270dc603199222ad905a130a5013c96d34e1
|
7
|
+
data.tar.gz: 4a8a4a2870f407ce24649323ec570a759e7649352a17bd82959c35aa820ec086c9020375e12a3d338752ed7e748251dcd5855328c2b2e4420312b66922581ac7
|
data/CHANGELOG.md
CHANGED
data/lib/angelo.rb
CHANGED
@@ -14,8 +14,8 @@ module Angelo
|
|
14
14
|
DELETE = 'DELETE'
|
15
15
|
OPTIONS = 'OPTIONS'
|
16
16
|
|
17
|
-
ROUTABLE = [:get, :post, :put, :delete, :websocket]
|
18
|
-
HTTPABLE = [:get, :post, :put, :delete]
|
17
|
+
ROUTABLE = [:get, :post, :put, :delete, :options, :websocket]
|
18
|
+
HTTPABLE = [:get, :post, :put, :delete, :options]
|
19
19
|
STATICABLE = [:get, :head]
|
20
20
|
|
21
21
|
CONTENT_TYPE_HEADER_KEY = 'Content-Type'
|
data/lib/angelo/params_parser.rb
CHANGED
@@ -34,12 +34,22 @@ module Angelo
|
|
34
34
|
when json?
|
35
35
|
body = EMPTY_JSON if body.empty?
|
36
36
|
body = JSON.parse body
|
37
|
-
qs.merge! body
|
37
|
+
recurse_symhash qs.merge! body
|
38
38
|
else
|
39
39
|
qs
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
+
def recurse_symhash h
|
44
|
+
h.each do |k,v|
|
45
|
+
if Hash === v
|
46
|
+
h[k] = Responder.symhash.merge! v
|
47
|
+
recurse_symhash h[k]
|
48
|
+
end
|
49
|
+
end
|
50
|
+
h
|
51
|
+
end
|
52
|
+
|
43
53
|
def form_encoded?
|
44
54
|
content_type? FORM_TYPE
|
45
55
|
end
|
data/lib/angelo/version.rb
CHANGED
data/test/angelo/params_spec.rb
CHANGED
@@ -60,6 +60,25 @@ describe Angelo::ParamsParser do
|
|
60
60
|
parser.parse_post_body.must_equal post_params
|
61
61
|
end
|
62
62
|
|
63
|
+
it 'recursively symhashes JSON POST bodies params' do
|
64
|
+
nested = {
|
65
|
+
foo: {
|
66
|
+
bar: 'baz',
|
67
|
+
that: {
|
68
|
+
holmes: true
|
69
|
+
}
|
70
|
+
}
|
71
|
+
}
|
72
|
+
parser.form_encoded = false
|
73
|
+
parser.json = true
|
74
|
+
parser.body = nested.to_json
|
75
|
+
parsed = parser.parse_post_body
|
76
|
+
parsed['foo']['bar'].must_equal 'baz'
|
77
|
+
parsed[:foo][:bar].must_equal 'baz'
|
78
|
+
assert parsed['foo']['that']['holmes']
|
79
|
+
assert parsed[:foo][:that][:holmes]
|
80
|
+
end
|
81
|
+
|
63
82
|
it 'should override query string with JSON POST bodies params' do
|
64
83
|
parser.form_encoded = false
|
65
84
|
parser.json = true
|
data/test/angelo_spec.rb
CHANGED
@@ -147,8 +147,8 @@ describe Angelo::Base do
|
|
147
147
|
end
|
148
148
|
|
149
149
|
it 'runs after filters after routes' do
|
150
|
-
a = %w[2 6 14 30]
|
151
|
-
b = [4, 12, 28, 60]
|
150
|
+
a = %w[2 6 14 30 62]
|
151
|
+
b = [4, 12, 28, 60, 124]
|
152
152
|
|
153
153
|
Angelo::HTTPABLE.each_with_index do |m,i|
|
154
154
|
__send__ m, '/after', obj
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: angelo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kenichi Nakamura
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: reel
|