mongrel 0.3.6 → 0.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. data/README +28 -1
  2. data/Rakefile +2 -2
  3. data/bin/mongrel_rails +102 -65
  4. data/bin/mongrel_rails_service +16 -7
  5. data/bin/mongrel_rails_svc +184 -87
  6. data/doc/rdoc/classes/Mongrel.html +1 -0
  7. data/doc/rdoc/classes/Mongrel/Const.html +3 -3
  8. data/doc/rdoc/classes/Mongrel/HeaderOut.html +10 -10
  9. data/doc/rdoc/classes/Mongrel/HeaderOut.src/{M000028.html → M000014.html} +4 -4
  10. data/doc/rdoc/classes/Mongrel/HeaderOut.src/{M000029.html → M000015.html} +7 -7
  11. data/doc/rdoc/classes/Mongrel/HttpParser.html +35 -35
  12. data/doc/rdoc/classes/Mongrel/HttpParser.src/{M000015.html → M000001.html} +0 -0
  13. data/doc/rdoc/classes/Mongrel/HttpParser.src/{M000016.html → M000002.html} +0 -0
  14. data/doc/rdoc/classes/Mongrel/HttpParser.src/{M000017.html → M000003.html} +0 -0
  15. data/doc/rdoc/classes/Mongrel/HttpParser.src/{M000018.html → M000004.html} +0 -0
  16. data/doc/rdoc/classes/Mongrel/HttpParser.src/{M000019.html → M000005.html} +0 -0
  17. data/doc/rdoc/classes/Mongrel/HttpParser.src/{M000020.html → M000006.html} +0 -0
  18. data/doc/rdoc/classes/Mongrel/HttpParser.src/{M000021.html → M000007.html} +0 -0
  19. data/doc/rdoc/classes/Mongrel/HttpRequest.html +5 -5
  20. data/doc/rdoc/classes/Mongrel/HttpRequest.src/{M000041.html → M000029.html} +25 -25
  21. data/doc/rdoc/classes/Mongrel/HttpResponse.html +36 -36
  22. data/doc/rdoc/classes/Mongrel/HttpResponse.src/{M000034.html → M000016.html} +7 -7
  23. data/doc/rdoc/classes/Mongrel/HttpResponse.src/{M000035.html → M000017.html} +6 -6
  24. data/doc/rdoc/classes/Mongrel/HttpResponse.src/{M000036.html → M000018.html} +5 -5
  25. data/doc/rdoc/classes/Mongrel/HttpResponse.src/{M000037.html → M000019.html} +5 -5
  26. data/doc/rdoc/classes/Mongrel/HttpResponse.src/{M000038.html → M000020.html} +6 -6
  27. data/doc/rdoc/classes/Mongrel/HttpResponse.src/{M000039.html → M000021.html} +6 -6
  28. data/doc/rdoc/classes/Mongrel/HttpResponse.src/{M000040.html → M000022.html} +6 -6
  29. data/doc/rdoc/classes/Mongrel/HttpServer.html +34 -35
  30. data/doc/rdoc/classes/Mongrel/HttpServer.src/M000008.html +36 -0
  31. data/doc/rdoc/classes/Mongrel/HttpServer.src/{M000023.html → M000009.html} +43 -43
  32. data/doc/rdoc/classes/Mongrel/HttpServer.src/{M000024.html → M000010.html} +31 -31
  33. data/doc/rdoc/classes/Mongrel/HttpServer.src/{M000025.html → M000011.html} +4 -4
  34. data/doc/rdoc/classes/Mongrel/HttpServer.src/{M000026.html → M000012.html} +4 -4
  35. data/doc/rdoc/classes/Mongrel/HttpServer.src/M000013.html +23 -0
  36. data/doc/rdoc/classes/{FactoryError.html → Mongrel/TimeoutWorker.html} +7 -34
  37. data/doc/rdoc/classes/Mongrel/URIClassifier.html +63 -20
  38. data/doc/rdoc/classes/Mongrel/URIClassifier.src/M000023.html +18 -0
  39. data/doc/rdoc/classes/Mongrel/URIClassifier.src/M000024.html +18 -0
  40. data/doc/rdoc/classes/Mongrel/URIClassifier.src/{M000030.html → M000025.html} +0 -0
  41. data/doc/rdoc/classes/Mongrel/URIClassifier.src/{M000031.html → M000026.html} +0 -0
  42. data/doc/rdoc/classes/Mongrel/URIClassifier.src/{M000032.html → M000027.html} +0 -0
  43. data/doc/rdoc/classes/Mongrel/URIClassifier.src/{M000033.html → M000028.html} +0 -0
  44. data/doc/rdoc/created.rid +1 -1
  45. data/doc/rdoc/files/README.html +35 -2
  46. data/doc/rdoc/files/lib/mongrel_rb.html +4 -1
  47. data/doc/rdoc/fr_class_index.html +1 -2
  48. data/doc/rdoc/fr_file_index.html +0 -1
  49. data/doc/rdoc/fr_method_index.html +29 -41
  50. data/lib/mongrel.rb +37 -9
  51. data/lib/mongrel/command.rb +13 -34
  52. data/lib/mongrel/plugins.rb +156 -0
  53. data/lib/mongrel/rails.rb +70 -0
  54. data/test/plugins/commands/test1.rb +19 -0
  55. data/test/test_plugins.rb +45 -0
  56. data/test/test_uriclassifier.rb +5 -1
  57. metadata +38 -49
  58. data/doc/rdoc/classes/FactoryError.src/M000001.html +0 -23
  59. data/doc/rdoc/classes/Mongrel/HttpServer.src/M000022.html +0 -33
  60. data/doc/rdoc/classes/Mongrel/HttpServer.src/M000027.html +0 -19
  61. data/doc/rdoc/classes/PluginFactory.html +0 -409
  62. data/doc/rdoc/classes/PluginFactory.src/M000002.html +0 -18
  63. data/doc/rdoc/classes/PluginFactory.src/M000003.html +0 -18
  64. data/doc/rdoc/classes/PluginFactory.src/M000004.html +0 -22
  65. data/doc/rdoc/classes/PluginFactory.src/M000005.html +0 -22
  66. data/doc/rdoc/classes/PluginFactory.src/M000006.html +0 -33
  67. data/doc/rdoc/classes/PluginFactory.src/M000007.html +0 -32
  68. data/doc/rdoc/classes/PluginFactory.src/M000008.html +0 -18
  69. data/doc/rdoc/classes/PluginFactory.src/M000009.html +0 -24
  70. data/doc/rdoc/classes/PluginFactory.src/M000010.html +0 -40
  71. data/doc/rdoc/classes/PluginFactory.src/M000011.html +0 -39
  72. data/doc/rdoc/classes/PluginFactory.src/M000012.html +0 -24
  73. data/doc/rdoc/classes/PluginFactory.src/M000013.html +0 -70
  74. data/doc/rdoc/classes/PluginFactory.src/M000014.html +0 -34
  75. data/doc/rdoc/files/lib/pluginfactory_rb.html +0 -132
  76. data/lib/pluginfactory.rb +0 -384
