nested 0.0.25 → 0.0.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/lib/nested/app.rb +31 -0
- data/lib/nested/integration/angular.rb +119 -0
- data/lib/nested/js.rb +42 -0
- data/lib/nested/many.rb +19 -0
- data/lib/nested/one.rb +29 -0
- data/lib/nested/redirect.rb +8 -0
- data/lib/nested/resource.rb +268 -0
- data/lib/nested/serializer.rb +45 -0
- data/lib/nested/serializer_field.rb +9 -0
- data/lib/nested/singleton.rb +13 -0
- data/lib/nested/with_many.rb +11 -0
- data/lib/nested/with_singleton.rb +11 -0
- data/lib/nested.rb +16 -566
- data/nested.gemspec +1 -1
- data/test/nested_test.rb +73 -109
- data/test/test_helper.rb +2 -2
- metadata +14 -2
data/test/nested_test.rb
CHANGED
@@ -14,39 +14,6 @@ class NestedTest < Test::Unit::TestCase
|
|
14
14
|
@sinatra = mock
|
15
15
|
end
|
16
16
|
|
17
|
-
def test_initialize_name
|
18
|
-
assert_raise Nested::NameMissingError do
|
19
|
-
Nested::Resource.new({}, nil, true, false, nil, nil)
|
20
|
-
end
|
21
|
-
|
22
|
-
assert_raise Nested::NameMissingError do
|
23
|
-
Nested::Resource.new({}, nil, false, true, nil, nil)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_is_singleton
|
28
|
-
assert_equal true, singleton(:project).singleton?
|
29
|
-
assert_equal false, many(:projects).singleton?
|
30
|
-
assert_equal false, many(:projects).one.singleton?
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_is_collection
|
34
|
-
assert_equal true, many(:projects).collection?
|
35
|
-
assert_equal false, many(:projects).one.collection?
|
36
|
-
assert_equal false, singleton(:project).collection?
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_is_member
|
40
|
-
assert_equal true, many(:projects).one.member?
|
41
|
-
assert_equal false, many(:projects).member?
|
42
|
-
assert_equal false, singleton(:project).member?
|
43
|
-
end
|
44
|
-
|
45
|
-
# def test_init
|
46
|
-
# init = ->{ }
|
47
|
-
# assert_equal init, singleton(:project).init(&init).instance_variable_get("@__init")
|
48
|
-
# end
|
49
|
-
|
50
17
|
def test_serialize
|
51
18
|
serializer = mock()
|
52
19
|
|
@@ -98,89 +65,86 @@ class NestedTest < Test::Unit::TestCase
|
|
98
65
|
|
99
66
|
def test_singleton
|
100
67
|
resource = singleton(:project)
|
101
|
-
resource.expects(:child_resource).with(:statistic,
|
68
|
+
resource.expects(:child_resource).with(:statistic, Nested::Singleton, Nested::PROC_TRUE, nil)
|
102
69
|
resource.singleton(:statistic)
|
103
70
|
|
104
71
|
resource = many(:projects)
|
105
|
-
resource.expects(:child_resource).with(:statistic,
|
72
|
+
resource.expects(:child_resource).with(:statistic, Nested::Singleton, Nested::PROC_TRUE, nil)
|
106
73
|
resource.singleton(:statistic)
|
107
74
|
|
108
75
|
resource = many(:projects).one
|
109
|
-
resource.expects(:child_resource).with(:statistic,
|
76
|
+
resource.expects(:child_resource).with(:statistic, Nested::Singleton, Nested::PROC_TRUE, nil)
|
110
77
|
resource.singleton(:statistic)
|
111
78
|
end
|
112
79
|
|
113
80
|
def test_one
|
114
81
|
resource = many(:projects)
|
115
|
-
resource.expects(:child_resource).with(:project,
|
82
|
+
resource.expects(:child_resource).with(:project, Nested::One, Nested::PROC_TRUE, nil)
|
116
83
|
resource.one
|
117
84
|
end
|
118
85
|
|
119
86
|
def test_many
|
120
87
|
resource = singleton(:project)
|
121
|
-
resource.expects(:child_resource).with(:statistics,
|
88
|
+
resource.expects(:child_resource).with(:statistics, Nested::Many, Nested::PROC_TRUE, nil)
|
122
89
|
resource.many(:statistics)
|
123
90
|
|
124
91
|
resource = singleton(:project).many(:statistics).one
|
125
|
-
resource.expects(:child_resource).with(:entries,
|
92
|
+
resource.expects(:child_resource).with(:entries, Nested::Many, Nested::PROC_TRUE, nil)
|
126
93
|
resource.many(:entries)
|
127
94
|
end
|
128
95
|
|
129
96
|
def test_get
|
130
97
|
resource = singleton(:project)
|
131
98
|
|
132
|
-
resource.expects(:create_sinatra_route).with(:get, nil)
|
99
|
+
resource.expects(:create_sinatra_route).with(:get, nil, Nested::PROC_TRUE)
|
133
100
|
resource.get
|
134
101
|
|
135
|
-
resource.expects(:create_sinatra_route).with(:get, :action)
|
102
|
+
resource.expects(:create_sinatra_route).with(:get, :action, Nested::PROC_TRUE)
|
136
103
|
resource.get :action
|
137
104
|
end
|
138
105
|
|
139
106
|
def test_post
|
140
107
|
resource = singleton(:project)
|
141
108
|
|
142
|
-
resource.expects(:create_sinatra_route).with(:post, nil)
|
109
|
+
resource.expects(:create_sinatra_route).with(:post, nil, Nested::PROC_TRUE)
|
143
110
|
resource.post
|
144
111
|
|
145
|
-
resource.expects(:create_sinatra_route).with(:post, :action)
|
112
|
+
resource.expects(:create_sinatra_route).with(:post, :action, Nested::PROC_TRUE)
|
146
113
|
resource.post :action
|
147
114
|
end
|
148
115
|
|
149
116
|
def test_put
|
150
117
|
resource = singleton(:project)
|
151
118
|
|
152
|
-
resource.expects(:create_sinatra_route).with(:put, nil)
|
119
|
+
resource.expects(:create_sinatra_route).with(:put, nil, Nested::PROC_TRUE)
|
153
120
|
resource.put
|
154
121
|
|
155
|
-
resource.expects(:create_sinatra_route).with(:put, :action)
|
122
|
+
resource.expects(:create_sinatra_route).with(:put, :action, Nested::PROC_TRUE)
|
156
123
|
resource.put :action
|
157
124
|
end
|
158
125
|
|
159
126
|
def test_delete
|
160
127
|
resource = singleton(:project)
|
161
128
|
|
162
|
-
resource.expects(:create_sinatra_route).with(:delete, nil)
|
129
|
+
resource.expects(:create_sinatra_route).with(:delete, nil, Nested::PROC_TRUE)
|
163
130
|
resource.delete
|
164
131
|
|
165
|
-
resource.expects(:create_sinatra_route).with(:delete, :action)
|
132
|
+
resource.expects(:create_sinatra_route).with(:delete, :action, Nested::PROC_TRUE)
|
166
133
|
resource.delete :action
|
167
134
|
end
|
168
135
|
|
169
136
|
def test_child_resource
|
170
|
-
resource =
|
137
|
+
resource = many(:projects).child_resource(:statistic, Nested::One, Proc.new{ true}, nil) { }
|
171
138
|
assert_equal :statistic, resource.name
|
172
|
-
assert_equal
|
173
|
-
assert_equal false, resource.instance_variable_get("@collection")
|
139
|
+
assert_equal true, resource.is_a?(Nested::One)
|
174
140
|
|
175
|
-
resource = singleton(:project).child_resource(:statistic,
|
141
|
+
resource = singleton(:project).child_resource(:statistic, Nested::Singleton, Proc.new{ true}, nil) { }
|
176
142
|
assert_equal :statistic, resource.name
|
177
|
-
assert_equal true, resource.
|
178
|
-
assert_equal false, resource.instance_variable_get("@collection")
|
143
|
+
assert_equal true, resource.is_a?(Nested::Singleton)
|
179
144
|
|
180
|
-
resource = singleton(:project).child_resource(:statistic,
|
145
|
+
resource = singleton(:project).child_resource(:statistic, Nested::Many, Proc.new{ true}, nil) { }
|
181
146
|
assert_equal :statistic, resource.name
|
182
|
-
assert_equal
|
183
|
-
assert_equal true, resource.instance_variable_get("@collection")
|
147
|
+
assert_equal true, resource.is_a?(Nested::Many)
|
184
148
|
end
|
185
149
|
|
186
150
|
def test_instance_variable_name
|
@@ -278,81 +242,81 @@ class NestedTest < Test::Unit::TestCase
|
|
278
242
|
def test_function_name
|
279
243
|
resource = singleton(:project)
|
280
244
|
|
281
|
-
assert_equal "project", Nested::
|
282
|
-
assert_equal "updateProject", Nested::
|
283
|
-
assert_equal "createProject", Nested::
|
284
|
-
assert_equal "destroyProject", Nested::
|
245
|
+
assert_equal "project", Nested::Js::generate_function_name(resource, :get, nil)
|
246
|
+
assert_equal "updateProject", Nested::Js::generate_function_name(resource, :put, nil)
|
247
|
+
assert_equal "createProject", Nested::Js::generate_function_name(resource, :post, nil)
|
248
|
+
assert_equal "destroyProject", Nested::Js::generate_function_name(resource, :delete, nil)
|
285
249
|
|
286
|
-
assert_equal "projectAction", Nested::
|
287
|
-
assert_equal "updateProjectAction", Nested::
|
288
|
-
assert_equal "createProjectAction", Nested::
|
289
|
-
assert_equal "destroyProjectAction", Nested::
|
250
|
+
assert_equal "projectAction", Nested::Js::generate_function_name(resource, :get, :action)
|
251
|
+
assert_equal "updateProjectAction", Nested::Js::generate_function_name(resource, :put, :action)
|
252
|
+
assert_equal "createProjectAction", Nested::Js::generate_function_name(resource, :post, :action)
|
253
|
+
assert_equal "destroyProjectAction", Nested::Js::generate_function_name(resource, :delete, :action)
|
290
254
|
|
291
255
|
resource = many(:projects)
|
292
256
|
|
293
|
-
assert_equal "projects", Nested::
|
294
|
-
assert_equal "updateProjects", Nested::
|
295
|
-
assert_equal "createProject", Nested::
|
296
|
-
assert_equal "destroyProjects", Nested::
|
257
|
+
assert_equal "projects", Nested::Js::generate_function_name(resource, :get, nil)
|
258
|
+
assert_equal "updateProjects", Nested::Js::generate_function_name(resource, :put, nil)
|
259
|
+
assert_equal "createProject", Nested::Js::generate_function_name(resource, :post, nil)
|
260
|
+
assert_equal "destroyProjects", Nested::Js::generate_function_name(resource, :delete, nil)
|
297
261
|
|
298
|
-
assert_equal "projectsAction", Nested::
|
299
|
-
assert_equal "updateProjectsAction", Nested::
|
300
|
-
assert_equal "createProjectAction", Nested::
|
301
|
-
assert_equal "destroyProjectsAction", Nested::
|
262
|
+
assert_equal "projectsAction", Nested::Js::generate_function_name(resource, :get, :action)
|
263
|
+
assert_equal "updateProjectsAction", Nested::Js::generate_function_name(resource, :put, :action)
|
264
|
+
assert_equal "createProjectAction", Nested::Js::generate_function_name(resource, :post, :action)
|
265
|
+
assert_equal "destroyProjectsAction", Nested::Js::generate_function_name(resource, :delete, :action)
|
302
266
|
|
303
267
|
resource = many(:projects).one
|
304
268
|
|
305
|
-
assert_equal "project", Nested::
|
306
|
-
assert_equal "updateProject", Nested::
|
307
|
-
assert_equal "createProject", Nested::
|
308
|
-
assert_equal "destroyProject", Nested::
|
269
|
+
assert_equal "project", Nested::Js::generate_function_name(resource, :get, nil)
|
270
|
+
assert_equal "updateProject", Nested::Js::generate_function_name(resource, :put, nil)
|
271
|
+
assert_equal "createProject", Nested::Js::generate_function_name(resource, :post, nil)
|
272
|
+
assert_equal "destroyProject", Nested::Js::generate_function_name(resource, :delete, nil)
|
309
273
|
|
310
|
-
assert_equal "projectAction", Nested::
|
311
|
-
assert_equal "updateProjectAction", Nested::
|
312
|
-
assert_equal "createProjectAction", Nested::
|
313
|
-
assert_equal "destroyProjectAction", Nested::
|
274
|
+
assert_equal "projectAction", Nested::Js::generate_function_name(resource, :get, :action)
|
275
|
+
assert_equal "updateProjectAction", Nested::Js::generate_function_name(resource, :put, :action)
|
276
|
+
assert_equal "createProjectAction", Nested::Js::generate_function_name(resource, :post, :action)
|
277
|
+
assert_equal "destroyProjectAction", Nested::Js::generate_function_name(resource, :delete, :action)
|
314
278
|
|
315
279
|
resource = singleton(:project).many(:statistics)
|
316
280
|
|
317
|
-
assert_equal "projectStatistics", Nested::
|
318
|
-
assert_equal "updateProjectStatistics", Nested::
|
319
|
-
assert_equal "createProjectStatistic", Nested::
|
320
|
-
assert_equal "destroyProjectStatistics", Nested::
|
281
|
+
assert_equal "projectStatistics", Nested::Js::generate_function_name(resource, :get, nil)
|
282
|
+
assert_equal "updateProjectStatistics", Nested::Js::generate_function_name(resource, :put, nil)
|
283
|
+
assert_equal "createProjectStatistic", Nested::Js::generate_function_name(resource, :post, nil)
|
284
|
+
assert_equal "destroyProjectStatistics", Nested::Js::generate_function_name(resource, :delete, nil)
|
321
285
|
|
322
|
-
assert_equal "projectStatisticsAction", Nested::
|
323
|
-
assert_equal "updateProjectStatisticsAction", Nested::
|
324
|
-
assert_equal "createProjectStatisticAction", Nested::
|
325
|
-
assert_equal "destroyProjectStatisticsAction", Nested::
|
286
|
+
assert_equal "projectStatisticsAction", Nested::Js::generate_function_name(resource, :get, :action)
|
287
|
+
assert_equal "updateProjectStatisticsAction", Nested::Js::generate_function_name(resource, :put, :action)
|
288
|
+
assert_equal "createProjectStatisticAction", Nested::Js::generate_function_name(resource, :post, :action)
|
289
|
+
assert_equal "destroyProjectStatisticsAction", Nested::Js::generate_function_name(resource, :delete, :action)
|
326
290
|
|
327
291
|
resource = singleton(:project).many(:statistics).one
|
328
292
|
|
329
|
-
assert_equal "projectStatistic", Nested::
|
330
|
-
assert_equal "updateProjectStatistic", Nested::
|
331
|
-
assert_equal "createProjectStatistic", Nested::
|
332
|
-
assert_equal "destroyProjectStatistic", Nested::
|
293
|
+
assert_equal "projectStatistic", Nested::Js::generate_function_name(resource, :get, nil)
|
294
|
+
assert_equal "updateProjectStatistic", Nested::Js::generate_function_name(resource, :put, nil)
|
295
|
+
assert_equal "createProjectStatistic", Nested::Js::generate_function_name(resource, :post, nil)
|
296
|
+
assert_equal "destroyProjectStatistic", Nested::Js::generate_function_name(resource, :delete, nil)
|
333
297
|
|
334
|
-
assert_equal "projectStatisticAction", Nested::
|
335
|
-
assert_equal "updateProjectStatisticAction", Nested::
|
336
|
-
assert_equal "createProjectStatisticAction", Nested::
|
337
|
-
assert_equal "destroyProjectStatisticAction", Nested::
|
298
|
+
assert_equal "projectStatisticAction", Nested::Js::generate_function_name(resource, :get, :action)
|
299
|
+
assert_equal "updateProjectStatisticAction", Nested::Js::generate_function_name(resource, :put, :action)
|
300
|
+
assert_equal "createProjectStatisticAction", Nested::Js::generate_function_name(resource, :post, :action)
|
301
|
+
assert_equal "destroyProjectStatisticAction", Nested::Js::generate_function_name(resource, :delete, :action)
|
338
302
|
|
339
303
|
resource = singleton(:project).many(:statistics).one.many(:entries)
|
340
|
-
assert_equal "projectStatisticEntries", Nested::
|
304
|
+
assert_equal "projectStatisticEntries", Nested::Js::generate_function_name(resource, :get, nil)
|
341
305
|
end
|
342
306
|
|
343
307
|
def test_function_arguments
|
344
|
-
assert_equal [], Nested::
|
345
|
-
assert_equal [], Nested::
|
346
|
-
assert_equal [], Nested::
|
347
|
-
assert_equal ["statistic"], Nested::
|
348
|
-
|
349
|
-
assert_equal [], Nested::
|
350
|
-
assert_equal [], Nested::
|
351
|
-
assert_equal ["project"], Nested::
|
352
|
-
|
353
|
-
assert_equal ["project"], Nested::
|
354
|
-
assert_equal [], Nested::
|
355
|
-
assert_equal ["project", "entry"], Nested::
|
308
|
+
assert_equal [], Nested::Js.function_arguments(singleton(:project))
|
309
|
+
assert_equal [], Nested::Js.function_arguments(singleton(:project).singleton(:statistic))
|
310
|
+
assert_equal [], Nested::Js.function_arguments(singleton(:project).many(:statistics))
|
311
|
+
assert_equal ["statistic"], Nested::Js.function_arguments(singleton(:project).many(:statistics).one)
|
312
|
+
|
313
|
+
assert_equal [], Nested::Js.function_arguments(many(:projects))
|
314
|
+
assert_equal [], Nested::Js.function_arguments(many(:projects).singleton(:statistic))
|
315
|
+
assert_equal ["project"], Nested::Js.function_arguments(many(:projects).one)
|
316
|
+
|
317
|
+
assert_equal ["project"], Nested::Js.function_arguments(many(:projects).one.singleton(:today))
|
318
|
+
assert_equal [], Nested::Js.function_arguments(many(:projects).singleton(:statistic).singleton(:today))
|
319
|
+
assert_equal ["project", "entry"], Nested::Js.function_arguments(many(:projects).one.many(:entries).one)
|
356
320
|
end
|
357
321
|
|
358
322
|
end
|
data/test/test_helper.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
module TestHelper
|
2
2
|
def singleton(name)
|
3
|
-
Nested::
|
3
|
+
Nested::Singleton.new(@sinatra, name, nil, Nested::PROC_TRUE, nil)
|
4
4
|
end
|
5
5
|
|
6
6
|
def many(name)
|
7
|
-
Nested::
|
7
|
+
Nested::Many.new(@sinatra, name, nil, Nested::PROC_TRUE, nil)
|
8
8
|
end
|
9
9
|
end
|
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.26
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Zimmek
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-02-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -79,6 +79,18 @@ files:
|
|
79
79
|
- README.md
|
80
80
|
- Rakefile
|
81
81
|
- lib/nested.rb
|
82
|
+
- lib/nested/app.rb
|
83
|
+
- lib/nested/integration/angular.rb
|
84
|
+
- lib/nested/js.rb
|
85
|
+
- lib/nested/many.rb
|
86
|
+
- lib/nested/one.rb
|
87
|
+
- lib/nested/redirect.rb
|
88
|
+
- lib/nested/resource.rb
|
89
|
+
- lib/nested/serializer.rb
|
90
|
+
- lib/nested/serializer_field.rb
|
91
|
+
- lib/nested/singleton.rb
|
92
|
+
- lib/nested/with_many.rb
|
93
|
+
- lib/nested/with_singleton.rb
|
82
94
|
- nested.gemspec
|
83
95
|
- test/nested_test.rb
|
84
96
|
- test/serializer_field_test.rb
|