dyndoc-ruby-core 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. checksums.yaml +7 -0
  2. data/dyndoc/.DS_Store +0 -0
  3. data/dyndoc/Dyn/.postload +1 -0
  4. data/dyndoc/Dyn/.preload +1 -0
  5. data/dyndoc/Dyn/After.dyn +3 -0
  6. data/dyndoc/Dyn/Base.dyn +18 -0
  7. data/dyndoc/Dyn/Minimum.dyn +20 -0
  8. data/dyndoc/Model/Html/DefaultPost_html.dyn +5 -0
  9. data/dyndoc/Model/Html/DefaultPre_html.dyn +15 -0
  10. data/dyndoc/Model/Odt/DefaultPost_content.xml +3 -0
  11. data/dyndoc/Model/Odt/DefaultPost_tmpl_content.xml +3 -0
  12. data/dyndoc/Model/Odt/DefaultPre_content.xml +8 -0
  13. data/dyndoc/Model/Odt/DefaultPre_tmpl_content.xml +8 -0
  14. data/dyndoc/Model/Tex/ContentPost_tmpl.tex +1 -0
  15. data/dyndoc/Model/Tex/ContentPre_tmpl.tex +6 -0
  16. data/dyndoc/Model/Tex/DefaultPost_tmpl.tex +73 -0
  17. data/dyndoc/Model/Tex/DefaultPre_tmpl.tex +16 -0
  18. data/dyndoc/Model/Ttm/DefaultPost_tmpl.ttm +3 -0
  19. data/dyndoc/Model/Ttm/DefaultPre_tmpl.ttm +16 -0
  20. data/dyndoc/Std/Array.dyn +96 -0
  21. data/dyndoc/Std/Composer.dyn +38 -0
  22. data/dyndoc/Std/DevTag.dyn +101 -0
  23. data/dyndoc/Std/DynVar.dyn +23 -0
  24. data/dyndoc/Std/File.dyn +55 -0
  25. data/dyndoc/Std/Git.dyn +34 -0
  26. data/dyndoc/Std/List.dyn +46 -0
  27. data/dyndoc/Std/OOP.dyn +32 -0
  28. data/dyndoc/Std/Signal.dyn +18 -0
  29. data/dyndoc/Std/String.dyn +22 -0
  30. data/dyndoc/Std/Styles.dyn +1 -0
  31. data/dyndoc/Std/Test.dyn +282 -0
  32. data/dyndoc/Std/Utils.dyn +42 -0
  33. data/dyndoc/Std/Verb.dyn +5 -0
  34. data/dyndoc/Style/Notation/Math.dyn +7 -0
  35. data/dyndoc/Style/Notation/Stat/Classic.dyn +8 -0
  36. data/dyndoc/Style/Notation/Stat/Cqls.dyn +44 -0
  37. data/dyndoc/Style/Text/Std.dyn +5 -0
  38. data/dyndoc/Style/Text/StdAlias.dyn +3 -0
  39. data/dyndoc/Style/Text/StdTex.dyn +17 -0
  40. data/dyndoc/Style/Text/Txt.dyn +1 -0
  41. data/dyndoc/Tex/.postload +1 -0
  42. data/dyndoc/Tex/.preload +1 -0
  43. data/dyndoc/Tex/10pt_tmpl.tex +1 -0
  44. data/dyndoc/Tex/11pt_tmpl.tex +1 -0
  45. data/dyndoc/Tex/12pt_tmpl.tex +1 -0
  46. data/dyndoc/Tex/Article_tmpl.tex +1 -0
  47. data/dyndoc/Tex/Beamer.dyn_tex +35 -0
  48. data/dyndoc/Tex/BeamerHandout_tmpl.tex +2 -0
  49. data/dyndoc/Tex/Book_tmpl.tex +1 -0
  50. data/dyndoc/Tex/DefaultFirst_tmpl.tex +1 -0
  51. data/dyndoc/Tex/DefaultLast_tmpl.tex +8 -0
  52. data/dyndoc/Tex/Default_tmpl.tex +9 -0
  53. data/dyndoc/Tex/First_tmpl.tex +8 -0
  54. data/dyndoc/Tex/Fr_tmpl.tex +17 -0
  55. data/dyndoc/Tex/Header_tmpl.tex +3 -0
  56. data/dyndoc/Tex/InclGraph_tmpl.tex +19 -0
  57. data/dyndoc/Tex/InclSpatProc_tmpl.tex +70 -0
  58. data/dyndoc/Tex/InclSumMI_tmpl.tex +4 -0
  59. data/dyndoc/Tex/LargeA4_tmpl.tex +5 -0
  60. data/dyndoc/Tex/Last_tmpl.tex +1 -0
  61. data/dyndoc/Tex/Option_tmpl.tex +8 -0
  62. data/dyndoc/Tex/Png_tmpl.tex +1 -0
  63. data/dyndoc/Tex/RefCite2_tmpl.tex +16 -0
  64. data/dyndoc/Tex/RefCite_tmpl.tex +16 -0
  65. data/dyndoc/Tex/Report_tmpl.tex +1 -0
  66. data/dyndoc/Tex/Theorem_tmpl.tex +14 -0
  67. data/dyndoc/Tools/.DS_Store +0 -0
  68. data/dyndoc/Tools/Atom.dyn/index.dyn +42 -0
  69. data/dyndoc/Tools/AtomDyndocker.dyn/index.dyn +43 -0
  70. data/dyndoc/Tools/R/Fig.dyn +144 -0
  71. data/dyndoc/Tools/R/Tools.dyn +344 -0
  72. data/dyndoc/Tools/Tex/Beamer.dyn +204 -0
  73. data/dyndoc/Tools/Tex/BeamerSlide.dyn_tex +199 -0
  74. data/dyndoc/Tools/Tex/Pgf.dyn +115 -0
  75. data/dyndoc/Tools/Tex/Table.dyn +278 -0
  76. data/dyndoc/Tools/Tex/Tools.dyn +37 -0
  77. data/dyndoc/Tools/Tex/Verb.dyn +77 -0
  78. data/dyndoc/Tools/Web/.DS_Store +0 -0
  79. data/dyndoc/Tools/Web/Ace.dyn +54 -0
  80. data/dyndoc/Tools/Web/Code.dyn +129 -0
  81. data/dyndoc/Tools/Web/DHtmlX.dyn +39 -0
  82. data/dyndoc/Tools/Web/DataTable.dyn_html +354 -0
  83. data/dyndoc/Tools/Web/Html.dyn +286 -0
  84. data/dyndoc/Tools/Web/Html/JQuery.dyn +123 -0
  85. data/dyndoc/Tools/Web/Html/Styles.dyn +4 -0
  86. data/dyndoc/Tools/Web/JQueryTools.dyn +87 -0
  87. data/dyndoc/Tools/Web/Layout.dyn +86 -0
  88. data/dyndoc/Tools/Web/Layout/CQLS.dyn +6 -0
  89. data/dyndoc/Tools/Web/Layout/LJK.dyn +41 -0
  90. data/dyndoc/Tools/Web/TabBar.dyn +37 -0
  91. data/dyndoc/Tools/Web/Ttm.dyn +20 -0
  92. data/dyndoc/Tools/Web/Txtl.dyn +14 -0
  93. data/lib/dyndoc-core.rb +59 -0
  94. data/lib/dyndoc/base/envir.rb +541 -0
  95. data/lib/dyndoc/base/filter/call.rb +127 -0
  96. data/lib/dyndoc/base/filter/filter_mngr.rb +637 -0
  97. data/lib/dyndoc/base/filter/server.rb +882 -0
  98. data/lib/dyndoc/base/filters.rb +3 -0
  99. data/lib/dyndoc/base/helpers.rb +9 -0
  100. data/lib/dyndoc/base/helpers/core.rb +32 -0
  101. data/lib/dyndoc/base/helpers/parser.rb +188 -0
  102. data/lib/dyndoc/base/scanner.rb +886 -0
  103. data/lib/dyndoc/base/tags.rb +4 -0
  104. data/lib/dyndoc/base/tags/keys_mngr.rb +401 -0
  105. data/lib/dyndoc/base/tags/part_tag.rb +194 -0
  106. data/lib/dyndoc/base/tags/tag_mngr.rb +125 -0
  107. data/lib/dyndoc/base/tags/user_tag.rb +216 -0
  108. data/lib/dyndoc/base/tmpl.rb +6 -0
  109. data/lib/dyndoc/base/tmpl/eval.rb +581 -0
  110. data/lib/dyndoc/base/tmpl/extension.rb +337 -0
  111. data/lib/dyndoc/base/tmpl/manager.rb +450 -0
  112. data/lib/dyndoc/base/tmpl/oop.rb +57 -0
  113. data/lib/dyndoc/base/tmpl/parse_do.rb +2446 -0
  114. data/lib/dyndoc/base/tmpl/rbenvir.rb +54 -0
  115. data/lib/dyndoc/base/utils.rb +367 -0
  116. data/lib/dyndoc/common/dynArray.rb +234 -0
  117. data/lib/dyndoc/common/file.rb +52 -0
  118. data/lib/dyndoc/common/init.rb +2 -0
  119. data/lib/dyndoc/common/tilt.rb +149 -0
  120. data/lib/dyndoc/common/utils.rb +61 -0
  121. data/lib/dyndoc/common/uv.rb +163 -0
  122. data/lib/dyndoc/init/config.rb +296 -0
  123. data/lib/dyndoc/init/home.rb +9 -0
  124. data/lib/dyndoc/plugins/tex.rb +4 -0
  125. data/lib/dyndoc/plugins/tex/beamer.rb +208 -0
  126. data/lib/dyndoc/plugins/tex/tex_eval.rb +69 -0
  127. data/lib/dyndoc/plugins/tex/tex_parse_do.rb +25 -0
  128. data/lib/dyndoc/plugins/tex/tex_user_tag.rb +32 -0
  129. data/share/R/dyndocMsys2.R +5 -0
  130. data/share/R/dyndocTools.R +9 -0
  131. data/share/R/test.R +14 -0
  132. data/share/R/tools/dynArray.R +34 -0
  133. data/share/R/tools/dynCapture.R +84 -0
  134. data/share/R/tools/dynMsys2.R +54 -0
  135. data/share/julia/dynArray.jl +93 -0
  136. data/share/julia/dyndoc.jl +110 -0
  137. data/share/julia/ruby.jl +37 -0
  138. metadata +202 -0
