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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e3fe7e1fbbed26101e7b8204067db4e0cf8d8b24
4
- data.tar.gz: 0d80c3741af219d78fdd2273717588ad286afa4a
3
+ metadata.gz: 3d2f38075ab97096f8975e0ad89df951f4043d21
4
+ data.tar.gz: c4c9c531ed3413aac23566e6fe32b1d8fd75ba46
5
5
  SHA512:
6
- metadata.gz: 34fea99d0f4f8c0b4e10eaf2d1903df121d1ba541fb354e87f9b61caacfbcc4741894f6ec7bd8b4ccf1b7aab27770bf19d830b8a588afed113363c44d74fe26d
7
- data.tar.gz: 52ee6e7b8111bdcf75c77ee828b061d831c921d27f50181d8f6d6f2b69abf1164498f23a0d01a846f920375214400330ce8ab880242cf3c50786e3ea780557b2
6
+ metadata.gz: 02f605f138f53bd33fd55fbb2a45801a53819323efb64f5bddc00b82756877a89674d4349bb3271e13cefda21467270dc603199222ad905a130a5013c96d34e1
7
+ data.tar.gz: 4a8a4a2870f407ce24649323ec570a759e7649352a17bd82959c35aa820ec086c9020375e12a3d338752ed7e748251dcd5855328c2b2e4420312b66922581ac7
data/CHANGELOG.md CHANGED
@@ -1,6 +1,11 @@
1
1
  changelog
2
2
  =========
3
3
 
4
+ ### 0.1.16 8 aug 2014
5
+
6
+ * recursively symhash JSON POST bodies
7
+ * add options route builder
8
+
4
9
  ### 0.1.15 24 jul 2014
5
10
 
6
11
  * WebsocketResponder -> Responder::Websocket
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'
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Angelo
2
- VERSION = '0.1.15'
2
+ VERSION = '0.1.16'
3
3
  end
@@ -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.15
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-07-24 00:00:00.000000000 Z
11
+ date: 2014-08-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: reel