xamplr 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (142) hide show
  1. data/CHANGES.txt +13 -0
  2. data/LICENSE +3 -0
  3. data/README.rdoc +26 -0
  4. data/README.rdoc.orig +118 -0
  5. data/Rakefile +85 -0
  6. data/VERSION.yml +4 -0
  7. data/examples/random-people-shared-addresses/Makefile +16 -0
  8. data/examples/random-people-shared-addresses/batch-load-users.rb +83 -0
  9. data/examples/random-people-shared-addresses/find-mentions.rb +47 -0
  10. data/examples/random-people-shared-addresses/find-people-by-address.rb +104 -0
  11. data/examples/random-people-shared-addresses/optimise.rb +16 -0
  12. data/examples/random-people-shared-addresses/people.rb +35 -0
  13. data/examples/random-people-shared-addresses/query.rb +75 -0
  14. data/examples/random-people-shared-addresses/query2.rb +73 -0
  15. data/examples/random-people-shared-addresses/random-names.csv +10000 -0
  16. data/examples/random-people-shared-addresses/settings.rb +3 -0
  17. data/examples/random-people-shared-addresses/what-to-query-on.rb +82 -0
  18. data/examples/random-people-shared-addresses/xampl-gen.rb +36 -0
  19. data/examples/random-people-shared-addresses/xml/people.xml +14 -0
  20. data/examples/random-people/Makefile +16 -0
  21. data/examples/random-people/batch-load-users.rb +61 -0
  22. data/examples/random-people/optimise.rb +16 -0
  23. data/examples/random-people/people.rb +22 -0
  24. data/examples/random-people/query.rb +73 -0
  25. data/examples/random-people/query2.rb +73 -0
  26. data/examples/random-people/random-names.csv +10000 -0
  27. data/examples/random-people/rawtc.rb +91 -0
  28. data/examples/random-people/settings.rb +3 -0
  29. data/examples/random-people/what-to-query-on.rb +80 -0
  30. data/examples/random-people/xampl-gen.rb +36 -0
  31. data/examples/random-people/xml/people.xml +11 -0
  32. data/examples/read-testing/Makefile +10 -0
  33. data/examples/read-testing/load.rb +65 -0
  34. data/examples/read-testing/read.rb +51 -0
  35. data/examples/read-testing/rrr.rb +87 -0
  36. data/examples/read-testing/settings.rb +2 -0
  37. data/examples/read-testing/xampl-gen.rb +36 -0
  38. data/examples/read-testing/xml/text.xml +8 -0
  39. data/examples/tokyo-cabinet-experimental/expt-query.rb +42 -0
  40. data/examples/tokyo-cabinet-experimental/expt-query2.rb +42 -0
  41. data/examples/tokyo-cabinet-experimental/expt-query3.rb +41 -0
  42. data/examples/tokyo-cabinet-experimental/expt-reader.rb +32 -0
  43. data/examples/tokyo-cabinet-experimental/expt.rb +61 -0
  44. data/examples/tokyo-cabinet-experimental/xampl-gen.rb +36 -0
  45. data/examples/tokyo-cabinet-experimental/xml/tcx.xml +6 -0
  46. data/lib/xampl-generator.rb +3 -0
  47. data/lib/xampl.rb +3 -0
  48. data/lib/xamplr-generator.rb +10 -0
  49. data/lib/xamplr.rb +37 -0
  50. data/lib/xamplr/README-POSSIBLE-PROBLEMS +5 -0
  51. data/lib/xamplr/TODO +1 -0
  52. data/lib/xamplr/exceptions.rb +97 -0
  53. data/lib/xamplr/from-xml-orig.rb +350 -0
  54. data/lib/xamplr/from-xml.rb +439 -0
  55. data/lib/xamplr/gen-elements.xml +6230 -0
  56. data/lib/xamplr/gen.elements.xml +108 -0
  57. data/lib/xamplr/generate-elements.rb +15 -0
  58. data/lib/xamplr/generator.rb +5 -0
  59. data/lib/xamplr/graphml-out.rb +470 -0
  60. data/lib/xamplr/handwritten/example.rb +698 -0
  61. data/lib/xamplr/handwritten/hand-example.rb +533 -0
  62. data/lib/xamplr/handwritten/test-handwritten.rb +873 -0
  63. data/lib/xamplr/indexed-array.rb +115 -0
  64. data/lib/xamplr/mixins.rb +397 -0
  65. data/lib/xamplr/my.gen.elements.xml +461 -0
  66. data/lib/xamplr/notifications.rb +57 -0
  67. data/lib/xamplr/obsolete/fsdb.rb +62 -0
  68. data/lib/xamplr/persist-to-xml.rb +249 -0
  69. data/lib/xamplr/persistence.rb +522 -0
  70. data/lib/xamplr/persistence.rb.more_thread_safe +771 -0
  71. data/lib/xamplr/persistence.rb.partially_thread_safe +763 -0
  72. data/lib/xamplr/persister.rb +310 -0
  73. data/lib/xamplr/persisters/caches.rb +186 -0
  74. data/lib/xamplr/persisters/caching.rb +172 -0
  75. data/lib/xamplr/persisters/filesystem.rb +60 -0
  76. data/lib/xamplr/persisters/in-memory.rb +180 -0
  77. data/lib/xamplr/persisters/simple.rb +59 -0
  78. data/lib/xamplr/persisters/tokyo-cabinet.rb +641 -0
  79. data/lib/xamplr/simpleTemplate/danger.rx +4 -0
  80. data/lib/xamplr/simpleTemplate/obsolete/input-c.r4 +35 -0
  81. data/lib/xamplr/simpleTemplate/obsolete/play.r6.txt +12 -0
  82. data/lib/xamplr/simpleTemplate/obsolete/play_more.r6.txt +20 -0
  83. data/lib/xamplr/simpleTemplate/obsolete/test001.r5 +8 -0
  84. data/lib/xamplr/simpleTemplate/obsolete/test002.r5 +13 -0
  85. data/lib/xamplr/simpleTemplate/obsolete/test003.r5 +37 -0
  86. data/lib/xamplr/simpleTemplate/old/r6.000.rb +122 -0
  87. data/lib/xamplr/simpleTemplate/old/r6.001.rb +145 -0
  88. data/lib/xamplr/simpleTemplate/play.r6 +12 -0
  89. data/lib/xamplr/simpleTemplate/play_more.r6 +20 -0
  90. data/lib/xamplr/simpleTemplate/play_noblanks.r6 +21 -0
  91. data/lib/xamplr/simpleTemplate/playq.r6 +16 -0
  92. data/lib/xamplr/simpleTemplate/r6.rb +87 -0
  93. data/lib/xamplr/simpleTemplate/simple-template.rb +75 -0
  94. data/lib/xamplr/templates/child.template +47 -0
  95. data/lib/xamplr/templates/child_indexed.template +89 -0
  96. data/lib/xamplr/templates/child_modules.template +5 -0
  97. data/lib/xamplr/templates/element_classes.template +11 -0
  98. data/lib/xamplr/templates/element_data.template +282 -0
  99. data/lib/xamplr/templates/element_empty.template +285 -0
  100. data/lib/xamplr/templates/element_mixed.template +277 -0
  101. data/lib/xamplr/templates/element_simple.template +276 -0
  102. data/lib/xamplr/templates/package.template +26 -0
  103. data/lib/xamplr/test-support/Makefile +47 -0
  104. data/lib/xamplr/test-support/bench-cache.rb +80 -0
  105. data/lib/xamplr/test-support/bench-script.rb +21 -0
  106. data/lib/xamplr/test-support/bench.rb +116 -0
  107. data/lib/xamplr/test-support/bench2.rb +132 -0
  108. data/lib/xamplr/test-support/test-cache.rb +147 -0
  109. data/lib/xamplr/test-support/test-data/binding.xml +7 -0
  110. data/lib/xamplr/test-support/test-data/example.xml +14 -0
  111. data/lib/xamplr/test-support/test-data/internationalization-utf8.txt +1 -0
  112. data/lib/xamplr/test-support/test-data/labels.xml +37 -0
  113. data/lib/xamplr/test-support/test-data/labels001.xml +38 -0
  114. data/lib/xamplr/test-support/test-deep-change.rb +135 -0
  115. data/lib/xamplr/test-support/test-elements.rb +109 -0
  116. data/lib/xamplr/test-support/test-indexed-array.rb +169 -0
  117. data/lib/xamplr/test-support/test-misc.rb +73 -0
  118. data/lib/xamplr/test-support/test-names.rb +67 -0
  119. data/lib/xamplr/test-support/test-rollback.rb +106 -0
  120. data/lib/xamplr/test-support/test.rb +1504 -0
  121. data/lib/xamplr/to-ruby.rb +220 -0
  122. data/lib/xamplr/to-xml.rb +158 -0
  123. data/lib/xamplr/version.rb +67 -0
  124. data/lib/xamplr/visitor.rb +140 -0
  125. data/lib/xamplr/visitors.rb +573 -0
  126. data/lib/xamplr/xampl-generator.rb +533 -0
  127. data/lib/xamplr/xampl-hand-generated.rb +1535 -0
  128. data/lib/xamplr/xampl-module.rb +36 -0
  129. data/lib/xamplr/xampl-object-internals.rb +6 -0
  130. data/lib/xamplr/xampl-object.rb +202 -0
  131. data/lib/xamplr/xampl-persisted-object.rb +122 -0
  132. data/lib/xamplr/xml-text.rb +117 -0
  133. data/lib/xamplr/xml/document.xml +7 -0
  134. data/lib/xamplr/xml/elements.xml +101 -0
  135. data/lib/xamplr/xml/elements000.xml +73 -0
  136. data/lib/xamplr/xml/example.xml +23 -0
  137. data/lib/xamplr/xml/options.xml +12 -0
  138. data/lib/xamplr/xml/uche.xml +38 -0
  139. data/lib/xamplr/yEd-sample.graphml +300 -0
  140. data/test/test_helper.rb +10 -0
  141. data/test/xamplr_test.rb +7 -0
  142. metadata +245 -0