@@ -0,0 +1,23 @@
1
+ {#meth]set.DynVar[#,]field[:out][#,]content[][#rb<]@vars.extract_raw(#{=.ObjectName})[#{field}]=#{=content}[#}
2
+
3
+ {#meth]delete.DynVar[#,]field[:out][#?]#{=field}[0,1]!=":"[#=]field[:#{field}]
4
+ [#?]#{field} != :val[#rb<]@vars.extract_raw(#{=.ObjectName}).delete(#{field})
5
+ [#}
6
+
7
+ {#meth]rep.DynVar[#>]{#rep]#{#{.ObjectName}}[#}[#}
8
+
9
+ {#meth]split.DynVar[#,]field[:split][#,]sep[&][#rb<] @vars.extract_raw(#{=.ObjectName})[#{field}]=#{=.content}.split(#{=sep})[#}
10
+
11
+ {#meth]replicate.DynVar[#,]along[][#,]field[:out]
12
+ [#?]#{=field}[0,1]!=":"[#=]field[:#{field}]
13
+ [#?]#{field} != :val
14
+ [#rb<]var,indices=#{=along}.split(" in ").map{|e| e.strip}
15
+ #p indices
16
+ [#rb<]indices=:r{c(:{indices})} #rb< is required!
17
+ #p indices
18
+ res=[][#rb<]
19
+ for :{var} in indices do
20
+ res << {#<]#{.content!}[#}
21
+ end
22
+ @vars.extract_raw(#{=.ObjectName})[#{field}]=res
23
+ [#}
@@ -0,0 +1,55 @@
1
+ {#def]pwd[#>] [#{_PWD_}] [#}
2
+
3
+ {#def]filename[#>] [#{_FILENAME_}][#}
4
+
5
+ {#def]curpath[#,]name[][#rb>]File.join(File.dirname("#{_FILENAME_}"),"#{name}")[#}
6
+
7
+ {#def]curExpPath[#,]name[][#rb>]require 'dyndoc/common/file';CqlsDoc.expand_path(File.join(File.dirname("#{_FILENAME_CURRENT_}"),"#{name}"))[#}
8
+
9
+ {#def]home[#rb>][ENV["HOME"]][#}
10
+
11
+ {#def]modedoc[#rb>]Dyndoc.tmpl_mngr.fmt[#}
12
+
13
+ {#def]local_use[#rb>]$dyndoc_web and $dyndoc_web[:local][#def}
14
+
15
+
16
+ This doc mode is used to know if it is obtained by web
17
+ {#def]dyndoc_mode[#rb>]Dyndoc.tmpl_mngr.dyndocMode.inspect[#}
18
+
19
+ {#def]format_output[#rb>]Dyndoc.tmpl_mngr.fmtOutput[#}
20
+
21
+ {#def]cqlsdir[#rb>]File.join(ENV["HOME"],"cqls")[#}
22
+
23
+ {#def]dyndir[#rb>]File.join(ENV["HOME"],"dyndoc")[#}
24
+
25
+ {#def]prjpath[#,]prj[][#,]type[rsrc]
26
+ [#>][{#case]#{type}
27
+ [#when]rsrc[#rb>][File.join(ENV["CQLS_PRJ_ROOT"],"share","rsrc","#{prj}")]
28
+ [#when]img[#rb>][File.join(ENV["CQLS_PRJ_ROOT"],"share","rsrc","#{prj}","img")]
29
+ [#when]data[#rb>][File.join(ENV["CQLS_PRJ_ROOT"],"share","rsrc","#{prj}","data")]
30
+ [#case}]
31
+ [#}
32
+
33
+ {#def]cqlsweb_path[#,]path[][#,]root[/export/cqlsWeb]
34
+ [#rb>]dyndocWeb_path=(File.exists? File.join(ENV["HOME"],"dyndoc","web")) ? File.join(ENV["HOME"],"dyndoc","web") : #{=root}
35
+ File.join(dyndocWeb_path,#{=path})
36
+ [#def}
37
+
38
+ {#def]cqlsweb_rsrc_path[#,]path[][#>]{#cqlsweb_path]public/rsrc/#{path}[#cqlsweb_path}[#def}
39
+
40
+ {#def]cqlsweb_auto_img[#,]path[][#,]max[5000]
41
+ [#=]path2[{#cqlsweb_path]public/rsrc/img/#{path}[#}]
42
+ [#rb<]now=Time.now;Dir["#{path2}*"].each {|f| begin p f;FileUtils.rm(f) end if now-File.mtime(f) > 60}
43
+ [#>][#{path2}:{`uuidgen`.strip}]
44
+ [#def}
45
+
46
+ {#def]cqlsweb_public_imgName[#,]path[]
47
+ [#rb<]root="{#cqlsweb_path]path[][#}"+"public/"
48
+ puts "root";p root
49
+ rbpath=#{=path}
50
+ p rbpath
51
+ tmp=/^#{root}/.match(rbpath)
52
+ p tmp
53
+ res = tmp ? tmp.post_match : "error"
54
+ [#>]:{"/"+res}
55
+ [#def}
@@ -0,0 +1,34 @@
1
+ [#%] Git for dyn: accessing file in some git directory
2
+ require grit or maybe simply import the used functions
3
+ [#first][#rb<]$dyn_git=[]
4
+ [#main][#<]
5
+ {#def]git[#,]from[.git][#,]branch[HEAD][#,]path[][#,]as[][#%]as is UNUSED from now
6
+ [#?]#{0?as}[#>]as[#{path}][#?]end
7
+ [#rb<]
8
+ from_pathname=File.expand_path(#{=from})
9
+ if File.exist? from_pathname
10
+ if !(from_pathname =~ /\.git$/) and File.exist?(File.join(from_pathname,".git"))
11
+ from_pathname=File.join(from_pathname,".git")
12
+ else
13
+ puts "WARNING! #{from_pathname} does not contain a git repository!"
14
+ end
15
+ elsif File.exist? from_pathname+".git"
16
+ from_pathname=from_pathname+".git"
17
+ end
18
+ #p from_pathname
19
+ pathname=File.expand_path(#{=path})
20
+ if File.exist? pathname
21
+ FileUtils.cp(pathname,pathname+".__DYN_ORIG__")
22
+ end
23
+ [#rb<]
24
+ `git --git-dir=:{from_pathname} checkout #{branch} :{pathname}`
25
+ [#rb<]
26
+ as_pathname=pathname+".__DYN_GIT__"
27
+ FileUtils.mv(pathname,as_pathname)
28
+ $dyn_git << as_pathname
29
+ FileUtils.mv(pathname+".__DYN_ORIG__",pathname) if File.exist? pathname+".__DYN_ORIG__"
30
+ [#rb>]as_pathname
31
+ [#def}
32
+ [#last][#rb<]$dyn_git.uniq.each{|pathname|
33
+ FileUtils.rm_f(pathname)
34
+ }
@@ -0,0 +1,46 @@
1
+ ## each and keys methods for List class (see dyndoc-ruby-demo/BaseLang/List.dyn)
2
+
3
+
4
+ {#hide]
5
+ Does not work! To debug!
6
+ {#meth]keys.List[#rb>]@vars.extract("self.content").keys[#}
7
+ [#hide}
8
+
9
+ {#meth]listkeys.List[#rb>]@vars.extract("self.content").keys[#}
10
+
11
+ {#meth]each.List[#,]fct[]
12
+ [#?]#{0?fct}[#rb>]
13
+ @vars.extract_raw(".content").each do |k,v| #
14
+ {#>][#=].key[:{k}][#=].value[:{v[:val]}][#yield]default[#>}
15
+ end
16
+ [#?]else[#rb>]
17
+ @vars.extract_raw(".content").each do |k,v| #
18
+ {#>][#=].key[:{k}][#=].value[:{v[:val]}][#>]{#call]#{fct}[#,]#{.key}[#,]#{.value}[#call}[#>}
19
+ end
20
+ [#meth}
21
+
22
+ ## The code below is just here for old compatibility but would be remove or update soon
23
+
24
+ {#def]List[#,]list[#rb<]@vars.local[:prev][#{=list}]={}[#}
25
+
26
+ {#meth]apply.List[#,]_key_[key][#,]_elt_[val]
27
+ [#rb>]_key_[#{=_key_}.strip]
28
+ [#rb>]_elt_[#{=_elt_}.strip]
29
+ [#rb<]
30
+ @nb={} unless @nb
31
+ @keysList={} unless @keysList
32
+ @nb[#{=_elt_}]=#{#.content}
33
+ @keysList[#{=_elt_}]=@vars.extract("self.content").keys.sort
34
+ @ind={} unless @ind
35
+ @ind[#{=_elt_}]=-1
36
+ [#>]
37
+ [{#loop][#rb<][@ind[#{=_elt_}]+=1]
38
+ [#=]#{_key_}[:{@keysList[#{=_elt_}][@ind[#{=_elt_}]]}]
39
+ [#=]#{_elt_}[:self.content.#{#{_key_}}]
40
+ [#yield]default
41
+ [#break]:{@ind[#{=_elt_}]==@nb[#{=_elt_}]-1}
42
+ [#}]
43
+ [#rb<]@ind[#{=_elt_}]=-1
44
+ @nb.delete(#{=_elt_})
45
+ @keysList.delete(#{=_elt_})
46
+ [#}
@@ -0,0 +1,32 @@
1
+
2
+ {#meth]class.Object[#>]#{self.Class}[#}
3
+
4
+ {#meth]objname.Object[#>]#{self.ObjectName}[#}
5
+
6
+ {#meth]self.Object[#>]:#{self.ObjectName}[#}
7
+
8
+ {#meth]link.Object[#,]to[][#<]{#if]@vars.extract("self").respond_to? "keys" and @vars.extract(#{=to}).respond_to? "keys"
9
+ [#rb<]p #{=to};p @vars.extract("self").keys; p @vars.extract(#{=to}).keys;p #{=to}
10
+ vset=@vars.extract(#{=to}).keys - @vars.extract("self").keys
11
+ i=-1
12
+ [#<]{#loop][#rb<]v=vset[i+=1]
13
+ p v;p [#{=.ObjectName},#{=to}]
14
+ [#=].:{v}[:#{to}.:{v}]
15
+ [#break]vset.length==i
16
+ [#loop}
17
+ [#if}
18
+ [#meth}
19
+
20
+ {#meth]inspect.Object[#,]verbatim[true]
21
+ [#?]#{verbatim}[#>]\begin{verbatim}
22
+ [#>] [Class: [#{self.Class}]]
23
+ [#?]#{=self.ObjectName}[#>][
24
+ |ObjectName: [#{self.ObjectName}]
25
+ |True variable content:
26
+ |:{@vars.extract_list(#{=self.ObjectName})}]
27
+ [#?]#{=self.content}[#>][
28
+ |self variable content:
29
+ |:{@vars.extract_list("self.content")}]
30
+ [#?]#{verbatim}[#>][<\n>\end][#>][{verbatim}]
31
+ [#}
32
+
@@ -0,0 +1,18 @@
1
+ [#first][#rb<]$dyn_signal={}
2
+ [#main]
3
+ {#def]connect[#,]signal[][#,]object[][#,]method[][#,]priority[100]
4
+ [#rb<]
5
+ $dyn_signal[#{=signal}]=[] unless $dyn_signal[#{=signal}]
6
+ $dyn_signal[#{=signal}] << [#{priority},#{=object},#{=method}]
7
+ $dyn_signal[#{=signal}].sort!{|e,e2| ((e[0]<e2[0] or (e[0]==e2[0] and e[1]<e2[1])) ? -1 : 1)}
8
+ [#}
9
+
10
+ {#def]emit[#,]signal[][#,]args[]
11
+ [#rb<]
12
+ signal=$dyn_signal[#{=signal}]
13
+ ind=-1
14
+ [#>]{#loop][#break]ind==signal.length-1
15
+ [#rb<][priority,object,method=signal[ind+=1]]
16
+ [#>][{#call]:{method}[#,]:{object}[#,]_args_[:args][#}]
17
+ [#}
18
+ [#}
@@ -0,0 +1,22 @@
1
+ {#meth]rep.String[#,]nb[1][#,]sep[][#,]along[]
2
+ [#?]#{0?along}[#rb>](#{=.content.value}+#{=sep})*(#{nb}-1)[#>][#{.content.value}]
3
+ [#?]else[#%]string is supposed to be a #code block
4
+ [#rb<]res=[][#<]{#for]#{along}[#rb<]res << #{=.content.value!}[#}
5
+ [#rb>][res.join(#{=sep})]
6
+ [#}
7
+
8
+ {#meth]join.String[#,]sep[][#>]{#join]self.content.ary[#}[#}
9
+
10
+ {#meth]apply.String[#,]_elt_[elt]
11
+ [#rb<]
12
+ @nb={} unless @nb
13
+ @nb[#{=_elt_}]=#{#.content.ary}
14
+ @ind={} unless @ind
15
+ @ind[#{=_elt_}]=-1
16
+ [#>]
17
+ [{#loop][#rb<]@ind[#{=_elt_}]+=1
18
+ [#>]#{_elt_}[#{self.content.ary.:{@ind[#{=_elt_}]}}]
19
+ [#yield]default
20
+ [#break]:{@ind[#{=_elt_}]==@nb[#{=_elt_}]-1}
21
+ [#}]
22
+ [#}
@@ -0,0 +1 @@
1
+ {#require]Style/Text/Std[#}
@@ -0,0 +1,282 @@
1
+ [#package]\usepackage{xcolor}
2
+ [#preamble]\newcommand{\ok}{ \textcolor{green}{\large$\surd$}}
3
+ \newcommand{\nok}{ \textcolor{red}{\large X}}
4
+ [#main][#<]
5
+
6
+ New Mode: since #test exists and allows
7
+
8
+ -> In some directory, place all the result files!
9
+ -> The first time, (i.e. if the file does not exist) the file is created.
10
+ -> In the mode of documentation: the code is output and the result too.
11
+ -> When asking for the result, it is extracted from the result file.
12
+ -> In the testing mode: the code is executed and compred with the result file.
13
+ Rmk: the weird thing is that code is in the dyn file when the resukt is not!!!!
14
+ I guess that the two modes need to be consistent! The result has to be embedded in the dyn file when the code is too.
15
+
16
+
17
+
18
+ # OLD STUFF!
19
+ {#def]openTag[#,]tag[blck][#,]verb![false]
20
+ [#?]#{verb}[#>][\verb!][#?]end
21
+ [#>]
22
+ [_{_#|
23
+ |#{tag}]]
24
+ [#?]#{verb}[#>][!]
25
+ [#}
26
+
27
+ {#def]closeTag[#,]tag[][#,]verb![false]
28
+ [#?]#{verb}[#>][\verb!][#?]end
29
+ [#>]
30
+ [[#|
31
+ |#{tag}_}_]
32
+ [#?]#{verb}[#>][!]
33
+ [#}
34
+
35
+ {#def]instrTag[#,]tag[][#,]verb![false]
36
+ [#?]#{verb}[#>][\verb!][#?]end
37
+ [#>]
38
+ [[#|
39
+ |#{tag}]]
40
+ [#?]#{verb}[#>][!]
41
+ [#}
42
+
43
+ {#def]checkCode[#,]key[][#,]result[]
44
+ [#r<] p #{=result}
45
+ [#?]#{=result}=='{#dyn]test|#{key}[#}'[#>]\ok[#?]else[#>]\nok[#>][\hrulefill]
46
+ [#}
47
+
48
+ ## OLD STUFF
49
+
50
+ {#def]dynverb[#,]code[][#,]file[]
51
+ [#rb>]code[(#{=file}.empty?) ? @protected_txt : (Utils.protect_txt_block(CqlsDoc.input_from_file(#{=file})))]
52
+ [#>][{#verb]#{code}[#}]
53
+ [#}
54
+
55
+
56
+ {#def]runTestCode[#,]code[][#,]verbatim[true]
57
+ [#>]result[{#dyn]#{code}[#}]
58
+ [#>] [\noindent \fbox{\textbf{Code}} \hrulefill
59
+ {#beginVerb#}
60
+ :{@protected_txt}
61
+ {#endVerb#}
62
+ \noindent \fbox{\textbf{Result}} \hrulefill<\n>]
63
+ [#?]#{verbatim}[#>][{#beginVerb#}<\n>]
64
+ [#?]true[#>]#{result}
65
+ [#?]#{verbatim}[#>]{#endVerb#}
66
+ [#?]true[#>]\hrule
67
+ \vspace*{.5cm}
68
+ [#}
69
+
70
+ {#def]testCodeAndCheck[#,]file[test][#,]code[]
71
+ [#>]result[{#dyn]#{code}[#}]
72
+ [#>>]#{file}.output?[#{result}]
73
+ [#>] [\noindent \fbox{\textbf{Code}: :{CqlsDoc::Utils.escape(#{=file},["\_","\\\_"])}}\hrulefill\\
74
+ {#beginVerb#}
75
+ :{@protected_txt}
76
+ {#endVerb#}
77
+ \noindent \fbox{\textbf{Result}: :{CqlsDoc::Utils.escape(#{=file},["\_","\\\_"])}}\hrulefill\\ #{result}\\
78
+ \noindent \fbox{\textbf{Checked}: :{CqlsDoc::Utils.escape(#{=file},["\_","\\\_"])} {#if]#{=result}=='#F{#{file}.output}'[#>]\ok[#else]\nok[#}}\hrulefill
79
+ ]
80
+ [#}
81
+
82
+
83
+
84
+ {#def]testFile[#,]file[test.dyn][#,]verbatim[true]
85
+ [#>] code [#F{!:{CqlsDoc.doc_filename(#{=file})}}]
86
+ [#rb<]code=Utils.protect_txt_block(CqlsDoc.input_from_file("#{file}"))
87
+ [#>] [\noindent \fbox{\textbf{Code (from file \texttt{:{CqlsDoc::Utils.escape(#{=file},["\_","\\\_"])}})}} \hrulefill
88
+ {#beginVerb#}
89
+ :{code}
90
+ {#endVerb#}
91
+ ]
92
+ [#>]result[{#dyn]#{code}[#}]
93
+ [#>] [\noindent \fbox{\textbf{Result}} \hrulefill]
94
+ [#?]#{verbatim}[#rb>]result[#{=result}.gsub("\\begin{verbatim}","\\begin{__VERBATIM__}").gsub("\\end{verbatim}","\\end{__VERBATIM__}")][#>][{#beginVerb#}
95
+ ][#?]end
96
+ [#>][#{result}]
97
+ [#?]#{verbatim}[#>][
98
+ {#endVerb#}
99
+ ]
100
+ [#?]true[#>]\hrule
101
+ \vspace*{.5cm}
102
+ [#}
103
+
104
+ {#def]testFileAndCheck[#,]file[test]
105
+ [#>] code [#F{#{file}.dyn}]
106
+ [#rb<]code=Utils.protect_txt_block(File.read("#{file}.dyn"))
107
+ [#>]result[{#dyn]#{code}[#}]
108
+ [#>>]#{file}.output?[#{result}]
109
+ [#>] [\noindent \fbox{\textbf{Code}: :{CqlsDoc::Utils.escape(#{=file},["\_","\\\_"])}}\hrulefill
110
+ {#beginVerb#}
111
+ #rb{code}
112
+ {#endVerb#}
113
+ \noindent \fbox{\textbf{Result}: :{CqlsDoc::Utils.escape(#{=file},["\_","\\\_"])}}\hrulefill\\ #{result}\\
114
+ \noindent \fbox{\textbf{Checked}: :{CqlsDoc::Utils.escape(#{=file},["\_","\\\_"])} {#if]#{=result}=='#F{#{file}.output}'[#>]\ok[#else]\nok[#}}\hrulefill
115
+ ]
116
+ [#}
117
+
118
+ {#def]protxt[#rb>]@protected_txt[#}
119
+
120
+
121
+
122
+ {#hide]
123
+ NEW SPIRIT!!!!
124
+
125
+ ===========================
126
+ Object for testing dyn code
127
+ ===========================
128
+
129
+ [#<]
130
+
131
+ {#meth]new.Tester[#,].dir[output/][#=].report@[{}][#=].tests@[[]][#}
132
+
133
+ {#meth]testCode.Tester[#,]key[][#,]code[][#,]file[][#,]expected[][#,]descr[][#,]view[false]
134
+ [#?]#{=key}[-1,1]=="!"[#rb>]key[#{=key}[0...-1]][#=]view[true][#rb<]p "key #{key} registered!" [#?]else[#rb<]p "too bad!"
135
+ [#?]#{+?file}
136
+ [#=]code[#F{#{file}.dyn}]
137
+ [#rb<]code=Utils.protect_txt_block(File.read("#{file}.dyn"))
138
+ [#?]else
139
+ [#rb<]code=@protected_txt;#p code;p #{=code}
140
+ [#?]end
141
+ [#=]result[{#dyn]#{code}[#}]
142
+ [#rb<]
143
+ expectedFile=File.join(#{=.dir},<key:>)
144
+
145
+ <expected:> = File.read(expectedFile) if <expected:>.empty? and File.exists?(expectedFile)
146
+
147
+ unless File.exists?(expectedFile)
148
+ File.open(expectedFile,"w") do |f|
149
+ #puts "result"; p #{=result}
150
+ f << <result:>
151
+ end
152
+ end
153
+
154
+ <.tests@> << <key:>
155
+ #p <.codes@>
156
+ <.report@>[<key:>]={:type=>:code,:code=>code,:expected=> <expected:> ,:result=> <result:>,:file=> <file:>,:descr => <descr:>}
157
+ [#?]#{view}[#>]{#theCode]self[#,]#{key}[#}
158
+ [#meth-test}
159
+
160
+ {#meth]testRCode.Tester[#,]key[][#,]code[][#,]file[][#,]expected[][#,]seed[10][#,]descr[]
161
+ [#?]#{+?file}[#=]code[#F{#{file}.dyn}][#?]end
162
+ [#rb<]code=#{=code}.strip
163
+ [#r<]set.seed(#{seed})
164
+ [#=]result[{#rverb]:{code}[#}]
165
+ [#rb<]
166
+ expectedFile=File.join(#{=.dir},<key:>)
167
+
168
+ <expected:> = File.read(expectedFile) if <expected:>.empty? and File.exists?(expectedFile)
169
+
170
+ unless File.exists?(expectedFile)
171
+ File.open(expectedFile,"w") do |f| #do not remove!!!!!
172
+ #puts "result"; p #{=result}
173
+ f << <result:>
174
+ end
175
+ end
176
+
177
+ <.tests@> << <key:>
178
+ #p <.codes@>
179
+ <.report@>[<key:>]={:type=>:codeR,:code=> code,:expected=> <expected:> ,:result=> <result:>,:file=> <file:>,:descr => <descr:>}
180
+ [#meth-test}
181
+
182
+ {#meth]testRImg.Tester[#,]key[][#,]code[][#,]file[][#,]expected[][#,]seed[10][#,]descr[]
183
+ [#?]#{+?file}[#=]code[#F{#{file}.dyn}][#?]end
184
+ [#rb<]
185
+ code=#{=code}.strip
186
+ result=File.join(#{=.dir},<key:>+".png")
187
+ [#r<]set.seed(#{seed})
188
+ [#<]{#rpng]:{code}[#img]:{result}[#newR]TRUE[#}
189
+ [#rb<]
190
+ unless <expected:>.empty?
191
+ tmpExpected=File.join(#{=.dir},<expected:>)
192
+ <expected:> = tmpExpected if !File.exists?(<expected:>) and File.exists?(tmpExpected)
193
+ else
194
+ tmpExpected = File.join(#{=.dir},<key:>+"-expected.png")
195
+ if File.exists? tmpExpected
196
+ <expected:> = tmpExpected
197
+ elsif File.exists?(result)
198
+ <expected:> = tmpExpected
199
+ require 'fileutils'
200
+ FileUtils.cp(result,<expected:>)
201
+ end
202
+ end
203
+ raise "Boom! expected image file "+<expected:>+" does not exists!" unless File.exists?(<expected:>)
204
+ <.tests@> << <key:>
205
+ #p <.codes@>
206
+ <.report@>[<key:>]={:type=>:imgR,:code=>code,:expected=> <expected:> ,:result=> result,:file=> <file:>,:descr => <descr:>}
207
+ [#meth-test}
208
+
209
+ {#meth]check.Tester[#>]
210
+ \begin{tabular}{|c|c|} \hline
211
+ [#rb>]
212
+ <.tests@>.each{|key| #
213
+ {#>]:{key} & [#>}
214
+ if {#<<]{#isValid]self[#key]:{key}[#}[#<<}
215
+ {#>]\ok[#>}
216
+ else
217
+ {#>]\nok[#>}
218
+ end
219
+ {#>]\\\hline[#nl][#>}
220
+ }
221
+ [#>]\end{tabular}
222
+ [#meth-report}
223
+
224
+ {#meth]theCode.Tester[#,]key[][#,]verbSep[!][#rb>]
225
+ case <.report@>[<key:>][:type]
226
+ when :code
227
+ {#>]{@verbatim]:{<.report@>[<key:>][:code]}[@}[#} #make a comment in the doc! This works since <.report@>[<key:>] is converted befaore the code execution in ruby object!!!!
228
+ when :codeR, :imgR
229
+ {#>]{@verbatim]:{<.report@>[<key:>][:code]}[@}[#}
230
+ end
231
+ [#meth}
232
+
233
+ {#meth]result.Tester[#,]key[][#,]verbSep[!][#rb>]
234
+ case <.report@>[<key:>][:type]
235
+ when :code
236
+ {#>]{@verbatim]:{<.report@>[<key:>][:result]}[@}[#}
237
+ when :codeR
238
+ {#>][#rb>][<.report@>[<key:>][:result]][#}
239
+ when :imgR
240
+ {#>]\includegraphics[scale=.5]{:{<.report@>[<key:>][:result]}}[#}
241
+ end
242
+ [#}
243
+
244
+ {#meth]expected.Tester[#,]key[][#,]verbSep[!][#rb>]
245
+ case <.report@>[<key:>][:type]
246
+ when :code
247
+ {#>]{@verbatim]:{<.report@>[<key:>][:expected]}[@}[#}
248
+ when :codeR
249
+ {#>][#rb>][<.report@>[<key:>][:expected]][#}
250
+ when :imgR
251
+ {#>]\includegraphics[scale=.5]{:{<.report@>[<key:>][:expected]}}[#}
252
+ end
253
+ [#meth}
254
+
255
+ {#meth]isValid.Tester[#,]key[]
256
+ [#rb>]
257
+ require 'digest'
258
+ case <.report@>[<key:>][:type]
259
+ when :code, :codeR
260
+ Digest::SHA1.hexdigest(<.report@>[<key:>][:result])==Digest::SHA1.hexdigest(<.report@>[<key:>][:expected])
261
+ when :imgR
262
+ Digest::SHA1.hexdigest(File.read(<.report@>[<key:>][:result]))==Digest::SHA1.hexdigest(File.read(<.report@>[<key:>][:expected]))
263
+ end
264
+ [#meth}
265
+
266
+ CREATION OF THE GLOBAL TESTER: {#new]::Test[#of]Tester[#}
267
+
268
+ IN THE STYLE MODE:
269
+ {@Tester:new@}
270
+
271
+ {@Tester:testCode][@,]key[][@,]code[][@,]file[][@,]expected[][@,]descr[][@,]view[false][@>]{#testCode]Test[#}[@}
272
+
273
+ {@Tester:testRCode][@,]key[][@,]code[][@,]file[][@,]expected[][@,]seed[10][@,]descr[][@>]{#testRCode]Test[#}[@}
274
+
275
+ {@Tester:theCode][@,]key[][@,]verbSep[!][@>]{#theCode]Test[#}[@}
276
+
277
+ {@Tester:theResult][@,]key[][@,]verbSep[!][@>]{#result]Test[#}[@}
278
+
279
+ {@Tester:expectedResult][@,]key[][@,]verbSep[!][@>]{#expected]Test[#}[@}
280
+
281
+ [#hide}
282
+