nested 0.0.17 → 0.0.18
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -50
- data/lib/nested.rb +19 -3
- data/nested.gemspec +1 -1
- 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: 7505747ad7eac679ad8c41141fb048f60dd62144
|
4
|
+
data.tar.gz: 4df39444b401cc046ca9df82b9e7702b6c512954
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b9ff324edd1ea97db727208c6a974e35b6a66f895a56fcc1da45038237d90ecbd602bc0c1bb5df9bca65f83b20c4a5654a8dd2722e08096b4b027920204ff77
|
7
|
+
data.tar.gz: 42f0520f7569731de9476208831e07372c29a5045c8b142ac0909cb55a032114b788602f97a23c387ebce5bc2191647204011b8877460c65501851e739dc58ff
|
data/README.md
CHANGED
@@ -1,51 +1,4 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
nested
|
2
|
+
======
|
3
3
|
|
4
|
-
|
5
|
-
- convention of configuration
|
6
|
-
- honor exiting defacto standards
|
7
|
-
|
8
|
-
## Getting Started
|
9
|
-
```
|
10
|
-
class TodoApp < Sinatra::Base
|
11
|
-
|
12
|
-
many :projects do
|
13
|
-
get
|
14
|
-
|
15
|
-
one do
|
16
|
-
many :tasks do
|
17
|
-
get
|
18
|
-
|
19
|
-
one do
|
20
|
-
get
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
singleton :creator, ->{ @project.creator } do
|
25
|
-
get
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
30
|
-
|
31
|
-
singleton :user, ->{ User.current } do
|
32
|
-
get
|
33
|
-
end
|
34
|
-
end
|
35
|
-
```
|
36
|
-
|
37
|
-
## Building Blocks
|
38
|
-
|
39
|
-
### Singleton
|
40
|
-
Lorem ipsum dolor sit amet, consectetur adipisicing elit.
|
41
|
-
|
42
|
-
### Many
|
43
|
-
Lorem ipsum dolor sit amet, consectetur adipisicing elit.
|
44
|
-
|
45
|
-
### One
|
46
|
-
Lorem ipsum dolor sit amet, consectetur adipisicing elit.
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
## Credits
|
51
|
-
Nested is using the fantastic Sinatra framework under the hood.
|
4
|
+
a nestable dsl to create a restful api
|
data/lib/nested.rb
CHANGED
@@ -233,7 +233,12 @@ module Nested
|
|
233
233
|
end
|
234
234
|
|
235
235
|
def sinatra_response(sinatra, method)
|
236
|
-
response = sinatra.
|
236
|
+
response = if sinatra.errors.empty?
|
237
|
+
sinatra.instance_variable_get("@#{self.instance_variable_name}")
|
238
|
+
else
|
239
|
+
sinatra.errors
|
240
|
+
end
|
241
|
+
|
237
242
|
response = self.send(:"sinatra_response_create_#{sinatra_response_type(response)}", sinatra, response, method)
|
238
243
|
|
239
244
|
case response
|
@@ -280,6 +285,15 @@ module Nested
|
|
280
285
|
puts "sinatra router [#{method}] #{@sinatra.nested_config[:prefix]}#{route}"
|
281
286
|
|
282
287
|
@sinatra.send(method, route) do
|
288
|
+
|
289
|
+
def self.error(message)
|
290
|
+
errors.add(:base, message)
|
291
|
+
end
|
292
|
+
|
293
|
+
def self.errors
|
294
|
+
@__errors ||= ActiveModel::Errors.new({})
|
295
|
+
end
|
296
|
+
|
283
297
|
content_type :json
|
284
298
|
|
285
299
|
resource.self_and_parents.reverse.each do |res|
|
@@ -394,7 +408,7 @@ module Nested
|
|
394
408
|
|
395
409
|
module_name = "nested_#{resource.name}".camelcase(:lower)
|
396
410
|
|
397
|
-
js << "angular.module('#{module_name}', [
|
411
|
+
js << "angular.module('#{module_name}', [])"
|
398
412
|
js << ".factory('#{resource.name.to_s.camelcase.capitalize}#{nested_angular_config[:service_suffix]}', function($http, $q){"
|
399
413
|
|
400
414
|
js << " var impl = {}"
|
@@ -403,9 +417,11 @@ module Nested
|
|
403
417
|
|
404
418
|
js << "})"
|
405
419
|
|
420
|
+
response_transform = nested_angular_config[:response_transform] || ->(code){ code }
|
421
|
+
|
406
422
|
get "/#{resource.name}.js" do
|
407
423
|
content_type :js
|
408
|
-
js.join("\n")
|
424
|
+
instance_exec(js.join("\n"), &response_transform)
|
409
425
|
end
|
410
426
|
end
|
411
427
|
end
|
data/nested.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nested
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.18
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Zimmek
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|