@@ -0,0 +1,533 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ module XamplExample
4
+
5
+ require "xamplr"
6
+
7
+ ### <things>
8
+ ### <thing pid=''>
9
+ ### <description kind=''>blah <emph>blah</emph> blah</description>
10
+ ### <keyValue id='' value=''/>
11
+ ### <stuff kind=''/>
12
+ ### <thing pid=''/>
13
+ ### <things/>
14
+ ### </thing>
15
+ ### </things>
16
+
17
+ module EmphAsChild
18
+
19
+ attr_accessor :emph_child
20
+
21
+ def init_emph_as_child
22
+ @emph_child = []
23
+ end
24
+
25
+ def add_emph(emph)
26
+ @children << emph
27
+ @emph_child << emph
28
+ emph.add_parent(self)
29
+ changed
30
+ return emph
31
+ end
32
+
33
+ def new_emph
34
+ emph = Emph.new
35
+ yield(emph) if block_given?
36
+ return add_emph(emph)
37
+ end
38
+ end
39
+
40
+ module StuffAsChild
41
+
42
+ attr_accessor :stuff_child
43
+
44
+ def init_stuff_as_child
45
+ @stuff_child = []
46
+ end
47
+
48
+ def add_stuff(stuff)
49
+ @children << stuff
50
+ @stuff_child << stuff
51
+ stuff.add_parent(self)
52
+ changed
53
+ return stuff
54
+ end
55
+
56
+ def new_stuff
57
+ stuff = Stuff.new
58
+ yield(stuff) if block_given?
59
+ return add_stuff(stuff)
60
+ end
61
+ end
62
+
63
+ module DescriptionAsChild
64
+
65
+ attr_accessor :description_child
66
+
67
+ def init_description_as_child
68
+ @description_child = []
69
+ end
70
+
71
+ def add_description(description)
72
+ @children << description
73
+ @description_child << description
74
+ description.add_parent(self)
75
+ changed
76
+ return description
77
+ end
78
+
79
+ def new_description
80
+ description = Description.new
81
+ yield(description) if block_given?
82
+ return add_description(description)
83
+ end
84
+ end
85
+
86
+ module ThingAsChild
87
+
88
+ attr_accessor :thing_child, :thing_map
89
+
90
+ def init_thing_as_child
91
+ @thing_child = []
92
+ @thing_map = {}
93
+ end
94
+
95
+ def add_thing(thing)
96
+ if (nil == thing.get_the_index) then
97
+ throw "no index attribute defined in : " << thing.to_xml
98
+ end
99
+ @children << thing
100
+ @thing_child << thing
101
+ @thing_map[thing.get_the_index] = thing
102
+ thing.add_parent(self)
103
+ changed
104
+ return thing
105
+ end
106
+
107
+ def new_thing(index)
108
+ thing = Thing.new
109
+ thing.set_the_index(index)
110
+ yield(thing) if block_given?
111
+ return add_thing(thing)
112
+ end
113
+ end
114
+
115
+ module KeyValueAsChild
116
+
117
+ attr_accessor :key_value_child, :key_value_map
118
+
119
+ def init_key_value_as_child
120
+ @key_value_child = []
121
+ @key_value_map = {}
122
+ end
123
+
124
+ def add_key_value(key_value)
125
+ if (nil == key_value.get_the_index) then
126
+ throw "no index attribute defined in : " << key_value.to_xml
127
+ end
128
+ @children << key_value
129
+ @key_value_child << key_value
130
+ @key_value_map[key_value.get_the_index] = key_value
131
+ key_value.add_parent(self)
132
+ changed
133
+ return key_value
134
+ end
135
+
136
+ def new_key_value(index)
137
+ key_value = KeyValue.new
138
+ key_value.set_the_index(index)
139
+ yield(key_value) if block_given?
140
+ return add_key_value(key_value)
141
+ end
142
+ end
143
+
144
+ class Emph
145
+ include Xampl::XamplObject
146
+ include Xampl::XamplWithSimpleContent
147
+
148
+ @@tag = "emph"
149
+ @@ns = "http://xampl.com/example"
150
+ @@ns_tag = "{http://xampl.com/example}emph"
151
+ @@module_name = "XamplExample"
152
+ @@attributes = [ ]
153
+
154
+ def Emph.tag
155
+ @@tag
156
+ end
157
+
158
+ def Emph.ns
159
+ @@ns
160
+ end
161
+
162
+ def Emph.ns_tag
163
+ @@ns_tag
164
+ end
165
+
166
+ def Emph.module_name
167
+ @@module_name
168
+ end
169
+
170
+ Xampl::FromXML::register(Emph::tag, Emph::ns_tag, Emph)
171
+
172
+ def initialize
173
+ super
174
+ init_xampl_object
175
+
176
+ changed
177
+ end
178
+
179
+ def append_to(other)
180
+ other.add_emph(self)
181
+ end
182
+
183
+ def tag
184
+ @@tag
185
+ end
186
+
187
+ def ns
188
+ @@ns
189
+ end
190
+
191
+ def ns_tag
192
+ @@ns_tag
193
+ end
194
+
195
+ def module_name
196
+ @@module_name
197
+ end
198
+
199
+ def attributes
200
+ @@attributes
201
+ end
202
+ end
203
+
204
+ class Stuff
205
+ include Xampl::XamplObject
206
+ include Xampl::XamplWithoutContent
207
+
208
+ @@tag = "stuff"
209
+ @@ns = "http://xampl.com/example"
210
+ @@ns_tag = "{http://xampl.com/example}stuff"
211
+ @@module_name = "XamplExample"
212
+ @@attributes = [
213
+ [:@kind, "kind"],
214
+ [:@special, "special", "http://xampl.com/example/special"]
215
+ ]
216
+
217
+ attr_reader :kind, :special
218
+
219
+ def Stuff.tag
220
+ @@tag
221
+ end
222
+
223
+ def Stuff.ns
224
+ @@ns
225
+ end
226
+
227
+ def Stuff.ns_tag
228
+ @@ns_tag
229
+ end
230
+
231
+ def Stuff.module_name
232
+ @@module_name
233
+ end
234
+
235
+ Xampl::FromXML::register(Stuff::tag, Stuff::ns_tag, Stuff)
236
+
237
+ def kind=(v)
238
+ changed
239
+ @kind = v
240
+ end
241
+
242
+ def special=(v)
243
+ changed
244
+ @special = v
245
+ end
246
+
247
+ def initialize
248
+ super
249
+ init_xampl_object
250
+
251
+ @kind = nil if not defined? @kind
252
+ @special = nil if not defined? @special
253
+
254
+ changed
255
+ end
256
+
257
+ def append_to(other)
258
+ other.add_stuff(self)
259
+ end
260
+
261
+ def tag
262
+ @@tag
263
+ end
264
+
265
+ def ns
266
+ @@ns
267
+ end
268
+
269
+ def ns_tag
270
+ @@ns_tag
271
+ end
272
+
273
+ def module_name
274
+ @@module_name
275
+ end
276
+
277
+ def attributes
278
+ @@attributes
279
+ end
280
+ end
281
+
282
+ class Description
283
+ include Xampl::XamplObject
284
+ include Xampl::XamplWithMixedContent
285
+
286
+ @@tag = "description"
287
+ @@ns = "http://xampl.com/example"
288
+ @@ns_tag = "{http://xampl.com/example}description"
289
+ @@module_name = "XamplExample"
290
+ @@attributes = [
291
+ [:@kind, "kind"],
292
+ ]
293
+
294
+ include EmphAsChild
295
+
296
+ attr_reader :kind
297
+
298
+ def Description.tag
299
+ @@tag
300
+ end
301
+
302
+ def Description.ns
303
+ @@ns
304
+ end
305
+
306
+ def Description.ns_tag
307
+ @@ns_tag
308
+ end
309
+
310
+ def Description.module_name
311
+ @@module_name
312
+ end
313
+
314
+ Xampl::FromXML::register(Description::tag, Description::ns_tag, Description)
315
+
316
+ def kind=(v)
317
+ changed
318
+ @kind = v
319
+ end
320
+
321
+ def initialize
322
+ super
323
+ init_xampl_object
324
+
325
+ @kind = nil if not defined? @kind
326
+
327
+ init_mixed_content
328
+ init_emph_as_child
329
+
330
+ changed
331
+ end
332
+
333
+ def append_to(other)
334
+ other.add_description(self)
335
+ end
336
+
337
+ def tag
338
+ @@tag
339
+ end
340
+
341
+ def ns
342
+ @@ns
343
+ end
344
+
345
+ def ns_tag
346
+ @@ns_tag
347
+ end
348
+
349
+ def module_name
350
+ @@module_name
351
+ end
352
+
353
+ def attributes
354
+ @@attributes
355
+ end
356
+ end
357
+
358
+ class Thing
359
+ include Xampl::XamplPersistedObject
360
+ include Xampl::XamplWithDataContent
361
+
362
+ @@tag = "thing"
363
+ @@ns = "http://xampl.com/example"
364
+ @@ns_tag = "{http://xampl.com/example}thing"
365
+ @@module_name = "XamplExample"
366
+ @@attributes = [ [ :@pid, "pid" ] ]
367
+
368
+ include StuffAsChild
369
+ include DescriptionAsChild
370
+ include ThingAsChild
371
+ include KeyValueAsChild
372
+
373
+ attr_reader :pid
374
+
375
+ def Thing.tag
376
+ @@tag
377
+ end
378
+
379
+ def Thing.ns
380
+ @@ns
381
+ end
382
+
383
+ def Thing.ns_tag
384
+ @@ns_tag
385
+ end
386
+
387
+ def Thing.module_name
388
+ @@module_name
389
+ end
390
+
391
+ Xampl::FromXML::register(Thing::tag, Thing::ns_tag, Thing)
392
+
393
+ def pid=(v)
394
+ changed
395
+ @pid = v
396
+ end
397
+
398
+ def initialize
399
+ super
400
+ init_xampl_object
401
+
402
+ @pid = nil if not defined? @pid
403
+
404
+ init_data_content
405
+
406
+ init_stuff_as_child
407
+ init_description_as_child
408
+ init_thing_as_child
409
+ init_key_value_as_child
410
+
411
+ changed
412
+ end
413
+
414
+ def append_to(other)
415
+ other.add_thing(self)
416
+ end
417
+
418
+ def tag
419
+ @@tag
420
+ end
421
+
422
+ def ns
423
+ @@ns
424
+ end
425
+
426
+ def ns_tag
427
+ @@ns_tag
428
+ end
429
+
430
+ def module_name
431
+ @@module_name
432
+ end
433
+
434
+ def attributes
435
+ @@attributes
436
+ end
437
+
438
+ def get_the_index
439
+ @pid
440
+ end
441
+
442
+ def set_the_index(index)
443
+ @pid = index
444
+ end
445
+ end
446
+
447
+ class KeyValue
448
+ include Xampl::XamplObject
449
+ include Xampl::XamplWithoutContent
450
+
451
+ @@tag = "keyValue"
452
+ @@ns = "http://xampl.com/example"
453
+ @@ns_tag = "{http://xampl.com/example}keyValue"
454
+ @@module_name = "XamplExample"
455
+ @@attributes = [
456
+ [:@id, "id"],
457
+ [:@value, "value"]
458
+ ]
459
+
460
+ attr_reader :id, :value
461
+
462
+ def KeyValue.tag
463
+ @@tag
464
+ end
465
+
466
+ def KeyValue.ns
467
+ @@ns
468
+ end
469
+
470
+ def KeyValue.ns_tag
471
+ @@ns_tag
472
+ end
473
+
474
+ def KeyValue.module_name
475
+ @@module_name
476
+ end
477
+
478
+ Xampl::FromXML::register(KeyValue::tag, KeyValue::ns_tag, KeyValue)
479
+
480
+ def id=(v)
481
+ changed
482
+ @id = v
483
+ end
484
+
485
+ def value=(v)
486
+ changed
487
+ @value = v
488
+ end
489
+
490
+ def initialize
491
+ super
492
+ init_xampl_object
493
+
494
+ @id = nil if not defined? @id
495
+ @value = nil if not defined? @value
496
+
497
+ changed
498
+ end
499
+
500
+ def append_to(other)
501
+ other.add_key_value(self)
502
+ end
503
+
504
+ def tag
505
+ @@tag
506
+ end
507
+
508
+ def ns
509
+ @@ns
510
+ end
511
+
512
+ def ns_tag
513
+ @@ns_tag
514
+ end
515
+
516
+ def module_name
517
+ @@module_name
518
+ end
519
+
520
+ def attributes
521
+ @@attributes
522
+ end
523
+
524
+ def get_the_index
525
+ @id
526
+ end
527
+
528
+ def set_the_index(index)
529
+ @id = index
530
+ end
531
+ end
532
+ end
533
+