ontology 0.0.1

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.
Files changed (61) hide show
  1. data/LICENSE +19 -0
  2. data/NEWS.md +7 -0
  3. data/README.md +36 -0
  4. data/bin/ontology +83 -0
  5. data/doc/Change_Log_txt.html +97 -0
  6. data/doc/Gemfile.html +93 -0
  7. data/doc/LICENSE.html +111 -0
  8. data/doc/Object.html +230 -0
  9. data/doc/Ontology.html +791 -0
  10. data/doc/Ontology/Leaf.html +370 -0
  11. data/doc/bin/ontology.html +193 -0
  12. data/doc/created.rid +17 -0
  13. data/doc/images/add.png +0 -0
  14. data/doc/images/brick.png +0 -0
  15. data/doc/images/brick_link.png +0 -0
  16. data/doc/images/bug.png +0 -0
  17. data/doc/images/bullet_black.png +0 -0
  18. data/doc/images/bullet_toggle_minus.png +0 -0
  19. data/doc/images/bullet_toggle_plus.png +0 -0
  20. data/doc/images/date.png +0 -0
  21. data/doc/images/delete.png +0 -0
  22. data/doc/images/find.png +0 -0
  23. data/doc/images/loadingAnimation.gif +0 -0
  24. data/doc/images/macFFBgHack.png +0 -0
  25. data/doc/images/package.png +0 -0
  26. data/doc/images/page_green.png +0 -0
  27. data/doc/images/page_white_text.png +0 -0
  28. data/doc/images/page_white_width.png +0 -0
  29. data/doc/images/plugin.png +0 -0
  30. data/doc/images/ruby.png +0 -0
  31. data/doc/images/tag_blue.png +0 -0
  32. data/doc/images/tag_green.png +0 -0
  33. data/doc/images/transparent.png +0 -0
  34. data/doc/images/wrench.png +0 -0
  35. data/doc/images/wrench_orange.png +0 -0
  36. data/doc/images/zoom.png +0 -0
  37. data/doc/index.html +88 -0
  38. data/doc/js/darkfish.js +153 -0
  39. data/doc/js/jquery.js +18 -0
  40. data/doc/js/navigation.js +142 -0
  41. data/doc/js/search.js +94 -0
  42. data/doc/js/search_index.js +1 -0
  43. data/doc/js/searcher.js +228 -0
  44. data/doc/rdoc.css +543 -0
  45. data/doc/table_of_contents.html +110 -0
  46. data/lib/ontology.rb +11 -0
  47. data/lib/ontology/error_message.rb +17 -0
  48. data/lib/ontology/leaf.rb +57 -0
  49. data/lib/ontology/load_config_yaml.rb +13 -0
  50. data/lib/ontology/make_glossary.rb +128 -0
  51. data/lib/ontology/write_file.rb +10 -0
  52. data/lib/ontology/yaml_utils.rb +74 -0
  53. data/ontology.gemspec +32 -0
  54. data/spec/config.yaml +3 -0
  55. data/spec/decompose_md_file_spec.rb +417 -0
  56. data/spec/leaf_spec.rb +13 -0
  57. data/spec/test.md +5 -0
  58. data/spec/test_make_glossary.rb +68 -0
  59. data/spec/write_md_file_spec.rb +23 -0
  60. data/spec/yaml_utils_spec.rb +39 -0
  61. metadata +109 -0
