PageTemplate 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (110) hide show
  1. data/MANIFEST +4 -0
  2. data/Rakefile +54 -0
  3. data/config.save +12 -0
  4. data/doc/classes/BlockCommand.html +229 -0
  5. data/doc/classes/BlockCommand.src/M000004.html +18 -0
  6. data/doc/classes/BlockCommand.src/M000005.html +25 -0
  7. data/doc/classes/BlockCommand.src/M000006.html +18 -0
  8. data/doc/classes/BlockCommand.src/M000007.html +23 -0
  9. data/doc/classes/BlockCommand.src/M000008.html +24 -0
  10. data/doc/classes/Command.html +167 -0
  11. data/doc/classes/Command.src/M000029.html +19 -0
  12. data/doc/classes/Command.src/M000030.html +18 -0
  13. data/doc/classes/IfCommand.html +193 -0
  14. data/doc/classes/IfCommand.src/M000039.html +19 -0
  15. data/doc/classes/IfCommand.src/M000040.html +20 -0
  16. data/doc/classes/IfCommand.src/M000041.html +20 -0
  17. data/doc/classes/IfElseCommand.html +189 -0
  18. data/doc/classes/IfElseCommand.src/M000023.html +19 -0
  19. data/doc/classes/IfElseCommand.src/M000024.html +23 -0
  20. data/doc/classes/IfElseCommand.src/M000025.html +20 -0
  21. data/doc/classes/IncludeCommand.html +178 -0
  22. data/doc/classes/IncludeCommand.src/M000017.html +21 -0
  23. data/doc/classes/IncludeCommand.src/M000018.html +23 -0
  24. data/doc/classes/IncludeCommand.src/M000019.html +18 -0
  25. data/doc/classes/LoopCommand.html +197 -0
  26. data/doc/classes/LoopCommand.src/M000001.html +19 -0
  27. data/doc/classes/LoopCommand.src/M000002.html +33 -0
  28. data/doc/classes/LoopCommand.src/M000003.html +20 -0
  29. data/doc/classes/LoopElseCommand.html +190 -0
  30. data/doc/classes/LoopElseCommand.src/M000020.html +19 -0
  31. data/doc/classes/LoopElseCommand.src/M000021.html +23 -0
  32. data/doc/classes/LoopElseCommand.src/M000022.html +20 -0
  33. data/doc/classes/Namespace.html +297 -0
  34. data/doc/classes/Namespace.src/M000031.html +19 -0
  35. data/doc/classes/Namespace.src/M000032.html +18 -0
  36. data/doc/classes/Namespace.src/M000033.html +18 -0
  37. data/doc/classes/Namespace.src/M000034.html +19 -0
  38. data/doc/classes/Namespace.src/M000035.html +36 -0
  39. data/doc/classes/Namespace.src/M000036.html +21 -0
  40. data/doc/classes/Namespace.src/M000037.html +18 -0
  41. data/doc/classes/Namespace.src/M000038.html +18 -0
  42. data/doc/classes/PageTemplate.html +352 -0
  43. data/doc/classes/PageTemplate.src/M000009.html +46 -0
  44. data/doc/classes/PageTemplate.src/M000010.html +29 -0
  45. data/doc/classes/PageTemplate.src/M000011.html +18 -0
  46. data/doc/classes/PageTemplate.src/M000012.html +18 -0
  47. data/doc/classes/PageTemplate.src/M000013.html +18 -0
  48. data/doc/classes/PageTemplate.src/M000014.html +18 -0
  49. data/doc/classes/PageTemplate.src/M000015.html +18 -0
  50. data/doc/classes/PageTemplate.src/M000016.html +19 -0
  51. data/doc/classes/Syntax.html +139 -0
  52. data/doc/classes/Syntax/CachedParser.html +163 -0
  53. data/doc/classes/Syntax/CachedParser.src/M000045.html +19 -0
  54. data/doc/classes/Syntax/CachedParser.src/M000046.html +52 -0
  55. data/doc/classes/Syntax/Glossary.html +245 -0
  56. data/doc/classes/Syntax/Glossary.src/M000047.html +20 -0
  57. data/doc/classes/Syntax/Glossary.src/M000048.html +29 -0
  58. data/doc/classes/Syntax/Parser.html +261 -0
  59. data/doc/classes/Syntax/Parser.src/M000049.html +22 -0
  60. data/doc/classes/Syntax/Parser.src/M000050.html +35 -0
  61. data/doc/classes/Syntax/Parser.src/M000051.html +18 -0
  62. data/doc/classes/Syntax/Parser.src/M000052.html +21 -0
  63. data/doc/classes/Syntax/Parser.src/M000053.html +53 -0
  64. data/doc/classes/Syntax/Parser.src/M000054.html +107 -0
  65. data/doc/classes/TextCommand.html +185 -0
  66. data/doc/classes/TextCommand.src/M000042.html +18 -0
  67. data/doc/classes/TextCommand.src/M000043.html +18 -0
  68. data/doc/classes/TextCommand.src/M000044.html +18 -0
  69. data/doc/classes/ValueCommand.html +186 -0
  70. data/doc/classes/ValueCommand.src/M000026.html +18 -0
  71. data/doc/classes/ValueCommand.src/M000027.html +18 -0
  72. data/doc/classes/ValueCommand.src/M000028.html +20 -0
  73. data/doc/created.rid +1 -0
  74. data/doc/files/README_txt.html +224 -0
  75. data/doc/files/lib/PageTemplate_rb.html +119 -0
  76. data/doc/fr_class_index.html +41 -0
  77. data/doc/fr_file_index.html +28 -0
  78. data/doc/fr_method_index.html +80 -0
  79. data/doc/index.html +24 -0
  80. data/doc/rdoc-style.css +208 -0
  81. data/install.rb +1015 -0
  82. data/lib/MANIFEST +2 -0
  83. data/lib/PageTemplate.rb +936 -0
  84. data/pkg/PageTemplate-1.1.2.gem +0 -0
  85. data/tdata/complex.txt +116 -0
  86. data/tdata/i1.txt +1 -0
  87. data/tdata/i2.txt +7 -0
  88. data/tdata/ib1.txt +7 -0
  89. data/tdata/ib2.txt +13 -0
  90. data/tdata/ie1.txt +4 -0
  91. data/tdata/ie2.txt +15 -0
  92. data/tdata/include.1.txt +1 -0
  93. data/tdata/include.2.txt +1 -0
  94. data/tdata/include.3.txt +1 -0
  95. data/tdata/include.4.out.txt +3 -0
  96. data/tdata/include.4.txt +2 -0
  97. data/tdata/include.4a.txt +1 -0
  98. data/tdata/include.4b.txt +2 -0
  99. data/tdata/include.5.txt +2 -0
  100. data/tdata/l1.txt +5 -0
  101. data/tdata/l2.txt +7 -0
  102. data/tdata/nm.txt +4 -0
  103. data/tdata/p/_b1.txt +0 -0
  104. data/tdata/p/b1.txt +4 -0
  105. data/tdata/p/cb1.txt +4 -0
  106. data/tdata/t.txt +2 -0
  107. data/tdata/v1.txt +11 -0
  108. data/tdata/v2.txt +11 -0
  109. data/test-install.rb +2 -0
  110. metadata +137 -4
