cuba-api 0.3.3 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +5 -1
- data/lib/cuba_api/guard.rb +2 -1
- data/lib/cuba_api/input_filter.rb +7 -26
- data/lib/cuba_api/utils.rb +5 -0
- data/spec/input_filter_spec.rb +3 -2
- metadata +38 -54
data/Gemfile
CHANGED
data/lib/cuba_api/guard.rb
CHANGED
@@ -22,6 +22,7 @@
|
|
22
22
|
|
23
23
|
module CubaApi
|
24
24
|
module Guard
|
25
|
+
warn 'DEPRECATED: guard will disappear as it is now'
|
25
26
|
def allowed?( *group_names )
|
26
27
|
authenticated? && ( allowed_groups( *group_names ).size > 0 )
|
27
28
|
end
|
@@ -34,4 +35,4 @@ module CubaApi
|
|
34
35
|
current_user.groups
|
35
36
|
end
|
36
37
|
end
|
37
|
-
end
|
38
|
+
end
|
@@ -9,33 +9,15 @@ module CubaApi
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
def
|
13
|
-
|
12
|
+
def req_filter( model = nil, context = nil )
|
13
|
+
@_filter ||=
|
14
|
+
begin
|
15
|
+
filter = self.class.factory.new_filter( model ).use( context )
|
16
|
+
filter.filter_it( parse_request_body )
|
17
|
+
end
|
14
18
|
end
|
15
|
-
alias :new_instance_from_request :new_instance
|
16
19
|
|
17
|
-
|
18
|
-
filter_params_and_keeps( clazz, context )
|
19
|
-
@_data[ 0 ] || {}
|
20
|
-
end
|
21
|
-
alias :filtered_params :params
|
22
|
-
|
23
|
-
def keeps( clazz = nil, context = nil )
|
24
|
-
filter_params_and_keeps( clazz, context )
|
25
|
-
@_data[ 1 ] || {}
|
26
|
-
end
|
27
|
-
|
28
|
-
def filter_params_and_keeps( clazz, context )
|
29
|
-
if clazz
|
30
|
-
@_data ||=
|
31
|
-
begin
|
32
|
-
filter = self.class.factory.new_filter( clazz ).use( context )
|
33
|
-
filter.filter_it( parse_request_body )
|
34
|
-
end
|
35
|
-
end
|
36
|
-
@_data ||= {}
|
37
|
-
end
|
38
|
-
private :filter_params_and_keeps
|
20
|
+
protected
|
39
21
|
|
40
22
|
def parse_request_body
|
41
23
|
if env[ 'CONTENT_TYPE' ] =~ /^application\/json/
|
@@ -44,6 +26,5 @@ module CubaApi
|
|
44
26
|
{}
|
45
27
|
end
|
46
28
|
end
|
47
|
-
protected :parse_request_body
|
48
29
|
end
|
49
30
|
end
|
data/lib/cuba_api/utils.rb
CHANGED
data/spec/input_filter_spec.rb
CHANGED
@@ -27,12 +27,13 @@ describe CubaApi::InputFilter do
|
|
27
27
|
Cuba.plugin CubaApi::InputFilter
|
28
28
|
Cuba.define do
|
29
29
|
on post do
|
30
|
-
attr =
|
30
|
+
attr = req_filter( D ).new_model.attributes
|
31
31
|
# whether hash is ordered-hash should not matter
|
32
32
|
res.write attr.keys.sort.collect {|k| attr[k] }.join
|
33
33
|
end
|
34
34
|
on default do
|
35
|
-
|
35
|
+
filter = req_filter( D, :update )
|
36
|
+
res.write filter.params['message'].to_s + filter.age.to_s
|
36
37
|
end
|
37
38
|
end
|
38
39
|
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cuba-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.4.0
|
4
5
|
prerelease:
|
5
|
-
version: 0.3.3
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Christian Meier
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-07-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: cuba
|
@@ -33,13 +33,13 @@ dependencies:
|
|
33
33
|
requirements:
|
34
34
|
- - "~>"
|
35
35
|
- !ruby/object:Gem::Version
|
36
|
-
version: '0.
|
36
|
+
version: '0.4'
|
37
37
|
none: false
|
38
38
|
requirement: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
40
|
- - "~>"
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: '0.
|
42
|
+
version: '0.4'
|
43
43
|
none: false
|
44
44
|
prerelease: false
|
45
45
|
type: :runtime
|
@@ -97,29 +97,13 @@ dependencies:
|
|
97
97
|
requirements:
|
98
98
|
- - "~>"
|
99
99
|
- !ruby/object:Gem::Version
|
100
|
-
version: 10.0
|
100
|
+
version: '10.0'
|
101
101
|
none: false
|
102
102
|
requirement: !ruby/object:Gem::Requirement
|
103
103
|
requirements:
|
104
104
|
- - "~>"
|
105
105
|
- !ruby/object:Gem::Version
|
106
|
-
version: 10.0
|
107
|
-
none: false
|
108
|
-
prerelease: false
|
109
|
-
type: :development
|
110
|
-
- !ruby/object:Gem::Dependency
|
111
|
-
name: copyright-header
|
112
|
-
version_requirements: !ruby/object:Gem::Requirement
|
113
|
-
requirements:
|
114
|
-
- - '='
|
115
|
-
- !ruby/object:Gem::Version
|
116
|
-
version: 1.0.8
|
117
|
-
none: false
|
118
|
-
requirement: !ruby/object:Gem::Requirement
|
119
|
-
requirements:
|
120
|
-
- - '='
|
121
|
-
- !ruby/object:Gem::Version
|
122
|
-
version: 1.0.8
|
106
|
+
version: '10.0'
|
123
107
|
none: false
|
124
108
|
prerelease: false
|
125
109
|
type: :development
|
@@ -129,13 +113,13 @@ dependencies:
|
|
129
113
|
requirements:
|
130
114
|
- - "~>"
|
131
115
|
- !ruby/object:Gem::Version
|
132
|
-
version: '4.
|
116
|
+
version: '4.0'
|
133
117
|
none: false
|
134
118
|
requirement: !ruby/object:Gem::Requirement
|
135
119
|
requirements:
|
136
120
|
- - "~>"
|
137
121
|
- !ruby/object:Gem::Version
|
138
|
-
version: '4.
|
122
|
+
version: '4.0'
|
139
123
|
none: false
|
140
124
|
prerelease: false
|
141
125
|
type: :development
|
@@ -182,46 +166,46 @@ files:
|
|
182
166
|
- README.md
|
183
167
|
- lib/cuba_api.rb~
|
184
168
|
- lib/cuba_api.rb
|
169
|
+
- lib/cuba_api/ext2mime_rack.rb~
|
170
|
+
- lib/cuba_api/guard.rb
|
185
171
|
- lib/cuba_api/accept_content.rb
|
186
|
-
- lib/cuba_api/reponse_status.rb~
|
187
|
-
- lib/cuba_api/response_status.rb
|
188
|
-
- lib/cuba_api/config.rb
|
189
|
-
- lib/cuba_api/current_user.rb
|
190
172
|
- lib/cuba_api/ext2mime_rack.rb
|
191
|
-
- lib/cuba_api/reloader_rack.rb
|
192
|
-
- lib/cuba_api/reloader_rack.rb~
|
193
|
-
- lib/cuba_api/ext2mime_rack.rb~
|
194
|
-
- lib/cuba_api/current_user.rb~
|
195
173
|
- lib/cuba_api/response_status.rb~
|
196
|
-
- lib/cuba_api/
|
197
|
-
- lib/cuba_api/
|
198
|
-
- lib/cuba_api/
|
174
|
+
- lib/cuba_api/accept_content.rb~
|
175
|
+
- lib/cuba_api/reloader_rack.rb
|
176
|
+
- lib/cuba_api/write_aspects.rb~
|
199
177
|
- lib/cuba_api/write_aspect.rb~
|
178
|
+
- lib/cuba_api/serializer.rb~
|
179
|
+
- lib/cuba_api/response_status.rb
|
200
180
|
- lib/cuba_api/serializer.rb
|
201
|
-
- lib/cuba_api/
|
181
|
+
- lib/cuba_api/write_aspect.rb
|
182
|
+
- lib/cuba_api/current_user.rb~
|
202
183
|
- lib/cuba_api/input_filter.rb~
|
203
|
-
- lib/cuba_api/accept_content.rb~
|
204
|
-
- lib/cuba_api/utils.rb
|
205
184
|
- lib/cuba_api/input_filter.rb
|
206
|
-
- lib/cuba_api/
|
207
|
-
- lib/cuba_api/
|
208
|
-
- lib/cuba_api/
|
209
|
-
-
|
210
|
-
-
|
211
|
-
-
|
212
|
-
-
|
213
|
-
-
|
185
|
+
- lib/cuba_api/reponse_status.rb~
|
186
|
+
- lib/cuba_api/config.rb~
|
187
|
+
- lib/cuba_api/guard.rb~
|
188
|
+
- lib/cuba_api/reloader_rack.rb~
|
189
|
+
- lib/cuba_api/utils.rb
|
190
|
+
- lib/cuba_api/current_user.rb
|
191
|
+
- lib/cuba_api/utils.rb~
|
192
|
+
- lib/cuba_api/config.rb
|
193
|
+
- spec/response_status_spec.rb~
|
214
194
|
- spec/current_user_spec.rb
|
195
|
+
- spec/spec_helper.rb
|
196
|
+
- spec/response_status_spec.rb
|
197
|
+
- spec/config_spec.rb
|
198
|
+
- spec/input_filter_spec.rb
|
215
199
|
- spec/current_user_spec.rb~
|
216
|
-
- spec/serializer_spec.rb~
|
217
200
|
- spec/aspects_spec.rb~
|
218
|
-
- spec/response_status_spec.rb~
|
219
|
-
- spec/input_filter_spec.rb
|
220
201
|
- spec/aspects_spec.rb
|
221
202
|
- spec/serializer_spec.rb
|
222
|
-
- spec/
|
223
|
-
- spec/
|
203
|
+
- spec/spec_helper.rb~
|
204
|
+
- spec/input_filter_spec.rb~
|
205
|
+
- spec/serializer_spec.rb~
|
224
206
|
- spec/accept_spec.rb~
|
207
|
+
- spec/config_spec.rb~
|
208
|
+
- spec/accept_spec.rb
|
225
209
|
- Gemfile
|
226
210
|
homepage: http://github.com/mkristian/cuba-api
|
227
211
|
licenses:
|
@@ -251,10 +235,10 @@ signing_key:
|
|
251
235
|
specification_version: 3
|
252
236
|
summary: set of plugins for using cuba as API server
|
253
237
|
test_files:
|
254
|
-
- spec/accept_spec.rb
|
255
238
|
- spec/current_user_spec.rb
|
239
|
+
- spec/response_status_spec.rb
|
240
|
+
- spec/config_spec.rb
|
256
241
|
- spec/input_filter_spec.rb
|
257
242
|
- spec/aspects_spec.rb
|
258
243
|
- spec/serializer_spec.rb
|
259
|
-
- spec/
|
260
|
-
- spec/response_status_spec.rb
|
244
|
+
- spec/accept_spec.rb
|