fto 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. data/CONTRIBUTORS.txt +5 -0
  2. data/LICENCE.txt +202 -0
  3. data/README.txt +75 -0
  4. data/doc/classes/FormatText.html +120 -0
  5. data/doc/classes/FormatText/Context.html +240 -0
  6. data/doc/classes/FormatText/Context.src/M000001.html +26 -0
  7. data/doc/classes/FormatText/Context.src/M000004.html +26 -0
  8. data/doc/classes/FormatText/Context.src/M000007.html +26 -0
  9. data/doc/classes/FormatText/Context.src/M000008.html +26 -0
  10. data/doc/classes/FormatText/Context.src/M000009.html +26 -0
  11. data/doc/classes/FormatText/Effector.html +411 -0
  12. data/doc/classes/FormatText/Effector.src/M000004.html +38 -0
  13. data/doc/classes/FormatText/Effector.src/M000005.html +39 -0
  14. data/doc/classes/FormatText/Effector.src/M000007.html +38 -0
  15. data/doc/classes/FormatText/Effector.src/M000008.html +42 -0
  16. data/doc/classes/FormatText/Effector.src/M000009.html +43 -0
  17. data/doc/classes/FormatText/Effector.src/M000010.html +19 -0
  18. data/doc/classes/FormatText/Effector.src/M000011.html +18 -0
  19. data/doc/classes/FormatText/Effector.src/M000012.html +19 -0
  20. data/doc/classes/FormatText/Effector.src/M000013.html +18 -0
  21. data/doc/classes/FormatText/Effector.src/M000014.html +18 -0
  22. data/doc/classes/FormatText/FTO.html +305 -0
  23. data/doc/classes/FormatText/FTO.src/M000001.html +19 -0
  24. data/doc/classes/FormatText/FTO.src/M000002.html +34 -0
  25. data/doc/classes/FormatText/FTO.src/M000003.html +22 -0
  26. data/doc/classes/FormatText/FTO.src/M000004.html +19 -0
  27. data/doc/classes/FormatText/FTO.src/M000005.html +22 -0
  28. data/doc/classes/FormatText/FTO.src/M000006.html +20 -0
  29. data/doc/classes/FormatText/FTO.src/M000007.html +63 -0
  30. data/doc/classes/FormatText/FTO.src/M000008.html +63 -0
  31. data/doc/created.rid +1 -0
  32. data/doc/files/fto_rb.html +141 -0
  33. data/doc/files/lib/fto_rb.html +150 -0
  34. data/doc/fr_class_index.html +30 -0
  35. data/doc/fr_file_index.html +27 -0
  36. data/doc/fr_method_index.html +39 -0
  37. data/doc/index.html +24 -0
  38. data/doc/rdoc-style.css +208 -0
  39. data/lib/fto.rb +1349 -0
  40. data/test/test_fto_api.rb +143 -0
  41. data/test/test_fto_effectors.rb +440 -0
  42. data/test/test_helper.rb +3 -0
  43. metadata +115 -0