@@ -0,0 +1,22 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>new (Syntax::Parser)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/PageTemplate.rb, line 476</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">glossary</span>, <span class="ruby-identifier">path</span>=<span class="ruby-constant">Dir</span>.<span class="ruby-identifier">getwd</span>)
15
+ <span class="ruby-ivar">@path</span> = <span class="ruby-identifier">path</span>
16
+ <span class="ruby-ivar">@syntax</span> = <span class="ruby-identifier">glossary</span>
17
+ <span class="ruby-ivar">@commands</span> = <span class="ruby-keyword kw">nil</span>
18
+ <span class="ruby-ivar">@lastFile</span> = <span class="ruby-keyword kw">nil</span>
19
+ <span class="ruby-ivar">@mTime</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">at</span>(<span class="ruby-value">0</span>)
20
+ <span class="ruby-keyword kw">end</span></pre>
21
+ </body>
22
+ </html>
@@ -0,0 +1,35 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>build (Syntax::Parser)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/PageTemplate.rb, line 485</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">build</span>(<span class="ruby-identifier">filename</span>)
15
+ <span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exists?</span>(<span class="ruby-identifier">filename</span>)
16
+ <span class="ruby-identifier">file</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">filename</span>)
17
+ <span class="ruby-keyword kw">else</span>
18
+ <span class="ruby-identifier">file</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-ivar">@path</span>, <span class="ruby-identifier">filename</span>))
19
+ <span class="ruby-keyword kw">end</span>
20
+
21
+ <span class="ruby-comment cmt"># If this is a new file, or the file has been changed,</span>
22
+ <span class="ruby-comment cmt"># parse and compile.</span>
23
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">filename</span> <span class="ruby-operator">!=</span> <span class="ruby-ivar">@lastFile</span> <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">file</span>.<span class="ruby-identifier">mtime</span> <span class="ruby-operator">&lt;</span> <span class="ruby-ivar">@mTime</span>
24
+ <span class="ruby-identifier">reset</span>
25
+ <span class="ruby-identifier">source</span> = <span class="ruby-identifier">file</span>.<span class="ruby-identifier">readlines</span>
26
+ <span class="ruby-identifier">parsed</span> = <span class="ruby-identifier">parse</span>(<span class="ruby-identifier">source</span>, <span class="ruby-identifier">filename</span>)
27
+ <span class="ruby-ivar">@commands</span> = <span class="ruby-identifier">compile</span>(<span class="ruby-identifier">parsed</span>, <span class="ruby-identifier">filename</span>)
28
+ <span class="ruby-ivar">@lastFile</span> = <span class="ruby-identifier">filename</span>
29
+ <span class="ruby-ivar">@mTime</span> = <span class="ruby-identifier">file</span>.<span class="ruby-identifier">mtime</span>
30
+ <span class="ruby-keyword kw">end</span>
31
+
32
+ <span class="ruby-keyword kw">return</span> <span class="ruby-value">1</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@commands</span>
33
+ <span class="ruby-keyword kw">end</span></pre>
34
+ </body>
35
+ </html>
@@ -0,0 +1,18 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>output (Syntax::Parser)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/PageTemplate.rb, line 508</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">output</span>(<span class="ruby-identifier">namespace</span> = <span class="ruby-keyword kw">nil</span>)
15
+ <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@commands</span>.<span class="ruby-identifier">output</span>(<span class="ruby-identifier">namespace</span>)
16
+ <span class="ruby-keyword kw">end</span></pre>
17
+ </body>
18
+ </html>
@@ -0,0 +1,21 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>reset (Syntax::Parser)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/PageTemplate.rb, line 513</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">reset</span>
15
+ <span class="ruby-ivar">@lastFile</span> = <span class="ruby-keyword kw">nil</span>
16
+ <span class="ruby-ivar">@mTime</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">at</span>(<span class="ruby-value">0</span>)
17
+ <span class="ruby-ivar">@commands</span> = <span class="ruby-keyword kw">nil</span>
18
+ <span class="ruby-keyword kw">return</span> <span class="ruby-value">1</span>
19
+ <span class="ruby-keyword kw">end</span></pre>
20
+ </body>
21
+ </html>
@@ -0,0 +1,53 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>parse (Syntax::Parser)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/PageTemplate.rb, line 525</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">parse</span>(<span class="ruby-identifier">source</span>, <span class="ruby-identifier">filename</span> = <span class="ruby-value str">&quot;?&quot;</span>)
15
+ <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;#{filename}: Parsing ...&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">$DEBUG</span>
16
+
17
+ <span class="ruby-comment cmt"># Translate source into listing of text and directives</span>
18
+ <span class="ruby-identifier">lineNo</span> = <span class="ruby-value">1</span>
19
+ <span class="ruby-identifier">parsed</span> = []
20
+ <span class="ruby-identifier">source</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">line</span><span class="ruby-operator">|</span>
21
+ <span class="ruby-comment cmt"># split into plain text and directives</span>
22
+ <span class="ruby-keyword kw">while</span> <span class="ruby-identifier">line</span>
23
+ <span class="ruby-identifier">dirMatch</span> = <span class="ruby-ivar">@syntax</span>.<span class="ruby-identifier">directive</span>.<span class="ruby-identifier">match</span>(<span class="ruby-identifier">line</span>)
24
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">dirMatch</span>
25
+ <span class="ruby-identifier">matchText</span> = <span class="ruby-identifier">dirMatch</span>[<span class="ruby-value">1</span>]
26
+ <span class="ruby-identifier">pre</span> = <span class="ruby-identifier">dirMatch</span>.<span class="ruby-identifier">pre_match</span>
27
+ <span class="ruby-identifier">directive</span> = <span class="ruby-ivar">@syntax</span>.<span class="ruby-identifier">lookup</span>(<span class="ruby-identifier">matchText</span>)
28
+ <span class="ruby-identifier">parsed</span>.<span class="ruby-identifier">push</span> [<span class="ruby-identifier">lineNo</span>, <span class="ruby-identifier">pre</span>]
29
+
30
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">directive</span>
31
+ <span class="ruby-identifier">parsed</span>.<span class="ruby-identifier">push</span> [<span class="ruby-identifier">lineNo</span>, <span class="ruby-identifier">directive</span>]
32
+ <span class="ruby-keyword kw">else</span>
33
+ <span class="ruby-comment cmt"># Unrecognized directives are treated as</span>
34
+ <span class="ruby-comment cmt"># plain text.</span>
35
+ <span class="ruby-identifier">parsed</span>.<span class="ruby-identifier">push</span> [<span class="ruby-identifier">lineNo</span>, <span class="ruby-identifier">dirMatch</span>[<span class="ruby-value">0</span>]]
36
+ <span class="ruby-keyword kw">end</span>
37
+
38
+ <span class="ruby-identifier">fragment</span> = <span class="ruby-identifier">dirMatch</span>.<span class="ruby-identifier">post_match</span>
39
+ <span class="ruby-identifier">line</span> = <span class="ruby-identifier">fragment</span>
40
+ <span class="ruby-keyword kw">else</span>
41
+ <span class="ruby-identifier">parsed</span>.<span class="ruby-identifier">push</span> [<span class="ruby-identifier">lineNo</span>, <span class="ruby-identifier">line</span>]
42
+ <span class="ruby-keyword kw">break</span>
43
+ <span class="ruby-keyword kw">end</span>
44
+ <span class="ruby-keyword kw">end</span>
45
+ <span class="ruby-identifier">lineNo</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
46
+ <span class="ruby-keyword kw">end</span>
47
+
48
+ <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;#{filename}: #{@parsed.length} directives&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">$DEBUG</span>
49
+
50
+ <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">parsed</span>
51
+ <span class="ruby-keyword kw">end</span></pre>
52
+ </body>
53
+ </html>
@@ -0,0 +1,107 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>compile (Syntax::Parser)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/PageTemplate.rb, line 568</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">compile</span>(<span class="ruby-identifier">lines</span>, <span class="ruby-identifier">filename</span> = <span class="ruby-value str">&quot;?&quot;</span>)
15
+
16
+ <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;#{filename}: Compiling ...&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">$DEBUG</span>
17
+ <span class="ruby-comment cmt"># Translate listing of text and directives into a BlockCommand</span>
18
+ <span class="ruby-identifier">commands</span> = <span class="ruby-constant">BlockCommand</span>.<span class="ruby-identifier">new</span>()
19
+ <span class="ruby-identifier">max</span> = <span class="ruby-identifier">lines</span>.<span class="ruby-identifier">length</span>
20
+ <span class="ruby-identifier">i</span> = <span class="ruby-value">0</span>
21
+ <span class="ruby-keyword kw">while</span> <span class="ruby-identifier">i</span> <span class="ruby-operator">&lt;</span> <span class="ruby-identifier">max</span>
22
+ <span class="ruby-identifier">line</span> = <span class="ruby-identifier">lines</span>[<span class="ruby-identifier">i</span>]
23
+ <span class="ruby-identifier">type</span> = <span class="ruby-identifier">line</span>[<span class="ruby-value">1</span>].<span class="ruby-identifier">class</span>
24
+ <span class="ruby-identifier">command</span> = <span class="ruby-keyword kw">nil</span>
25
+ <span class="ruby-comment cmt">#puts &quot;#{filename}/#{line[0]}: #{type} -- #{line}&quot;</span>
26
+
27
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">type</span> <span class="ruby-operator">==</span> <span class="ruby-constant">String</span>
28
+ <span class="ruby-identifier">command</span> = <span class="ruby-constant">TextCommand</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">line</span>[<span class="ruby-value">1</span>])
29
+ <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">type</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Array</span>
30
+ <span class="ruby-identifier">directive</span> = <span class="ruby-identifier">line</span>[<span class="ruby-value">1</span>][<span class="ruby-value">0</span>]
31
+ <span class="ruby-identifier">value</span> = <span class="ruby-identifier">line</span>[<span class="ruby-value">1</span>][<span class="ruby-value">1</span>]
32
+ <span class="ruby-identifier">print</span> <span class="ruby-node">&quot;(#{directive} #{value}) &quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">$DEBUG</span>
33
+
34
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">directive</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;value&quot;</span>
35
+ <span class="ruby-identifier">command</span> = <span class="ruby-constant">ValueCommand</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">value</span>)
36
+ <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">directive</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;include&quot;</span>
37
+ <span class="ruby-identifier">command</span> = <span class="ruby-constant">IncludeCommand</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">value</span>, <span class="ruby-ivar">@path</span>)
38
+ <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">directive</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/^(\w+?)open$/</span>
39
+ <span class="ruby-identifier">mainBlock</span> = <span class="ruby-keyword kw">nil</span>
40
+ <span class="ruby-identifier">branchBlock</span> = <span class="ruby-keyword kw">nil</span>
41
+ <span class="ruby-identifier">close</span> = <span class="ruby-keyword kw">nil</span>
42
+ <span class="ruby-identifier">branch</span> = <span class="ruby-keyword kw">nil</span>
43
+
44
+ <span class="ruby-identifier">block</span> = <span class="ruby-identifier">$1</span>
45
+ <span class="ruby-identifier">startIndex</span> = <span class="ruby-identifier">i</span> <span class="ruby-operator">+</span> <span class="ruby-value">1</span>
46
+ <span class="ruby-identifier">closers</span> = <span class="ruby-identifier">findClose</span>(<span class="ruby-identifier">lines</span>[<span class="ruby-identifier">startIndex</span><span class="ruby-operator">..</span><span class="ruby-value">-1</span>],
47
+ <span class="ruby-identifier">startIndex</span>, <span class="ruby-identifier">block</span>)
48
+
49
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">closers</span>[<span class="ruby-value str">'close'</span>]
50
+ <span class="ruby-identifier">close</span> = <span class="ruby-identifier">closers</span>[<span class="ruby-value str">'close'</span>]
51
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">closers</span>[<span class="ruby-value str">'branch'</span>]
52
+ <span class="ruby-identifier">branch</span> = <span class="ruby-identifier">closers</span>[<span class="ruby-value str">'branch'</span>]
53
+ <span class="ruby-identifier">mainLines</span> = <span class="ruby-identifier">lines</span>[<span class="ruby-identifier">startIndex</span><span class="ruby-operator">...</span><span class="ruby-identifier">branch</span>]
54
+ <span class="ruby-identifier">mainBlock</span> = <span class="ruby-identifier">compile</span>(<span class="ruby-identifier">mainLines</span>)
55
+ <span class="ruby-identifier">branchLines</span> = <span class="ruby-identifier">lines</span>[<span class="ruby-identifier">branch</span><span class="ruby-operator">+</span><span class="ruby-value">1</span><span class="ruby-operator">...</span><span class="ruby-identifier">close</span>]
56
+ <span class="ruby-identifier">branchBlock</span> = <span class="ruby-identifier">compile</span>(<span class="ruby-identifier">branchLines</span>)
57
+ <span class="ruby-keyword kw">else</span>
58
+ <span class="ruby-identifier">mainLines</span> = <span class="ruby-identifier">lines</span>[<span class="ruby-identifier">startIndex</span><span class="ruby-operator">...</span><span class="ruby-identifier">close</span>]
59
+ <span class="ruby-identifier">mainBlock</span> = <span class="ruby-identifier">compile</span>(<span class="ruby-identifier">mainLines</span>)
60
+ <span class="ruby-keyword kw">end</span>
61
+ <span class="ruby-keyword kw">else</span>
62
+ <span class="ruby-identifier">raise</span> <span class="ruby-node">&quot;#{@file}:#{line[0]} - &quot;</span> <span class="ruby-operator">+</span>
63
+ <span class="ruby-node">&quot;#{block} #{value} doesn't close&quot;</span>
64
+ <span class="ruby-keyword kw">end</span>
65
+
66
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;if&quot;</span>
67
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">mainBlock</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">branchBlock</span>
68
+ <span class="ruby-identifier">command</span> = <span class="ruby-constant">IfElseCommand</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">value</span>,
69
+ <span class="ruby-identifier">mainBlock</span>, <span class="ruby-identifier">branchBlock</span>)
70
+ <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">mainBlock</span>
71
+ <span class="ruby-identifier">command</span> = <span class="ruby-constant">IfCommand</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">value</span>, <span class="ruby-identifier">mainBlock</span>)
72
+ <span class="ruby-keyword kw">end</span>
73
+ <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">block</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;loop&quot;</span>
74
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">mainBlock</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">branchBlock</span>
75
+ <span class="ruby-identifier">command</span> = <span class="ruby-constant">LoopElseCommand</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">value</span>,
76
+ <span class="ruby-identifier">mainBlock</span>, <span class="ruby-identifier">branchBlock</span>)
77
+ <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">mainBlock</span>
78
+ <span class="ruby-identifier">command</span> = <span class="ruby-constant">LoopCommand</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">value</span>, <span class="ruby-identifier">mainBlock</span>)
79
+ <span class="ruby-keyword kw">end</span>
80
+ <span class="ruby-keyword kw">else</span>
81
+ <span class="ruby-identifier">raise</span> <span class="ruby-node">&quot;#{filename}: #{line[0]} - &quot;</span> <span class="ruby-operator">+</span>
82
+ <span class="ruby-node">&quot;Unrecognized block type '#{block}'&quot;</span>
83
+ <span class="ruby-keyword kw">end</span>
84
+
85
+ <span class="ruby-comment cmt"># Skip to the line after the block closer.</span>
86
+ <span class="ruby-identifier">i</span> = <span class="ruby-identifier">close</span>
87
+ <span class="ruby-keyword kw">elsif</span> <span class="ruby-value str">%Q[
88
+ ifbranch ifclose loopbranch loopclose
89
+ ]</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">directive</span>)
90
+ <span class="ruby-identifier">raise</span> <span class="ruby-node">&quot;#{@file}:#{line[0]} - #{directive}&quot;</span> <span class="ruby-operator">+</span>
91
+ <span class="ruby-value str">&quot; without corresponding opening directive&quot;</span>
92
+ <span class="ruby-keyword kw">else</span>
93
+ <span class="ruby-identifier">raise</span> <span class="ruby-node">&quot;#{@file}:#{line[0]} - Unknown command #{directive}&quot;</span>
94
+ <span class="ruby-keyword kw">end</span>
95
+ <span class="ruby-keyword kw">else</span>
96
+ <span class="ruby-identifier">raise</span> <span class="ruby-node">&quot;#{@file}: Unknown instruction in line #{line}&quot;</span>
97
+ <span class="ruby-keyword kw">end</span>
98
+
99
+ <span class="ruby-identifier">commands</span>.<span class="ruby-identifier">add</span>(<span class="ruby-identifier">command</span>)
100
+ <span class="ruby-identifier">i</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
101
+ <span class="ruby-keyword kw">end</span>
102
+
103
+ <span class="ruby-comment cmt"># Return compiled BlockCommand</span>
104
+ <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">commands</span>
105
+ <span class="ruby-keyword kw">end</span></pre>
106
+ </body>
107
+ </html>
@@ -0,0 +1,185 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>Class: TextCommand</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="classHeader">
50
+ <table class="header-table">
51
+ <tr class="top-aligned-row">
52
+ <td><strong>Class</strong></td>
53
+ <td class="class-name-in-header">TextCommand</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../files/lib/PageTemplate_rb.html">
59
+ lib/PageTemplate.rb
60
+ </a>
61
+ <br />
62
+ </td>
63
+ </tr>
64
+
65
+ <tr class="top-aligned-row">
66
+ <td><strong>Parent:</strong></td>
67
+ <td>
68
+ <a href="Command.html">
69
+ Command
70
+ </a>
71
+ </td>
72
+ </tr>
73
+ </table>
74
+ </div>
75
+ <!-- banner header -->
76
+
77
+ <div id="bodyContent">
78
+
79
+
80
+
81
+ <div id="contextContent">
82
+
83
+ <div id="description">
84
+ <p>
85
+ A very simple <a href="Command.html">Command</a> which outputs a static
86
+ string of text
87
+ </p>
88
+
89
+ </div>
90
+
91
+
92
+ </div>
93
+
94
+ <div id="method-list">
95
+ <h3 class="section-bar">Methods</h3>
96
+
97
+ <div class="name-list">
98
+ <a href="#M000042">new</a>&nbsp;&nbsp;
99
+ <a href="#M000044">output</a>&nbsp;&nbsp;
100
+ <a href="#M000043">to_s</a>&nbsp;&nbsp;
101
+ </div>
102
+ </div>
103
+
104
+ </div>
105
+
106
+
107
+ <!-- if includes -->
108
+
109
+ <div id="section">
110
+
111
+
112
+
113
+
114
+
115
+
116
+
117
+
118
+ <!-- if method_list -->
119
+ <div id="methods">
120
+ <h3 class="section-bar">Public Class methods</h3>
121
+
122
+ <div id="method-M000042" class="method-detail">
123
+ <a name="M000042"></a>
124
+
125
+ <div class="method-heading">
126
+ <a href="TextCommand.src/M000042.html" target="Code" class="method-signature"
127
+ onclick="popupCode('TextCommand.src/M000042.html');return false;">
128
+ <span class="method-name">new</span><span class="method-args">(text)</span>
129
+ </a>
130
+ </div>
131
+
132
+ <div class="method-description">
133
+ <p>
134
+ Creates a <a href="TextCommand.html">TextCommand</a> object, saving
135
+ <tt>text</tt> for future output.
136
+ </p>
137
+ </div>
138
+ </div>
139
+
140
+ <h3 class="section-bar">Public Instance methods</h3>
141
+
142
+ <div id="method-M000044" class="method-detail">
143
+ <a name="M000044"></a>
144
+
145
+ <div class="method-heading">
146
+ <a href="TextCommand.src/M000044.html" target="Code" class="method-signature"
147
+ onclick="popupCode('TextCommand.src/M000044.html');return false;">
148
+ <span class="method-name">output</span><span class="method-args">(namespace = nil)</span>
149
+ </a>
150
+ </div>
151
+
152
+ <div class="method-description">
153
+ <p>
154
+ Returns the string provided during this object&#8217;s creation.
155
+ </p>
156
+ </div>
157
+ </div>
158
+
159
+ <div id="method-M000043" class="method-detail">
160
+ <a name="M000043"></a>
161
+
162
+ <div class="method-heading">
163
+ <a href="TextCommand.src/M000043.html" target="Code" class="method-signature"
164
+ onclick="popupCode('TextCommand.src/M000043.html');return false;">
165
+ <span class="method-name">to_s</span><span class="method-args">()</span>
166
+ </a>
167
+ </div>
168
+
169
+ <div class="method-description">
170
+ </div>
171
+ </div>
172
+
173
+
174
+ </div>
175
+
176
+
177
+ </div>
178
+
179
+
180
+ <div id="validator-badges">
181
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
182
+ </div>
183
+
184
+ </body>
185
+ </html>