clone 1.0.0.beta → 1.0.0.beta2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -2
  3. data/VERSION +1 -1
  4. data/samples/grape/init/Gemfile +2 -2
  5. data/samples/grape/init/{docs → doc}/grape/documentation.txt +0 -0
  6. data/samples/grape/init/lib/grape.rb +12 -2
  7. data/samples/grape/init/lib/grape/mount/rest_api.rb +22 -0
  8. data/samples/grape/vendor/lib/grape/vendors/{v1/rest.rb → v1.rb} +4 -2
  9. data/samples/helper/init/Gemfile +5 -0
  10. data/samples/helper/init/lib/boot.rb +23 -0
  11. data/samples/mongoid/init/Gemfile +1 -3
  12. data/samples/mongoid/init/lib/mongoid.rb +9 -40
  13. data/samples/mongoid/init/lib/mongoid/meta/{mongoid.yml → config.yml} +0 -0
  14. data/samples/rack/init/Gemfile +1 -4
  15. data/samples/rack/init/lib/rack.rb +1 -1
  16. metadata +8 -44
  17. data/samples/blather/restlike/Gemfile +0 -4
  18. data/samples/blather/restlike/cmd.yml +0 -1
  19. data/samples/blather/restlike/lib/blather.rb +0 -9
  20. data/samples/blather/restlike/lib/blather/dsl/api.rb +0 -78
  21. data/samples/blather/restlike/lib/blather/dsl/call.rb +0 -13
  22. data/samples/blather/restlike/lib/blather/dsl/client.rb +0 -58
  23. data/samples/blather/restlike/lib/blather/dsl/config.rb +0 -11
  24. data/samples/blather/restlike/lib/blather/dsl/extraDSL.rb +0 -163
  25. data/samples/blather/restlike/lib/blather/meta/require.rb +0 -8
  26. data/samples/blather/restlike/lib/blather/meta/xmpp.yml +0 -5
  27. data/samples/blather/restlike/lib/blather/vendors/xmpp_default.rb +0 -27
  28. data/samples/blather/restlike/readme +0 -2
  29. data/samples/grape/init/docs/grape/generate_rest_routes.rb +0 -37
  30. data/samples/grape/init/docs/grape/ls_routes.rb +0 -31
  31. data/samples/grape/init/lib/grape/meta/subclasses.rb +0 -20
  32. data/samples/grape/init/lib/grape/xpath/app.rb +0 -30
  33. data/samples/grape/init/lib/grape/xpath/ruotes.rb +0 -6
  34. data/samples/mongoid/cmd.yml +0 -1
  35. data/samples/mongoid/init/docs/mongoid/ModelsRelations.rb +0 -11
  36. data/samples/mongoid/init/docs/mongoid/generate_modelsToDocs.rb +0 -25
  37. data/samples/mongoid/init/docs/mongoid/modelsToDocs.rb +0 -25
  38. data/samples/mongoid/init/lib/mongoid/dsl/extraDSL_CRUD.rb +0 -446
  39. data/samples/mongoid/init/lib/mongoid/dsl/extraDSL_MP.rb +0 -517
  40. data/samples/mongoid/init/lib/mongoid/dsl/init.rb +0 -37
  41. data/samples/mongoid/init/lib/mongoid/dsl/params.rb +0 -67
  42. data/samples/mongoid/init/lib/mongoid/meta/banned.rb +0 -147
  43. data/samples/mongoid/init/lib/mongoid/meta/control.yml +0 -13
  44. data/samples/mongoid/init/lib/mongoid/meta/mpatch.rb +0 -14
  45. data/samples/rack/init/lib/rack/meta/webserver/thin.rb +0 -45
  46. data/samples/rack/init/lib/rack/meta/webserver/thin.yml +0 -6
  47. data/samples/rack/init/server.rb +0 -0
  48. data/samples/rest_client/init/Gemfile +0 -5
  49. data/samples/rest_client/init/boot.rb +0 -2
  50. data/samples/rest_client/init/cmd.yml +0 -1
  51. data/samples/rest_client/init/config/rest_client/defaults.rb +0 -16
  52. data/samples/rest_client/init/docs/rest_client/simple overlook +0 -251
  53. data/samples/rest_client/init/test/rest_client/rest_dsl.rb +0 -5
  54. data/samples/rest_client/readme +0 -7