@@ -0,0 +1,19 @@
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 (FormatText::FTO)</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/fto.rb, line 287</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">text</span>=<span class="ruby-keyword kw">nil</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
15
+ <span class="ruby-constant">String_initialize</span>(<span class="ruby-identifier">text</span>)
16
+ <span class="ruby-ivar">@args</span> = <span class="ruby-identifier">args</span>
17
+ <span class="ruby-keyword kw">end</span></pre>
18
+ </body>
19
+ </html>
@@ -0,0 +1,34 @@
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>registerEffector (FormatText::FTO)</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/fto.rb, line 300</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">registerEffector</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
15
+ <span class="ruby-keyword kw">if</span> ((<span class="ruby-identifier">args</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span>) <span class="ruby-operator">&amp;&amp;</span> (<span class="ruby-identifier">args</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">class</span>.<span class="ruby-identifier">name</span>.<span class="ruby-identifier">match</span>(<span class="ruby-regexp re">/Effector$/</span>))
16
+ <span class="ruby-identifier">newE</span> = <span class="ruby-identifier">args</span>[<span class="ruby-value">0</span>]
17
+ <span class="ruby-keyword kw">else</span>
18
+ <span class="ruby-identifier">newE</span> = <span class="ruby-constant">Effector</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">'placeholder'</span>)
19
+ <span class="ruby-keyword kw">if</span> ((<span class="ruby-identifier">args</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span>) <span class="ruby-operator">&amp;&amp;</span> (<span class="ruby-identifier">args</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Hash</span>))
20
+ <span class="ruby-identifier">args</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>,<span class="ruby-identifier">val</span><span class="ruby-operator">|</span>
21
+ <span class="ruby-identifier">eval</span>(<span class="ruby-node">&quot;newE.#{key.to_s} = val&quot;</span>)
22
+ <span class="ruby-keyword kw">end</span>
23
+ <span class="ruby-keyword kw">else</span>
24
+ <span class="ruby-identifier">newE</span> = <span class="ruby-constant">Effector</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">args</span>)
25
+ <span class="ruby-keyword kw">end</span>
26
+ <span class="ruby-keyword kw">end</span>
27
+ <span class="ruby-ivar">@@RegisteredEffectors</span>[<span class="ruby-identifier">newE</span>.<span class="ruby-identifier">id</span>] = <span class="ruby-identifier">newE</span>
28
+ <span class="ruby-identifier">key</span> = <span class="ruby-identifier">sprintf</span>(<span class="ruby-value str">'%06d-%s'</span>, <span class="ruby-identifier">newE</span>.<span class="ruby-identifier">priority</span>, <span class="ruby-identifier">newE</span>.<span class="ruby-identifier">name</span>)
29
+ <span class="ruby-identifier">newE</span>.<span class="ruby-identifier">sortKey</span> = <span class="ruby-identifier">key</span>
30
+ <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">rebuildEffectorList</span>()
31
+ <span class="ruby-keyword kw">nil</span>
32
+ <span class="ruby-keyword kw">end</span></pre>
33
+ </body>
34
+ </html>
@@ -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>enableEffector (FormatText::FTO)</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/fto.rb, line 345</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">enableEffector</span>(<span class="ruby-identifier">id</span>)
15
+ <span class="ruby-keyword kw">if</span> ((<span class="ruby-identifier">e</span> = <span class="ruby-ivar">@@RegisteredEffectors</span>[<span class="ruby-identifier">id</span>]).<span class="ruby-identifier">nil?</span>)
16
+ <span class="ruby-identifier">raise</span> <span class="ruby-constant">RuntimeError</span>, <span class="ruby-identifier">_</span>(<span class="ruby-value str">'No such effector '</span>) <span class="ruby-operator">+</span> <span class="ruby-node">&quot;ID\##{id}&quot;</span>
17
+ <span class="ruby-keyword kw">end</span>
18
+ <span class="ruby-identifier">e</span>.<span class="ruby-identifier">enabled</span> = <span class="ruby-keyword kw">true</span>
19
+ <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">rebuildEffectorList</span>()
20
+ <span class="ruby-keyword kw">end</span></pre>
21
+ </body>
22
+ </html>
@@ -0,0 +1,19 @@
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>destroyEffector (FormatText::FTO)</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/fto.rb, line 360</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">destroyEffector</span>(<span class="ruby-identifier">id</span>)
15
+ <span class="ruby-ivar">@@RegisteredEffectors</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">id</span>)
16
+ <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">rebuildEffectorList</span>()
17
+ <span class="ruby-keyword kw">end</span></pre>
18
+ </body>
19
+ </html>
@@ -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>disableEffector (FormatText::FTO)</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/fto.rb, line 373</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">disableEffector</span>(<span class="ruby-identifier">id</span>)
15
+ <span class="ruby-keyword kw">if</span> ((<span class="ruby-identifier">e</span> = <span class="ruby-ivar">@@RegisteredEffectors</span>[<span class="ruby-identifier">id</span>]).<span class="ruby-identifier">nil?</span>)
16
+ <span class="ruby-identifier">raise</span> <span class="ruby-constant">RuntimeError</span>, <span class="ruby-identifier">_</span>(<span class="ruby-value str">'No such effector '</span>) <span class="ruby-operator">+</span> <span class="ruby-node">&quot;ID\##{id}&quot;</span>
17
+ <span class="ruby-keyword kw">end</span>
18
+ <span class="ruby-identifier">e</span>.<span class="ruby-identifier">disable</span>
19
+ <span class="ruby-keyword kw">nil</span>
20
+ <span class="ruby-keyword kw">end</span></pre>
21
+ </body>
22
+ </html>
@@ -0,0 +1,20 @@
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>findEffectors (FormatText::FTO)</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/fto.rb, line 389</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">findEffectors</span>(<span class="ruby-identifier">pattern</span>)
15
+ <span class="ruby-identifier">pattern</span> = <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">pattern</span>) <span class="ruby-keyword kw">unless</span> (<span class="ruby-identifier">pattern</span>.<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Regexp</span>)
16
+ <span class="ruby-identifier">matches</span> = <span class="ruby-ivar">@@RegisteredEffectors</span>.<span class="ruby-identifier">select</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">id</span>,<span class="ruby-identifier">e</span><span class="ruby-operator">|</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">name</span>.<span class="ruby-identifier">match</span>(<span class="ruby-identifier">pattern</span>) }
17
+ <span class="ruby-identifier">matches</span>.<span class="ruby-identifier">collect</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">id</span>,<span class="ruby-identifier">e</span><span class="ruby-operator">|</span> <span class="ruby-identifier">e</span> }
18
+ <span class="ruby-keyword kw">end</span></pre>
19
+ </body>
20
+ </html>
@@ -0,0 +1,63 @@
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>format (FormatText::FTO)</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/fto.rb, line 408</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">format</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">argListp</span>)
15
+ <span class="ruby-identifier">argList</span> = <span class="ruby-identifier">argListp</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-value">? </span><span class="ruby-ivar">@args</span>.<span class="ruby-identifier">clone</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">argListp</span>
16
+ <span class="ruby-keyword kw">if</span> ((<span class="ruby-identifier">argList</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span>) <span class="ruby-operator">&amp;&amp;</span> (<span class="ruby-identifier">argList</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Array</span>)) <span class="ruby-operator">&amp;&amp;</span>
17
+ <span class="ruby-identifier">argList</span> = <span class="ruby-identifier">argList</span>[<span class="ruby-value">0</span>]
18
+ <span class="ruby-keyword kw">end</span>
19
+ <span class="ruby-comment cmt">#</span>
20
+ <span class="ruby-comment cmt"># It's possible we were passed a Context object so we can</span>
21
+ <span class="ruby-comment cmt"># recurse. If so, use its values for some of these.</span>
22
+ <span class="ruby-comment cmt">#</span>
23
+ <span class="ruby-keyword kw">if</span> ((<span class="ruby-identifier">argList</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span>) <span class="ruby-operator">&amp;&amp;</span> (<span class="ruby-identifier">argList</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">FormatText</span><span class="ruby-operator">::</span><span class="ruby-constant">Context</span>))
24
+ <span class="ruby-identifier">eContext</span> = <span class="ruby-identifier">argList</span>[<span class="ruby-value">0</span>]
25
+ <span class="ruby-identifier">usedArgs</span> = <span class="ruby-identifier">eContext</span>.<span class="ruby-identifier">usedArgs</span>
26
+ <span class="ruby-identifier">argList</span> = <span class="ruby-identifier">eContext</span>.<span class="ruby-identifier">argList</span>
27
+ <span class="ruby-keyword kw">else</span>
28
+ <span class="ruby-identifier">usedArgs</span> = []
29
+ <span class="ruby-identifier">eContext</span> = <span class="ruby-constant">Context</span>.<span class="ruby-identifier">new</span>({
30
+ <span class="ruby-identifier">:ftoObj</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">self</span>,
31
+ <span class="ruby-identifier">:usedArgs</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">usedArgs</span>,
32
+ <span class="ruby-identifier">:argList</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">argList</span>
33
+ })
34
+ <span class="ruby-keyword kw">end</span>
35
+ <span class="ruby-identifier">result</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">to_s</span>
36
+ <span class="ruby-identifier">effector</span> = <span class="ruby-identifier">sMatched</span> = <span class="ruby-keyword kw">nil</span>
37
+ <span class="ruby-keyword kw">while</span> (<span class="ruby-identifier">m</span> = <span class="ruby-identifier">result</span>.<span class="ruby-identifier">match</span>(<span class="ruby-ivar">@@regex</span>))
38
+ <span class="ruby-comment cmt">#</span>
39
+ <span class="ruby-comment cmt"># Find out which effector was matched. The index in .captures</span>
40
+ <span class="ruby-comment cmt"># will be the same as the index in @effectors.</span>
41
+ <span class="ruby-comment cmt">#</span>
42
+ <span class="ruby-identifier">m</span>.<span class="ruby-identifier">captures</span>.<span class="ruby-identifier">length</span>.<span class="ruby-identifier">times</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span>
43
+ <span class="ruby-keyword kw">next</span> <span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">m</span>.<span class="ruby-identifier">captures</span>[<span class="ruby-identifier">i</span>].<span class="ruby-identifier">nil?</span>)
44
+ <span class="ruby-identifier">eContext</span>.<span class="ruby-identifier">effectorObj</span> = <span class="ruby-identifier">effector</span> = <span class="ruby-ivar">@@EnabledEffectors</span>[<span class="ruby-ivar">@@EffectorKeys</span>[<span class="ruby-identifier">i</span>]]
45
+ <span class="ruby-identifier">eContext</span>.<span class="ruby-identifier">sMatched</span> = <span class="ruby-identifier">sMatched</span> = <span class="ruby-identifier">m</span>.<span class="ruby-identifier">captures</span>[<span class="ruby-identifier">i</span>]
46
+ <span class="ruby-identifier">eContext</span>.<span class="ruby-identifier">reuseArg</span> = <span class="ruby-keyword kw">false</span>
47
+ <span class="ruby-keyword kw">break</span>
48
+ <span class="ruby-keyword kw">end</span>
49
+ <span class="ruby-comment cmt">#</span>
50
+ <span class="ruby-comment cmt"># Call the workhorse for this descriptor</span>
51
+ <span class="ruby-comment cmt">#</span>
52
+ <span class="ruby-identifier">replacement</span> = <span class="ruby-identifier">effector</span>.<span class="ruby-identifier">code</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">eContext</span>)
53
+ <span class="ruby-identifier">result</span>.<span class="ruby-identifier">sub!</span>(<span class="ruby-identifier">sMatched</span>, <span class="ruby-identifier">replacement</span>)
54
+ <span class="ruby-comment cmt">#</span>
55
+ <span class="ruby-comment cmt"># Mark the item at the front of the argument list as having</span>
56
+ <span class="ruby-comment cmt"># been used, if the effector agrees.</span>
57
+ <span class="ruby-comment cmt">#</span>
58
+ <span class="ruby-identifier">usedArgs</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">argList</span>.<span class="ruby-identifier">shift</span>) <span class="ruby-keyword kw">unless</span> (<span class="ruby-identifier">eContext</span>.<span class="ruby-identifier">reuseArg</span>)
59
+ <span class="ruby-keyword kw">end</span>
60
+ <span class="ruby-identifier">result</span>
61
+ <span class="ruby-keyword kw">end</span></pre>
62
+ </body>
63
+ </html>
@@ -0,0 +1,63 @@
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>format (FormatText::FTO)</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/fto.rb, line 387</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">format</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">argListp</span>)
15
+ <span class="ruby-identifier">argList</span> = <span class="ruby-identifier">argListp</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-value">? </span><span class="ruby-ivar">@args</span>.<span class="ruby-identifier">clone</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">argListp</span>
16
+ <span class="ruby-keyword kw">if</span> ((<span class="ruby-identifier">argList</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span>) <span class="ruby-operator">&amp;&amp;</span> (<span class="ruby-identifier">argList</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Array</span>)) <span class="ruby-operator">&amp;&amp;</span>
17
+ <span class="ruby-identifier">argList</span> = <span class="ruby-identifier">argList</span>[<span class="ruby-value">0</span>]
18
+ <span class="ruby-keyword kw">end</span>
19
+ <span class="ruby-comment cmt">#</span>
20
+ <span class="ruby-comment cmt"># It's possible we were passed a Context object so we can recurse.</span>
21
+ <span class="ruby-comment cmt"># If so, use its values for some of these.</span>
22
+ <span class="ruby-comment cmt">#</span>
23
+ <span class="ruby-keyword kw">if</span> ((<span class="ruby-identifier">argList</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span>) <span class="ruby-operator">&amp;&amp;</span> (<span class="ruby-identifier">argList</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">FormatText</span><span class="ruby-operator">::</span><span class="ruby-constant">Context</span>))
24
+ <span class="ruby-identifier">eContext</span> = <span class="ruby-identifier">argList</span>[<span class="ruby-value">0</span>]
25
+ <span class="ruby-identifier">usedArgs</span> = <span class="ruby-identifier">eContext</span>.<span class="ruby-identifier">usedArgs</span>
26
+ <span class="ruby-identifier">argList</span> = <span class="ruby-identifier">eContext</span>.<span class="ruby-identifier">argList</span>
27
+ <span class="ruby-keyword kw">else</span>
28
+ <span class="ruby-identifier">usedArgs</span> = []
29
+ <span class="ruby-identifier">eContext</span> = <span class="ruby-constant">Context</span>.<span class="ruby-identifier">new</span>({
30
+ <span class="ruby-identifier">:ftoObj</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">self</span>,
31
+ <span class="ruby-identifier">:usedArgs</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">usedArgs</span>,
32
+ <span class="ruby-identifier">:argList</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">argList</span>
33
+ })
34
+ <span class="ruby-keyword kw">end</span>
35
+ <span class="ruby-identifier">result</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">to_s</span>
36
+ <span class="ruby-identifier">effector</span> = <span class="ruby-identifier">sMatched</span> = <span class="ruby-keyword kw">nil</span>
37
+ <span class="ruby-keyword kw">while</span> (<span class="ruby-identifier">m</span> = <span class="ruby-identifier">result</span>.<span class="ruby-identifier">match</span>(<span class="ruby-ivar">@@regex</span>))
38
+ <span class="ruby-comment cmt">#</span>
39
+ <span class="ruby-comment cmt"># Find out which effector was matched. The index in .captures</span>
40
+ <span class="ruby-comment cmt"># will be the same as the index in @effectors.</span>
41
+ <span class="ruby-comment cmt">#</span>
42
+ <span class="ruby-identifier">m</span>.<span class="ruby-identifier">captures</span>.<span class="ruby-identifier">length</span>.<span class="ruby-identifier">times</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span>
43
+ <span class="ruby-keyword kw">next</span> <span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">m</span>.<span class="ruby-identifier">captures</span>[<span class="ruby-identifier">i</span>].<span class="ruby-identifier">nil?</span>)
44
+ <span class="ruby-identifier">eContext</span>.<span class="ruby-identifier">effectorObj</span> = <span class="ruby-identifier">effector</span> = <span class="ruby-ivar">@@EnabledEffectors</span>[<span class="ruby-ivar">@@EffectorKeys</span>[<span class="ruby-identifier">i</span>]]
45
+ <span class="ruby-identifier">eContext</span>.<span class="ruby-identifier">sMatched</span> = <span class="ruby-identifier">sMatched</span> = <span class="ruby-identifier">m</span>.<span class="ruby-identifier">captures</span>[<span class="ruby-identifier">i</span>]
46
+ <span class="ruby-identifier">eContext</span>.<span class="ruby-identifier">reuseArg</span> = <span class="ruby-keyword kw">false</span>
47
+ <span class="ruby-keyword kw">break</span>
48
+ <span class="ruby-keyword kw">end</span>
49
+ <span class="ruby-comment cmt">#</span>
50
+ <span class="ruby-comment cmt"># Call the workhorse for this descriptor</span>
51
+ <span class="ruby-comment cmt">#</span>
52
+ <span class="ruby-identifier">replacement</span> = <span class="ruby-identifier">effector</span>.<span class="ruby-identifier">code</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">eContext</span>)
53
+ <span class="ruby-identifier">result</span>.<span class="ruby-identifier">sub!</span>(<span class="ruby-identifier">sMatched</span>, <span class="ruby-identifier">replacement</span>)
54
+ <span class="ruby-comment cmt">#</span>
55
+ <span class="ruby-comment cmt"># Mark the item at the front of the argument list as having</span>
56
+ <span class="ruby-comment cmt"># been used, if the effector agrees.</span>
57
+ <span class="ruby-comment cmt">#</span>
58
+ <span class="ruby-identifier">usedArgs</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">argList</span>.<span class="ruby-identifier">shift</span>) <span class="ruby-keyword kw">unless</span> (<span class="ruby-identifier">eContext</span>.<span class="ruby-identifier">reuseArg</span>)
59
+ <span class="ruby-keyword kw">end</span>
60
+ <span class="ruby-identifier">result</span>
61
+ <span class="ruby-keyword kw">end</span></pre>
62
+ </body>
63
+ </html>
@@ -0,0 +1 @@
1
+ Fri, 04 Dec 2009 01:20:04 -0500
@@ -0,0 +1,141 @@
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>File: fto.rb</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="fileHeader">
50
+ <h1>fto.rb</h1>
51
+ <table class="header-table">
52
+ <tr class="top-aligned-row">
53
+ <td><strong>Path:</strong></td>
54
+ <td>fto.rb
55
+ </td>
56
+ </tr>
57
+ <tr class="top-aligned-row">
58
+ <td><strong>Last Update:</strong></td>
59
+ <td>Tue Dec 01 19:13:47 -0500 2009</td>
60
+ </tr>
61
+ </table>
62
+ </div>
63
+ <!-- banner header -->
64
+
65
+ <div id="bodyContent">
66
+
67
+
68
+
69
+ <div id="contextContent">
70
+
71
+ <div id="description">
72
+ <h1>fto.rb - Formatted Text Output</h1>
73
+ <table>
74
+ <tr><td valign="top">Author:</td><td>Ken Coar
75
+
76
+ </td></tr>
77
+ <tr><td valign="top">Copyright:</td><td>Copyright (c) 2009 Ken Coar
78
+
79
+ </td></tr>
80
+ <tr><td valign="top">License:</td><td>Apache Licence 2.0
81
+
82
+ </td></tr>
83
+ </table>
84
+ <h1>Synopsis</h1>
85
+ <pre>
86
+ require 'fto'
87
+ Include FormatText
88
+ formatString = FTO.new(&quot;This will include a string: !AS&quot;, &quot;string1&quot;)
89
+ puts formatString.format
90
+ puts formatString.format(&quot;string2&quot;)
91
+ </pre>
92
+ <h1>Description</h1>
93
+ <p>
94
+ FTO is a Ruby library for formatting text strings. In function it is
95
+ similar to <tt>printf(3)</tt>; however, the syntax of the format effectors
96
+ (sometimes called &#8216;format descriptors&#8217;) and the selection of
97
+ effectors bundled with the package are based on the SYS$FAO user-mode
98
+ system service found on OpenVMS.
99
+ </p>
100
+ <p>
101
+ The FTO class is an extension of String, enhancing the constructor, adding
102
+ the format() instance method, and the registerEffector() class method.
103
+ </p>
104
+ <p>
105
+ In addition to the included list of effectors, FTO provides easy
106
+ extensibility by allowing the developer to write her own effector handlers
107
+ and registering them with FTO::registerEffector().
108
+ </p>
109
+
110
+ </div>
111
+
112
+
113
+ </div>
114
+
115
+
116
+ </div>
117
+
118
+
119
+ <!-- if includes -->
120
+
121
+ <div id="section">
122
+
123
+
124
+
125
+
126
+
127
+
128
+
129
+
130
+ <!-- if method_list -->
131
+
132
+
133
+ </div>
134
+
135
+
136
+ <div id="validator-badges">
137
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
138
+ </div>
139
+
140
+ </body>
141
+ </html>
@@ -0,0 +1,150 @@
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>File: fto.rb</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="fileHeader">
50
+ <h1>fto.rb</h1>
51
+ <table class="header-table">
52
+ <tr class="top-aligned-row">
53
+ <td><strong>Path:</strong></td>
54
+ <td>lib/fto.rb
55
+ </td>
56
+ </tr>
57
+ <tr class="top-aligned-row">
58
+ <td><strong>Last Update:</strong></td>
59
+ <td>Fri Dec 04 01:20:01 -0500 2009</td>
60
+ </tr>
61
+ </table>
62
+ </div>
63
+ <!-- banner header -->
64
+
65
+ <div id="bodyContent">
66
+
67
+
68
+
69
+ <div id="contextContent">
70
+
71
+ <div id="description">
72
+ <h1>fto.rb - Formatted Text Output</h1>
73
+ <table>
74
+ <tr><td valign="top">Author:</td><td>Ken Coar
75
+
76
+ </td></tr>
77
+ <tr><td valign="top">Copyright:</td><td>Copyright © 2009 Ken Coar
78
+
79
+ </td></tr>
80
+ <tr><td valign="top">License:</td><td>Apache Licence 2.0
81
+
82
+ </td></tr>
83
+ </table>
84
+ <h2>Synopsis</h2>
85
+ <pre>
86
+ require 'fto'
87
+ include FormatText
88
+ formatString = FTO.new(&quot;This will include a string: !AS&quot;, &quot;string1&quot;)
89
+ puts formatString.format
90
+ puts formatString.format(&quot;string2&quot;)
91
+ </pre>
92
+ <h2>Description</h2>
93
+ <p>
94
+ FTO is a Ruby library for formatting text strings. In function it is
95
+ similar to <tt>printf(3)</tt>; however, the syntax of the format effectors
96
+ (sometimes called &#8216;format descriptors&#8217;) and the selection of
97
+ effectors bundled with the package are based on the SYS$FAO user-mode
98
+ system service found on OpenVMS.
99
+ </p>
100
+ <p>
101
+ The FTO class is an extension of String, enhancing the constructor, adding
102
+ the <em>format()</em> instance method, and the <em>registerEffector()</em>
103
+ class method.
104
+ </p>
105
+ <p>
106
+ In addition to the included list of effectors, FTO provides easy
107
+ extensibility by allowing the developer to write her own effector handlers
108
+ and registering them with <em>FTO.registerEffector()</em>.
109
+ </p>
110
+
111
+ </div>
112
+
113
+ <div id="requires-list">
114
+ <h3 class="section-bar">Required files</h3>
115
+
116
+ <div class="name-list">
117
+ rubygems&nbsp;&nbsp;
118
+ gettext&nbsp;&nbsp;
119
+ </div>
120
+ </div>
121
+
122
+ </div>
123
+
124
+
125
+ </div>
126
+
127
+
128
+ <!-- if includes -->
129
+
130
+ <div id="section">
131
+
132
+
133
+
134
+
135
+
136
+
137
+
138
+
139
+ <!-- if method_list -->
140
+
141
+
142
+ </div>
143
+
144
+
145
+ <div id="validator-badges">
146
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
147
+ </div>
148
+
149
+ </body>
150
+ </html>