@@ -1,18 +0,0 @@
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>log (PluginFactory)</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/pluginfactory.rb, line 111</span>
14
- 111: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span><span class="ruby-operator">::</span><span class="ruby-identifier">log</span>(<span class="ruby-identifier">level</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">msg</span>)
15
- 112: <span class="ruby-ivar">@logger_callback</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">level</span>, <span class="ruby-identifier">msg</span>.<span class="ruby-identifier">join</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@logger_callback</span>
16
- 113: <span class="ruby-keyword kw">end</span></pre>
17
- </body>
18
- </html>
@@ -1,18 +0,0 @@
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>included (PluginFactory)</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/pluginfactory.rb, line 117</span>
14
- 117: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span><span class="ruby-operator">::</span><span class="ruby-identifier">included</span>( <span class="ruby-identifier">klass</span> )
15
- 118: <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">extend</span>( <span class="ruby-keyword kw">self</span> )
16
- 119: <span class="ruby-keyword kw">end</span></pre>
17
- </body>
18
- </html>
@@ -1,22 +0,0 @@
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>extend_object (PluginFactory)</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/pluginfactory.rb, line 124</span>
14
- 124: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span><span class="ruby-operator">::</span><span class="ruby-identifier">extend_object</span>( <span class="ruby-identifier">obj</span> )
15
- 125: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">is_a?</span>( <span class="ruby-constant">Class</span> )
16
- 126: <span class="ruby-identifier">raise</span> <span class="ruby-constant">TypeError</span>, <span class="ruby-node">&quot;Cannot extend a #{obj.class.name}&quot;</span>, <span class="ruby-identifier">caller</span>(<span class="ruby-value">1</span>)
17
- 127: <span class="ruby-keyword kw">end</span>
18
- 128: <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">instance_variable_set</span>( <span class="ruby-identifier">:@derivatives</span>, {} )
19
- 129: <span class="ruby-keyword kw">super</span>
20
- 130: <span class="ruby-keyword kw">end</span></pre>
21
- </body>
22
- </html>
@@ -1,22 +0,0 @@
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>derivatives (PluginFactory)</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/pluginfactory.rb, line 139</span>
14
- 139: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">derivatives</span>
15
- 140: <span class="ruby-identifier">ancestors</span>.<span class="ruby-identifier">each</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">klass</span><span class="ruby-operator">|</span>
16
- 141: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">instance_variables</span>.<span class="ruby-identifier">include?</span>( <span class="ruby-value str">&quot;@derivatives&quot;</span> )
17
- 142: <span class="ruby-keyword kw">break</span> <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">instance_variable_get</span>( <span class="ruby-identifier">:@derivatives</span> )
18
- 143: <span class="ruby-keyword kw">end</span>
19
- 144: }
20
- 145: <span class="ruby-keyword kw">end</span></pre>
21
- </body>
22
- </html>
@@ -1,33 +0,0 @@
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>factoryType (PluginFactory)</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/pluginfactory.rb, line 149</span>
14
- 149: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">factoryType</span>
15
- 150: <span class="ruby-identifier">base</span> = <span class="ruby-keyword kw">nil</span>
16
- 151: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">ancestors</span>.<span class="ruby-identifier">each</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">klass</span><span class="ruby-operator">|</span>
17
- 152: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">instance_variables</span>.<span class="ruby-identifier">include?</span>( <span class="ruby-value str">&quot;@derivatives&quot;</span> )
18
- 153: <span class="ruby-identifier">base</span> = <span class="ruby-identifier">klass</span>
19
- 154: <span class="ruby-keyword kw">break</span>
20
- 155: <span class="ruby-keyword kw">end</span>
21
- 156: }
22
- 157:
23
- 158: <span class="ruby-identifier">raise</span> <span class="ruby-constant">FactoryError</span>, <span class="ruby-node">&quot;Couldn't find factory base for #{self.name}&quot;</span> <span class="ruby-keyword kw">if</span>
24
- 159: <span class="ruby-identifier">base</span>.<span class="ruby-identifier">nil?</span>
25
- 160:
26
- 161: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">base</span>.<span class="ruby-identifier">name</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/^.*::(.*)/</span>
27
- 162: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">$1</span>
28
- 163: <span class="ruby-keyword kw">else</span>
29
- 164: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">base</span>.<span class="ruby-identifier">name</span>
30
- 165: <span class="ruby-keyword kw">end</span>
31
- 166: <span class="ruby-keyword kw">end</span></pre>
32
- </body>
33
- </html>
@@ -1,32 +0,0 @@
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>inherited (PluginFactory)</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/pluginfactory.rb, line 171</span>
14
- 171: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">inherited</span>( <span class="ruby-identifier">subclass</span> )
15
- 172: <span class="ruby-identifier">keys</span> = [ <span class="ruby-identifier">subclass</span>.<span class="ruby-identifier">name</span>, <span class="ruby-identifier">subclass</span>.<span class="ruby-identifier">name</span>.<span class="ruby-identifier">downcase</span>, <span class="ruby-identifier">subclass</span> ]
16
- 173:
17
- 174: <span class="ruby-comment cmt"># Handle class names like 'FooBar' for 'Bar' factories.</span>
18
- 175: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">subclass</span>.<span class="ruby-identifier">name</span>.<span class="ruby-identifier">match</span>( <span class="ruby-node">/(?:.*::)?(\w+)(?:#{self.factoryType})/i</span> )
19
- 176: <span class="ruby-identifier">keys</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">last_match</span>[<span class="ruby-value">1</span>].<span class="ruby-identifier">downcase</span>
20
- 177: <span class="ruby-keyword kw">else</span>
21
- 178: <span class="ruby-identifier">keys</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">subclass</span>.<span class="ruby-identifier">name</span>.<span class="ruby-identifier">sub</span>( <span class="ruby-regexp re">/.*::/</span>, <span class="ruby-value str">''</span> ).<span class="ruby-identifier">downcase</span>
22
- 179: <span class="ruby-keyword kw">end</span>
23
- 180:
24
- 181: <span class="ruby-identifier">keys</span>.<span class="ruby-identifier">uniq</span>.<span class="ruby-identifier">each</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">key</span><span class="ruby-operator">|</span>
25
- 182: <span class="ruby-comment cmt">#PluginFactory::log :info, &quot;Registering %s derivative of %s as %p&quot; %</span>
26
- 183: <span class="ruby-comment cmt"># [ subclass.name, self.name, key ]</span>
27
- 184: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">derivatives</span>[ <span class="ruby-identifier">key</span> ] = <span class="ruby-identifier">subclass</span>
28
- 185: }
29
- 186: <span class="ruby-keyword kw">super</span>
30
- 187: <span class="ruby-keyword kw">end</span></pre>
31
- </body>
32
- </html>
@@ -1,18 +0,0 @@
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>derivativeClasses (PluginFactory)</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/pluginfactory.rb, line 191</span>
14
- 191: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">derivativeClasses</span>
15
- 192: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">derivatives</span>.<span class="ruby-identifier">values</span>.<span class="ruby-identifier">uniq</span>
16
- 193: <span class="ruby-keyword kw">end</span></pre>
17
- </body>
18
- </html>
@@ -1,24 +0,0 @@
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>create (PluginFactory)</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/pluginfactory.rb, line 208</span>
14
- 208: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">create</span>( <span class="ruby-identifier">subType</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span> )
15
- 209: <span class="ruby-identifier">subclass</span> = <span class="ruby-identifier">getSubclass</span>( <span class="ruby-identifier">subType</span> )
16
- 210:
17
- 211: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">subclass</span>.<span class="ruby-identifier">new</span>( <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span> )
18
- 212: <span class="ruby-keyword kw">rescue</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">err</span>
19
- 213: <span class="ruby-identifier">nicetrace</span> = <span class="ruby-identifier">err</span>.<span class="ruby-identifier">backtrace</span>.<span class="ruby-identifier">reject</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">frame</span><span class="ruby-operator">|</span> <span class="ruby-node">/#{__FILE__}/</span> <span class="ruby-operator">=~</span> <span class="ruby-identifier">frame</span>}
20
- 214: <span class="ruby-identifier">msg</span> = <span class="ruby-node">&quot;When creating '#{subType}': &quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">err</span>.<span class="ruby-identifier">message</span>
21
- 215: <span class="ruby-constant">Kernel</span><span class="ruby-operator">::</span><span class="ruby-identifier">raise</span>( <span class="ruby-identifier">err</span>.<span class="ruby-identifier">class</span>, <span class="ruby-identifier">msg</span>, <span class="ruby-identifier">nicetrace</span> )
22
- 216: <span class="ruby-keyword kw">end</span></pre>
23
- </body>
24
- </html>
@@ -1,40 +0,0 @@
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>getSubclass (PluginFactory)</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/pluginfactory.rb, line 222</span>
14
- 222: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">getSubclass</span>( <span class="ruby-identifier">className</span> )
15
- 223: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">self</span> <span class="ruby-keyword kw">if</span> ( <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">name</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">className</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">className</span> <span class="ruby-operator">==</span> <span class="ruby-value str">''</span> )
16
- 224: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">className</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">className</span>.<span class="ruby-identifier">is_a?</span>( <span class="ruby-constant">Class</span> ) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">className</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-keyword kw">self</span>
17
- 225:
18
- 226: <span class="ruby-keyword kw">unless</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">derivatives</span>.<span class="ruby-identifier">has_key?</span>( <span class="ruby-identifier">className</span>.<span class="ruby-identifier">downcase</span> )
19
- 227: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">loadDerivative</span>( <span class="ruby-identifier">className</span> )
20
- 228:
21
- 229: <span class="ruby-keyword kw">unless</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">derivatives</span>.<span class="ruby-identifier">has_key?</span>( <span class="ruby-identifier">className</span>.<span class="ruby-identifier">downcase</span> )
22
- 230: <span class="ruby-identifier">raise</span> <span class="ruby-constant">FactoryError</span>,
23
- 231: <span class="ruby-value str">&quot;loadDerivative(%s) didn't add a '%s' key to the &quot;</span>\
24
- 232: <span class="ruby-value str">&quot;registry for %s&quot;</span> <span class="ruby-operator">%</span>
25
- 233: [ <span class="ruby-identifier">className</span>, <span class="ruby-identifier">className</span>.<span class="ruby-identifier">downcase</span>, <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">name</span> ]
26
- 234: <span class="ruby-keyword kw">end</span>
27
- 235:
28
- 236: <span class="ruby-identifier">subclass</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">derivatives</span>[ <span class="ruby-identifier">className</span>.<span class="ruby-identifier">downcase</span> ]
29
- 237: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">subclass</span>.<span class="ruby-identifier">is_a?</span>( <span class="ruby-constant">Class</span> )
30
- 238: <span class="ruby-identifier">raise</span> <span class="ruby-constant">FactoryError</span>,
31
- 239: <span class="ruby-value str">&quot;loadDerivative(%s) added something other than a class &quot;</span>\
32
- 240: <span class="ruby-value str">&quot;to the registry for %s: %p&quot;</span> <span class="ruby-operator">%</span>
33
- 241: [ <span class="ruby-identifier">className</span>, <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">name</span>, <span class="ruby-identifier">subclass</span> ]
34
- 242: <span class="ruby-keyword kw">end</span>
35
- 243: <span class="ruby-keyword kw">end</span>
36
- 244:
37
- 245: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">derivatives</span>[ <span class="ruby-identifier">className</span>.<span class="ruby-identifier">downcase</span> ]
38
- 246: <span class="ruby-keyword kw">end</span></pre>
39
- </body>
40
- </html>
@@ -1,39 +0,0 @@
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>loadDerivative (PluginFactory)</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/pluginfactory.rb, line 258</span>
14
- 258: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">loadDerivative</span>( <span class="ruby-identifier">className</span> )
15
- 259: <span class="ruby-identifier">className</span> = <span class="ruby-identifier">className</span>.<span class="ruby-identifier">to_s</span>
16
- 260:
17
- 261: <span class="ruby-comment cmt">#PluginFactory::log :debug, &quot;Loading derivative #{className}&quot;</span>
18
- 262:
19
- 263: <span class="ruby-comment cmt"># Get the unique part of the derived class name and try to</span>
20
- 264: <span class="ruby-comment cmt"># load it from one of the derivative subdirs, if there are</span>
21
- 265: <span class="ruby-comment cmt"># any.</span>
22
- 266: <span class="ruby-identifier">modName</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">getModuleName</span>( <span class="ruby-identifier">className</span> )
23
- 267: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">requireDerivative</span>( <span class="ruby-identifier">modName</span> )
24
- 268:
25
- 269: <span class="ruby-comment cmt"># Check to see if the specified listener is now loaded. If it</span>
26
- 270: <span class="ruby-comment cmt"># is not, raise an error to that effect.</span>
27
- 271: <span class="ruby-keyword kw">unless</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">derivatives</span>[ <span class="ruby-identifier">className</span>.<span class="ruby-identifier">downcase</span> ]
28
- 272: <span class="ruby-identifier">raise</span> <span class="ruby-constant">FactoryError</span>,
29
- 273: <span class="ruby-value str">&quot;Couldn't find a %s named '%s'. Loaded derivatives are: %p&quot;</span> <span class="ruby-operator">%</span> [
30
- 274: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">factoryType</span>,
31
- 275: <span class="ruby-identifier">className</span>.<span class="ruby-identifier">downcase</span>,
32
- 276: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">derivatives</span>.<span class="ruby-identifier">keys</span>,
33
- 277: ], <span class="ruby-identifier">caller</span>(<span class="ruby-value">3</span>)
34
- 278: <span class="ruby-keyword kw">end</span>
35
- 279:
36
- 280: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span>
37
- 281: <span class="ruby-keyword kw">end</span></pre>
38
- </body>
39
- </html>
@@ -1,24 +0,0 @@
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>getModuleName (PluginFactory)</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/pluginfactory.rb, line 288</span>
14
- 288: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">getModuleName</span>( <span class="ruby-identifier">className</span> )
15
- 289: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">className</span> <span class="ruby-operator">=~</span> <span class="ruby-node">/\w+#{self.factoryType}/</span>
16
- 290: <span class="ruby-identifier">modName</span> = <span class="ruby-identifier">className</span>.<span class="ruby-identifier">sub</span>( <span class="ruby-node">/(?:.*::)?(\w+)(?:#{self.factoryType})/</span>, <span class="ruby-value str">&quot;\\1&quot;</span> )
17
- 291: <span class="ruby-keyword kw">else</span>
18
- 292: <span class="ruby-identifier">modName</span> = <span class="ruby-identifier">className</span>
19
- 293: <span class="ruby-keyword kw">end</span>
20
- 294:
21
- 295: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">modName</span>
22
- 296: <span class="ruby-keyword kw">end</span></pre>
23
- </body>
24
- </html>
@@ -1,70 +0,0 @@
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>requireDerivative (PluginFactory)</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/pluginfactory.rb, line 302</span>
14
- 302: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">requireDerivative</span>( <span class="ruby-identifier">modName</span> )
15
- 303:
16
- 304: <span class="ruby-comment cmt"># See if we have a list of special subdirs that derivatives</span>
17
- 305: <span class="ruby-comment cmt"># live in</span>
18
- 306: <span class="ruby-keyword kw">if</span> ( <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:derivativeDirs</span>) )
19
- 307: <span class="ruby-identifier">subdirs</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">derivativeDirs</span>
20
- 308: <span class="ruby-identifier">subdirs</span> = [ <span class="ruby-identifier">subdirs</span> ] <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">subdirs</span>.<span class="ruby-identifier">is_a?</span>( <span class="ruby-constant">Array</span> )
21
- 309:
22
- 310: <span class="ruby-comment cmt"># If not, just try requiring it from $LOAD_PATH</span>
23
- 311: <span class="ruby-keyword kw">else</span>
24
- 312: <span class="ruby-identifier">subdirs</span> = [<span class="ruby-value str">''</span>]
25
- 313: <span class="ruby-keyword kw">end</span>
26
- 314:
27
- 315: <span class="ruby-identifier">fatals</span> = []
28
- 316:
29
- 317: <span class="ruby-comment cmt"># Iterate over the subdirs until we successfully require a</span>
30
- 318: <span class="ruby-comment cmt"># module.</span>
31
- 319: <span class="ruby-identifier">catch</span>( <span class="ruby-identifier">:found</span> ) {
32
- 320: <span class="ruby-identifier">subdirs</span>.<span class="ruby-identifier">collect</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">dir</span><span class="ruby-operator">|</span> <span class="ruby-identifier">dir</span>.<span class="ruby-identifier">strip</span>}.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">subdir</span><span class="ruby-operator">|</span>
33
- 321: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">makeRequirePath</span>( <span class="ruby-identifier">modName</span>, <span class="ruby-identifier">subdir</span> ).<span class="ruby-identifier">each</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">path</span><span class="ruby-operator">|</span>
34
- 322: <span class="ruby-comment cmt">#PluginFactory::log :debug, &quot;Trying #{path}...&quot;</span>
35
- 323:
36
- 324: <span class="ruby-comment cmt"># Try to require the module, saving errors and jumping</span>
37
- 325: <span class="ruby-comment cmt"># out of the catch block on success.</span>
38
- 326: <span class="ruby-keyword kw">begin</span>
39
- 327: <span class="ruby-identifier">require</span>( <span class="ruby-identifier">path</span>.<span class="ruby-identifier">untaint</span> )
40
- 328: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">LoadError</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">err</span>
41
- 329: <span class="ruby-constant">PluginFactory</span><span class="ruby-operator">::</span><span class="ruby-identifier">log</span> <span class="ruby-identifier">:debug</span>,
42
- 330: <span class="ruby-value str">&quot;No module at '%s', trying the next alternative: '%s'&quot;</span> <span class="ruby-operator">%</span>
43
- 331: [ <span class="ruby-identifier">path</span>, <span class="ruby-identifier">err</span>.<span class="ruby-identifier">message</span> ]
44
- 332: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">ScriptError</span>,<span class="ruby-constant">StandardError</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">err</span>
45
- 333: <span class="ruby-identifier">fatals</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">err</span>
46
- 334: <span class="ruby-constant">PluginFactory</span><span class="ruby-operator">::</span><span class="ruby-identifier">log</span> <span class="ruby-identifier">:error</span>,
47
- 335: <span class="ruby-node">&quot;Found '#{path}', but encountered an error: %s\n\t%s&quot;</span> <span class="ruby-operator">%</span>
48
- 336: [ <span class="ruby-identifier">err</span>.<span class="ruby-identifier">message</span>, <span class="ruby-identifier">err</span>.<span class="ruby-identifier">backtrace</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">&quot;\n\t&quot;</span>) ]
49
- 337: <span class="ruby-keyword kw">else</span>
50
- 338: <span class="ruby-comment cmt">#PluginFactory::log :debug, </span>
51
- 339: <span class="ruby-comment cmt"># &quot;Found '#{path}'. Throwing :found&quot;</span>
52
- 340: <span class="ruby-identifier">throw</span> <span class="ruby-identifier">:found</span>
53
- 341: <span class="ruby-keyword kw">end</span>
54
- 342: }
55
- 343: <span class="ruby-keyword kw">end</span>
56
- 344:
57
- 345: <span class="ruby-comment cmt">#PluginFactory::log :debug, &quot;fatals = %p&quot; % [ fatals ]</span>
58
- 346:
59
- 347: <span class="ruby-comment cmt"># Re-raise is there was a file found, but it didn't load for</span>
60
- 348: <span class="ruby-comment cmt"># some reason.</span>
61
- 349: <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span> <span class="ruby-identifier">fatals</span>.<span class="ruby-identifier">empty?</span>
62
- 350: <span class="ruby-comment cmt">#PluginFactory::log :debug, &quot;Re-raising first fatal error&quot;</span>
63
- 351: <span class="ruby-constant">Kernel</span><span class="ruby-operator">::</span><span class="ruby-identifier">raise</span>( <span class="ruby-identifier">fatals</span>.<span class="ruby-identifier">first</span> )
64
- 352: <span class="ruby-keyword kw">end</span>
65
- 353:
66
- 354: <span class="ruby-keyword kw">nil</span>
67
- 355: }
68
- 356: <span class="ruby-keyword kw">end</span></pre>
69
- </body>
70
- </html>
@@ -1,34 +0,0 @@
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>makeRequirePath (PluginFactory)</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/pluginfactory.rb, line 364</span>
14
- 364: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">makeRequirePath</span>( <span class="ruby-identifier">modname</span>, <span class="ruby-identifier">subdir</span> )
15
- 365: <span class="ruby-identifier">path</span> = []
16
- 366: <span class="ruby-identifier">myname</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">factoryType</span>
17
- 367:
18
- 368: <span class="ruby-comment cmt"># Make permutations of the two parts</span>
19
- 369: <span class="ruby-identifier">path</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">modname</span>
20
- 370: <span class="ruby-identifier">path</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">modname</span>.<span class="ruby-identifier">downcase</span>
21
- 371: <span class="ruby-identifier">path</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">modname</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">myname</span>
22
- 372: <span class="ruby-identifier">path</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">modname</span>.<span class="ruby-identifier">downcase</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">myname</span>
23
- 373: <span class="ruby-identifier">path</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">modname</span>.<span class="ruby-identifier">downcase</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">myname</span>.<span class="ruby-identifier">downcase</span>
24
- 374:
25
- 375: <span class="ruby-comment cmt"># If a non-empty subdir was given, prepend it to all the items in the</span>
26
- 376: <span class="ruby-comment cmt"># path</span>
27
- 377: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">subdir</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">subdir</span>.<span class="ruby-identifier">empty?</span>
28
- 378: <span class="ruby-identifier">path</span>.<span class="ruby-identifier">collect!</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">m</span><span class="ruby-operator">|</span> <span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-identifier">join</span>(<span class="ruby-identifier">subdir</span>, <span class="ruby-identifier">m</span>)}
29
- 379: <span class="ruby-keyword kw">end</span>
30
- 380:
31
- 381: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">path</span>.<span class="ruby-identifier">uniq</span>.<span class="ruby-identifier">reverse</span>
32
- 382: <span class="ruby-keyword kw">end</span></pre>
33
- </body>
34
- </html>
@@ -1,132 +0,0 @@
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: pluginfactory.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>pluginfactory.rb</h1>
51
- <table class="header-table">
52
- <tr class="top-aligned-row">
53
- <td><strong>Path:</strong></td>
54
- <td>lib/pluginfactory.rb
55
- </td>
56
- </tr>
57
- <tr class="top-aligned-row">
58
- <td><strong>Last Update:</strong></td>
59
- <td>Sat Feb 11 22:57:24 EST 2006</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
- <p>
73
- This module contains the <a
74
- href="../../classes/PluginFactory.html">PluginFactory</a> mixin. Including
75
- <a href="../../classes/PluginFactory.html">PluginFactory</a> in your class
76
- turns it into a factory for its derivatives, capable of searching for and
77
- loading them by name. This is useful when you have an abstract base class
78
- which defines an interface and basic functionality for a part of a larger
79
- system, and a collection of subclasses which implement the interface for
80
- different underlying functionality.
81
- </p>
82
- <p>
83
- An example of where this might be useful is in a program which talks to a
84
- database. To avoid coupling it to a specific database, you use a Driver
85
- class which encapsulates your program&#8217;s interaction with the database
86
- behind a useful interface. Now you can create a concrete implementation of
87
- the Driver class for each kind of database you wish to talk to. If you make
88
- the base Driver class a <a
89
- href="../../classes/PluginFactory.html">PluginFactory</a>, too, you can add
90
- new drivers simply by dropping them in a directory and using the
91
- Driver&#8217;s <tt>create</tt> method to instantiate them:
92
- </p>
93
- <h2>Creation Argument Variants</h2>
94
- <p>
95
- The <tt>create</tt> class method added to your class by <a
96
- href="../../classes/PluginFactory.html">PluginFactory</a> searches for your
97
- module using
98
- </p>
99
- <h2>Synopsis</h2>
100
-
101
- </div>
102
-
103
-
104
- </div>
105
-
106
-
107
- </div>
108
-
109
-
110
- <!-- if includes -->
111
-
112
- <div id="section">
113
-
114
-
115
-
116
-
117
-
118
-
119
-
120
-
121
- <!-- if method_list -->
122
-
123
-
124
- </div>
125
-
126
-
127
- <div id="validator-badges">
128
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
129
- </div>
130
-
131
- </body>
132
- </html>