@@ -0,0 +1,3 @@
1
+
2
+
3
+ a voir n est pas trouve
@@ -0,0 +1,417 @@
1
+ # encoding: utf-8
2
+ require 'ontology'
3
+ include Ontology
4
+
5
+ describe 'testing the splitting of an md file in yaml or equivalent parts and of the diagnostic of the type of the part' do
6
+ before :each do
7
+ @config_yaml = <<EOF
8
+ ontology:
9
+ languages: [fr, en, de]
10
+
11
+ glossaries: [general_dictionary, glossary_2]
12
+
13
+ general_dictionary:
14
+ source: glossary
15
+ default_language: any
16
+ destination:
17
+ fr: content/fr/glossaire
18
+ de: content/de/glossarium
19
+ en: content/en/glossary
20
+
21
+ glossary_2:
22
+ source: glossary_tech
23
+ default_language: en
24
+ destination:
25
+ fr: content/fr/glossaire_tech
26
+ en: content/en/glossary_tech
27
+
28
+ EOF
29
+
30
+ end
31
+
32
+ it "should split this file in 2 yaml parts" do
33
+ @x= <<EOF
34
+ ---
35
+ aaaaa
36
+ ---
37
+ kkk
38
+ lll
39
+ ---
40
+
41
+ ---
42
+
43
+
44
+ ---
45
+
46
+ ---
47
+
48
+ ---
49
+
50
+ ---
51
+
52
+
53
+ EOF
54
+ result = []
55
+ iterate_yaml_part(@x) {|st|
56
+ st.length.should > 0
57
+ result << st
58
+ }
59
+ result[0].class.should == String
60
+ result[1].class.should == String
61
+ result.length.should == 2
62
+
63
+ end
64
+
65
+ it "should split this file in 3 yaml parts including the last one" do
66
+ @x= <<EOF
67
+ ---
68
+ aaaaa
69
+ ---
70
+ kkk
71
+ lll
72
+ ---
73
+
74
+ ---
75
+
76
+
77
+ ---
78
+
79
+ ---
80
+
81
+ ---
82
+
83
+ ---
84
+ aaaadsd
85
+
86
+ EOF
87
+ result = []
88
+ iterate_yaml_part(@x) {|st|
89
+ st.length.should > 0
90
+ result << st
91
+ }
92
+ result[0].class.should == String
93
+ result[1].class.should == String
94
+ result[2].class.should == String
95
+ result.length.should == 3
96
+
97
+ end
98
+
99
+ it "this one should not yield" do
100
+ @x= <<EOF
101
+ ---
102
+
103
+ ---
104
+
105
+ ---
106
+
107
+ ---
108
+
109
+
110
+ ---
111
+
112
+ ---
113
+
114
+ ---
115
+
116
+ ---
117
+
118
+ EOF
119
+ result = []
120
+ iterate_yaml_part(@x) {|st|
121
+ st.length.should > 0
122
+ result << st
123
+ }
124
+ result.length.should == 0
125
+
126
+ end
127
+
128
+ it "this one should also not yield" do
129
+ @x= <<EOF
130
+
131
+
132
+
133
+
134
+
135
+
136
+
137
+
138
+ EOF
139
+ result = []
140
+ iterate_yaml_part(@x) {|st|
141
+ st.length.should > 0
142
+ result << st
143
+ }
144
+ result.length.should == 0
145
+
146
+ end
147
+
148
+ it "this one should not include the last --- (without return)" do
149
+ @x= "--- \naaaaaaaaaaaaaa\n--- \t"
150
+ result = []
151
+ iterate_yaml_part(@x) {|st|
152
+ st.length.should > 0
153
+ result << st
154
+ }
155
+ result.length.should == 1
156
+ result[0].length.should < 17
157
+ end
158
+
159
+ it "should decompose a multi-language md string in an Hash with 3 entries" do
160
+ @x = <<EOF
161
+
162
+ [fr]
163
+
164
+ quid article à ce sujet???? lien position ??
165
+
166
+ [en]
167
+
168
+ ss
169
+
170
+ [de]
171
+
172
+ deutsch Sekundärwährung
173
+
174
+
175
+ EOF
176
+ result = decompose_as_multi_lang_md(@x)
177
+ result.class.should == Hash
178
+ result.keys.length.should == 3
179
+ end
180
+
181
+ it "should fail to decompose this string as a multi-language md string" do
182
+ @x = <<EOF
183
+
184
+ rien ne permet de décomposer ceci par langue
185
+
186
+
187
+
188
+ EOF
189
+ lambda { decompose_as_multi_lang_md(@x) }.should raise_exception
190
+ end
191
+
192
+ it "empty languages entries generate an empty Hash entry" do
193
+ @x = <<EOF
194
+
195
+ [fr]
196
+
197
+ quid article à ce sujet???? lien position ??
198
+
199
+ [en]
200
+
201
+
202
+ [de]
203
+
204
+ deutsch Sekundärwährung
205
+
206
+
207
+ EOF
208
+ result = decompose_as_multi_lang_md(@x)
209
+ result.class.should == Hash
210
+ result.keys.length.should == 3
211
+ result[:en].should == "\n\n\n"
212
+ end
213
+
214
+ it "should render an any version if the text is not defined for the language requested" do
215
+ h = Hash.new(&Lang_block)
216
+ h[:any] = 'My message'
217
+ h[:fr].should == 'My message'
218
+ end
219
+
220
+ it "should render abort if the text is not defined for the language requested and no :any version is supplied" do
221
+ h = Hash.new(&Lang_block)
222
+ h[:de] = 'My message'
223
+ h.default = 'test'
224
+ puts "h[:fr] #{h[:fr]}"
225
+ lambda { h[:fr] }.should raise_exception
226
+ end
227
+
228
+ it 'this should correctly decompose this - somewhat nasty - file' do
229
+ @x= <<EOF
230
+ ---
231
+ fr: devise complémentaire
232
+ en: complementary currency
233
+ de: Komplementärwährung
234
+ generic_id: complementary-currency
235
+ markdown: basic
236
+
237
+ ---
238
+
239
+ [fr]
240
+
241
+ quid article à ce sujet???? lien position ??
242
+
243
+ [en]
244
+
245
+ ss
246
+
247
+ [de]
248
+
249
+ deutsch Sekundärwährung
250
+
251
+ ---
252
+ title:
253
+ fr: devise secondaire
254
+ en: secondary currency
255
+ de: Sekundärwährung
256
+ order:
257
+ fr: devise secondaire
258
+ en: secondary currency
259
+ de: Sekundärwährung
260
+
261
+
262
+ generic_id: secondary-currency
263
+ markdown: basic
264
+ cf: complementary-currency
265
+
266
+ ---
267
+
268
+ [any]
269
+ any text for test purposes
270
+
271
+ [fr]
272
+ sauf pour le français
273
+ ---
274
+ any: beki
275
+
276
+ generic_id: beki
277
+ ---
278
+ here the picture
279
+ ---
280
+ [fr]
281
+ Le Beki est la devise régionale en cours de développement dans le canton de Redange. Il s'agit de la seule devise régionale luxembourgeoise. http://beki.lu/fr
282
+ [de]
283
+ Der Beki ist eine im Kanton Redingen entwickelte Regionalwährung. Es handelt sich um die einzige luxemburger Regionalwährung. http://beki.lu/
284
+ [en]
285
+ The Beki is a regional currency developped in the Canton Redingen. It is the only luxemburgish regional currency. http://beki.lu/
286
+
287
+ EOF
288
+
289
+ load_config_pars @config_yaml
290
+
291
+ leafs = []
292
+ generate_leaf_init_struct(@x){|hash_struct|
293
+ leafs << Leaf.new(hash_struct, :general_dictionary)
294
+ }
295
+ leafs.length.should == 3
296
+ puts "leafs0.class #{leafs[0].class}, #{leafs[0].my_hash.class}"
297
+ leafs[0].my_hash[:content].length.should == 1
298
+ leafs[1].my_hash[:content].length.should == 1
299
+ leafs[2].my_hash[:content].length.should == 2
300
+
301
+ Base_dir = '/egal'
302
+
303
+ leafs[0].generate_markdown_file :fr, 'my_dir'
304
+ leafs[1].generate_markdown_file :fr, 'my_dir'
305
+ puts leafs[2].my_hash
306
+ leafs[2].generate_markdown_file :fr, 'my_dir'
307
+ end
308
+
309
+
310
+ it 'this should correctly decompose this file, knowing that :title is not linked to a language or :any' do
311
+
312
+ @x = <<EOF
313
+ ---
314
+ order: Taleb, Nassim Nicholas
315
+
316
+ title: Nassim Nicholas Taleb
317
+
318
+ generic_id: nassim-taleb
319
+ markdown: basic
320
+ ---
321
+
322
+ [fr]
323
+
324
+ Nassim Taleb est un mathématicien, philosophe et trader.
325
+
326
+ [de]
327
+
328
+ Nassim Taleb ist ein Mathematiker, Philosoph und Händler
329
+
330
+ [en]
331
+
332
+ Nassim Taleb is a mathematician, philosopher and trader
333
+ EOF
334
+
335
+ load_config_pars @config_yaml
336
+
337
+ leafs = []
338
+ generate_leaf_init_struct(@x){|hash_struct|
339
+ leafs << Leaf.new(hash_struct, :general_dictionary)
340
+ }
341
+ leafs.length.should == 1
342
+ puts "leafs0.class #{leafs[0].class}, #{leafs[0].my_hash.class}"
343
+ leafs[0].my_hash[:content].length.should == 1
344
+ Base_dir = '/egal'
345
+
346
+ puts leafs[0].my_hash
347
+ leafs[0].generate_markdown_file :fr, 'my_dir'
348
+ end
349
+
350
+
351
+ it 'this should correctly decompose this file, despite the : after Chinese Truth' do
352
+ @x = <<EOF
353
+ ---
354
+ title: Olson, Mancur
355
+ generic_id: mancur-olsson
356
+ ---
357
+ The stationary bandit inventor
358
+
359
+ Chinese Truth:
360
+
361
+ * best governement is the one people forget
362
+ * the second best is the one they love
363
+ * the worser is the one they hate
364
+ * the worst, the one they rebell against
365
+ ---
366
+ EOF
367
+
368
+ load_config_pars @config_yaml
369
+
370
+ leafs = []
371
+ generate_leaf_init_struct(@x){|hash_struct|
372
+ leafs << Leaf.new(hash_struct, :general_dictionary)
373
+ }
374
+ leafs.length.should == 1
375
+ puts "leafs0.class #{leafs[0].class}, #{leafs[0].my_hash.class}"
376
+ leafs[0].my_hash[:content].length.should == 1
377
+ Base_dir = '/egal'
378
+
379
+ puts leafs[0].my_hash
380
+ leafs[0].generate_markdown_file :fr, 'my_dir'
381
+ end
382
+
383
+ it 'this should correctly decompose this file, despite the * before Minsky Marvin' do
384
+ @x = <<EOF
385
+
386
+ ---
387
+ fr: Monétarisation
388
+ en: Monetarization
389
+ de: Monetarisierung
390
+ generic_id: monetarization
391
+ ---
392
+ a very powerfull optimization factor
393
+
394
+ hitting it's limits
395
+ ---
396
+ * Minsky Marvin
397
+
398
+ bubble, speculation, Ponzi scheme
399
+ EOF
400
+
401
+
402
+ load_config_pars @config_yaml
403
+
404
+ leafs = []
405
+ generate_leaf_init_struct(@x){|hash_struct|
406
+ leafs << Leaf.new(hash_struct, :general_dictionary)
407
+ }
408
+ leafs.length.should == 1
409
+ puts "leafs0.class #{leafs[0].class}, #{leafs[0].my_hash.class}"
410
+ leafs[0].my_hash[:content].length.should == 1
411
+ Base_dir = '/egal'
412
+
413
+ puts leafs[0].my_hash
414
+ leafs[0].generate_markdown_file :fr, 'my_dir'
415
+ end
416
+
417
+ end
@@ -0,0 +1,13 @@
1
+ # encoding: utf-8
2
+ require 'ontology'
3
+ include Ontology
4
+ describe 'testing leaf' do
5
+ before :each do
6
+ end
7
+
8
+ it 'this should decompose the file in --- parts' do
9
+ x = Leaf.new()
10
+ end
11
+
12
+ end
13
+
@@ -0,0 +1,5 @@
1
+ ##Test
2
+
3
+ überlegen ob UTF-8 wirklich geht, à l'école, on teste!
4
+
5
+ This will be enough!
@@ -0,0 +1,68 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+
5
+ $: << '.'
6
+
7
+ require 'make_glossary'
8
+
9
+
10
+ Str1 = <<EOF
11
+ fr: devise complémentaire
12
+ en: complementary currency
13
+ de: Komplementärwährung
14
+ generic_id: complementary-currency
15
+ markdown: basic
16
+ EOF
17
+
18
+ Str2 = <<EOF
19
+
20
+ [fr]
21
+
22
+ quid article à ce sujet???? lien position ??
23
+
24
+ [en]
25
+
26
+ ss
27
+
28
+ [de]
29
+
30
+ deutsch Sekundärwährung
31
+ EOF
32
+
33
+ Str3 = <<EOF
34
+ title:
35
+ fr: devise secondaire
36
+ en: secondary currency
37
+ de: Sekundärwährung
38
+ sort:
39
+ fr: devise secondaire
40
+ en: currency (secondary)
41
+ de: Sekundärwährung
42
+
43
+
44
+ generic_id: secondary-currency
45
+ markdown: basic
46
+ cf: complementary-currency
47
+ EOF
48
+
49
+ Str4 = <<EOF
50
+
51
+ [any]
52
+ any text for test purposes
53
+ [fr]
54
+ sauf pour le français
55
+ EOF
56
+
57
+
58
+ leaf = Leaf.new(Str1, Str2)
59
+ puts leaf.inspect
60
+ leaf.export_markdowns
61
+
62
+ leaf = Leaf.new(Str3, Str4)
63
+ puts leaf.inspect
64
+ leaf.export_markdowns
65
+
66
+ def f(x = nil)
67
+ return 2
68
+ end