@@ -1,517 +0,0 @@
1
- class Class
2
-
3
- def documents
4
- begin
5
-
6
- exceptions= %w[
7
- Mongoid::Relations::Embedded::In
8
- Mongoid::Relations::Referenced::In
9
- ]
10
-
11
- return_array = Array.new
12
- self.relations.each do |model_name,module_propertys|
13
- if !exceptions.include?(module_propertys[:relation].to_s)
14
- return_array.push model_name
15
- end
16
- end
17
-
18
- return return_array
19
- rescue Exception
20
- return Array.new
21
- end
22
- end
23
-
24
- def relation_connection_type(to_model)
25
- begin
26
-
27
- return_none= "Mongoid::Relations::None"
28
- return_self= "Mongoid::Relations::Self"
29
-
30
- if to_model.nil?
31
- return return_none
32
- end
33
-
34
- if self.to_s == to_model.to_s
35
- return return_self
36
- end
37
-
38
- relation_type_data= self.reflect_on_association(to_model.convert_model_name)
39
-
40
- if relation_type_data.nil?
41
- return return_none
42
- else
43
- return relation_type_data[:relation].to_s
44
- end
45
-
46
- end
47
- end
48
- def reverse_relation_connection_type(to_model)
49
- begin
50
-
51
- return_none= "Mongoid::Relations::None"
52
- return_self= "Mongoid::Relations::Self"
53
-
54
- if to_model.nil?
55
- return return_none
56
- end
57
-
58
- if self.to_s == to_model.to_s
59
- return return_self
60
- end
61
-
62
- relation_type_data= to_model.reflect_on_association(self.convert_model_name)
63
-
64
- if relation_type_data.nil?
65
- return return_none
66
- else
67
- return relation_type_data[:relation].to_s
68
- end
69
-
70
- end
71
- end
72
-
73
- def properties
74
-
75
- hash_data = Hash.new
76
- self.fields.each do |key,value|
77
- hash_data[value.name]=value.options[:type]
78
- end
79
- return hash_data
80
-
81
- end
82
- def parents
83
- begin
84
-
85
- exceptions= %w[
86
- Mongoid::Relations::Embedded::In
87
- ]
88
-
89
- return_array = Array.new
90
- self.relations.each do |model_name,module_propertys|
91
- if exceptions.include?(module_propertys[:relation].to_s)
92
- return_array.push model_name
93
- end
94
- end
95
- if return_array.empty?
96
- return nil
97
- end
98
- return return_array
99
-
100
- end
101
- end
102
- def references
103
- begin
104
-
105
- exceptions= %w[
106
- Mongoid::Relations::Referenced::In
107
- Mongoid::Relations::Referenced::ManyToMany
108
- ]
109
-
110
- return_array = Array.new
111
- self.relations.each do |model_name,module_propertys|
112
- if exceptions.include?(module_propertys[:relation].to_s)
113
- return_array.push model_name
114
- end
115
- end
116
- if return_array.empty?
117
- return nil
118
- end
119
- return return_array
120
-
121
- end
122
- end
123
-
124
- def getPaths(*included)
125
-
126
- ### create defaults
127
- begin
128
- return_array= Array.new()
129
- check_list= Array.new#.push(self.to_s)
130
- relations_hash = Hash.new()
131
- #chains= Hash.new
132
- chains= Array.new
133
- end
134
-
135
- ### get parents for every participants
136
- begin
137
- models_to_check = Array.new.push self
138
- loop do
139
- tmp_array = Array.new
140
- break if models_to_check.empty?
141
- models_to_check.each do |one_models_element|
142
- begin
143
- one_models_element.parents.each do |one_parent_in_underscore|
144
- parent_model= one_parent_in_underscore.convert_model_name
145
- tmp_array.push parent_model if !relations_hash.keys.include?(parent_model)
146
- relations_hash[one_models_element] ||= Array.new
147
- relations_hash[one_models_element].push parent_model
148
- end
149
- rescue NoMethodError
150
- #next
151
- end
152
- end
153
- models_to_check= tmp_array
154
- end
155
- models_to_check.clear
156
- end
157
-
158
- ### make connections from relation pairs
159
- begin
160
-
161
- ### generate pre path chains
162
- ### minden egyes szulo,s szulo szulo elemen egyesevel menj vegig (csak elso elemet vizsgalva) es ahol tobb mint egy elem talalhato azt torold
163
- ### igy legkozelebb az mar nem lesz lehetseges utvonal, ahol pedig mindenhol csak 1 elem volt ott ellenorzid
164
- ### hogy mar megtalalt sorrol van e szo, s ha igen torold a relations_hash[self] ből ezt a szulot (2. elem a path ban)
165
- ### the goal is to get every 1 element from sub arrays
166
-
167
- begin
168
- available_paths= Array.new
169
- return nil if relations_hash[self].nil?
170
- loop do
171
-
172
- ### defaults
173
- begin
174
- next_element_to_find = self
175
- delete_element = Hash.new
176
- one_chain = Array.new
177
- end
178
-
179
- ### chain element builder
180
- begin
181
- loop do
182
- if !relations_hash[next_element_to_find].nil? && relations_hash[next_element_to_find] != Array.new
183
-
184
- one_chain.push(relations_hash[next_element_to_find][0])
185
- if relations_hash[next_element_to_find].count > 1
186
- delete_element = Hash.new
187
- delete_element[next_element_to_find]= relations_hash[next_element_to_find][0]
188
- end
189
-
190
- next_element_to_find= relations_hash[next_element_to_find][0]
191
- else
192
- break
193
- end
194
- end
195
- end
196
-
197
- ### remove already checked tree
198
- begin
199
- if delete_element != Hash.new
200
- relations_hash[delete_element.keys[0]].delete_at(
201
- relations_hash[delete_element.keys[0]].index(
202
- delete_element[delete_element.keys[0]]))
203
- delete_element= Hash.new
204
- end
205
- end
206
-
207
- ### add new element to chains
208
- begin
209
- unless chains.include? one_chain
210
- chains.push one_chain
211
- else
212
- break
213
- end
214
- end
215
- end
216
-
217
- end
218
-
219
- end
220
-
221
- ### after format and check params for contains
222
- begin
223
-
224
- ### pre chains trim
225
- begin
226
-
227
- tmp_array= Array.new
228
- chains.each do |one_element|
229
- if !one_element.contains?(included)
230
- tmp_array.push one_element
231
- end
232
- end
233
- tmp_array.each do |one_element_to_delete|
234
- chains.delete_at(chains.index(one_element_to_delete))
235
- end
236
-
237
- end
238
-
239
- ### choose the shortest path
240
- begin
241
- chain_list_max_count= nil
242
- chains.each do |one_chain_list|
243
- counter= one_chain_list.count
244
- chain_list_max_count ||= (counter+1)
245
- if counter < chain_list_max_count
246
- return_array= one_chain_list
247
- counter= chain_list_max_count
248
- end
249
- end
250
- end
251
-
252
- ### reverse array
253
- begin
254
- return_array.reverse!
255
- end
256
-
257
- ### add new element as self for first
258
- begin
259
- return_array.push self
260
- end
261
-
262
-
263
- end
264
-
265
- return return_array
266
- end
267
-
268
- def __query_wrapper(*args)
269
-
270
- ### defaults
271
- begin
272
- return_data= nil
273
- ### params field
274
- field_hash= Hash.new
275
- ### models
276
- models_container= Array.new
277
- ### mother model
278
- mother_model= nil
279
- ### method_to_use
280
- method_to_use= Hash.new
281
-
282
- args.each do |one_argument|
283
- case one_argument.class.to_s.downcase
284
- when "string"
285
- begin
286
- field_hash['_id']= Moped::BSON::ObjectId.from_string(one_argument)
287
- rescue
288
- begin
289
- models_container.push one_argument.constantize
290
- rescue NameError
291
- #method_to_use= one_argument
292
- end
293
- end
294
- when "hash"
295
- begin
296
- one_argument.each do |key,value|
297
- if key.to_s == '_id'
298
- field_hash['_id']= Moped::BSON::ObjectId.from_string(value.to_s)
299
- else
300
- field_hash[key]=value
301
- end
302
- end
303
- end
304
- when "class"
305
- begin
306
- models_container.push one_argument
307
- end
308
- when "array"
309
- begin
310
- method_to_use= one_argument
311
- end
312
-
313
- end
314
- end
315
-
316
- end
317
-
318
- ### mother model find, and path generate
319
- begin
320
-
321
- full_path = self.getPaths(*models_container) || Array.new.push(self)
322
- mother_model= full_path.shift
323
-
324
- full_path.count.times do |index|
325
- full_path[index]= full_path[index].convert_model_name
326
- end
327
-
328
- end
329
-
330
- ### path trim
331
- begin
332
-
333
- deep_level = (full_path.count) || 0
334
- chains= full_path
335
-
336
- if full_path != Array.new && !full_path.nil?
337
- full_path= full_path.join('.')+'.'
338
- end
339
-
340
- if full_path == Array.new
341
- full_path= String.new
342
- end
343
-
344
- end
345
-
346
- ### start query
347
- begin
348
-
349
- ### build app query args
350
- begin
351
- query_fields= Hash.new()
352
- field_hash.each do |key,value|
353
- query_fields["#{full_path}#{key}"]= value
354
- end
355
- end
356
-
357
- ### do query ask from db
358
- begin
359
- if method_to_use[1][:arguments?]
360
- query_data = mother_model.__send__(
361
- method_to_use[0].to_s,
362
- query_fields)
363
- else
364
- query_data = mother_model.__send__(
365
- method_to_use[0].to_s)
366
- end
367
-
368
-
369
- end
370
-
371
- ### return data
372
- begin
373
- if deep_level == 0
374
- return_data=query_data
375
-
376
- else
377
-
378
- ### go down for embeds docs
379
- begin
380
-
381
- last_round = (chains.count-1)
382
- map_object = query_data
383
- return_array = Array.new
384
- chains.count.times do |deepness|
385
- begin
386
- children = Array.new
387
- if map_object.class == Array || map_object.class == Mongoid::Criteria
388
-
389
- map_object.each do |one_element_of_the_map_array|
390
- subclass_data = one_element_of_the_map_array.__send__(chains[deepness])
391
- if subclass_data.class == Array || subclass_data.class == Mongoid::Criteria
392
- subclass_data.each do |one_element_of_tmp_children|
393
- if deepness < last_round
394
- children.push one_element_of_tmp_children
395
- else
396
- return_array.push one_element_of_tmp_children
397
- end
398
- end
399
- else
400
- if deepness < last_round
401
- children.push subclass_data
402
- else
403
- return_array.push subclass_data
404
- end
405
- end
406
- end
407
- else
408
- subclass_data = map_object.__send__(chains[deepness])
409
- if subclass_data.class == Array || subclass_data.class == Mongoid::Criteria
410
- subclass_data.each do |one_element_of_tmp_children|
411
- if deepness < last_round
412
- children.push one_element_of_tmp_children
413
- else
414
- return_array.push one_element_of_tmp_children
415
- end
416
- end
417
- else
418
- if deepness < last_round
419
- children.push subclass_data
420
- else
421
- return_array.push subclass_data
422
- end
423
- end
424
- end
425
- map_object=children.uniq
426
- rescue NoMethodError => ex
427
- puts ex
428
- end
429
- end
430
-
431
- return_data= return_array
432
-
433
- end
434
-
435
- end
436
- end
437
-
438
- end
439
-
440
- return return_data
441
- end
442
-
443
- def _where(*args)
444
- self.__query_wrapper(['where',{:arguments? => true}],*args)
445
- end
446
- def _all(*args)
447
- self.__query_wrapper(['all',{:arguments? => false}],*args)
448
- end
449
-
450
- def _find(*args)
451
-
452
- ### pre validation
453
- begin
454
- if args[0].class != Moped::BSON::ObjectId && args[0].class != String
455
- raise ArgumentError, "id parameter must be id or ObjectId"
456
- end
457
- end
458
-
459
- ### Do the Gangnam style
460
- begin
461
- return_array = self._where('_id' => args[0])
462
- end
463
-
464
- #### After validation
465
- #begin
466
- # if return_array.count > 1
467
- # raise ArgumentError,"multiple finds, give more parameters"
468
- # end
469
- #end
470
-
471
- ### reformation
472
- begin
473
- return_array=return_array[0]
474
- end
475
-
476
- return return_array
477
- end
478
- def _find_by(*args)
479
-
480
- ### Do the Gangnam style
481
- begin
482
- return_array = self._where(*args).first
483
- end
484
-
485
- return return_array
486
- end
487
-
488
- alias :this_to_me :relation_connection_type
489
- alias :me_to_this :reverse_relation_connection_type
490
-
491
- end
492
- class Object
493
- def convert_model_name
494
-
495
- unless self.class == Class || self.class == String || self.class == NilClass
496
- raise ArgumentError, "invalid input, must be Class or String: => #{self.class} (#{self})"
497
- end
498
-
499
- case self.class.to_s.downcase
500
-
501
- when "class"
502
- begin
503
- return self.to_s.underscore.split('/').last
504
- end
505
- when "string"
506
- begin
507
- Mongoid::Document.classes.each do |one_model_name|
508
- if one_model_name.to_s.underscore.split('/').last == self.to_s
509
- return one_model_name.to_s.constantize
510
- end
511
- end
512
- end
513
-
514
- end
515
-
516
- end
517
- end