mongrel 0.3.6 → 0.3.7

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -0,0 +1,45 @@
1
+ require 'test/unit'
2
+ require 'mongrel'
3
+
4
+ class ATestPlugin < Mongrel::Plugin "/stuff"
5
+ end
6
+
7
+
8
+ include Mongrel
9
+
10
+ class PluginTest < Test::Unit::TestCase
11
+
12
+ def setup
13
+ @pmgr = PluginManager.instance
14
+ @categories = ["/commands"]
15
+ @names = ["/first","/second","/last", "/atestplugin"]
16
+ end
17
+
18
+ def test_load_plugins
19
+ @pmgr.load(File.join(File.dirname(__FILE__),"plugins"))
20
+ puts "#{@pmgr.available.inspect}"
21
+ @pmgr.available.each {|cat,plugins|
22
+ plugins.each do |p|
23
+ puts "TEST: #{cat}#{p}"
24
+ assert @names.include?(p)
25
+ end
26
+ }
27
+
28
+ @pmgr.available.each do |cat,plugins|
29
+ plugins.each do |p|
30
+ STDERR.puts "#{cat}#{p}"
31
+ plugin = @pmgr.create("#{cat}#{p}", options={"name" => p})
32
+ end
33
+ end
34
+ end
35
+
36
+ def test_similar_uris
37
+
38
+ @pmgr.register("/test", "/testme", ATestPlugin)
39
+ @pmgr.register("/test2", "/testme", ATestPlugin)
40
+
41
+ assert_equal @pmgr.create("/test/testme").class, ATestPlugin
42
+ assert_equal @pmgr.create("/test2/testme").class, ATestPlugin
43
+
44
+ end
45
+ end
@@ -30,7 +30,9 @@ class URIClassifierTest < Test::Unit::TestCase
30
30
  assert val != nil, "didn't resolve"
31
31
  assert_equal prefix,sn, "wrong script name"
32
32
  assert_equal test[sn.length .. -1],pi, "wrong path info"
33
-
33
+
34
+ assert u.inspect != nil, "No inspect for classifier"
35
+ assert u.uris[0] == prefix, "URI list didn't match"
34
36
  end
35
37
 
36
38
  def test_not_finding
@@ -172,5 +174,7 @@ class URIClassifierTest < Test::Unit::TestCase
172
174
  assert_equal root,sn, "didn't get right script name"
173
175
  assert_equal 1,h, "didn't find handler"
174
176
  end
177
+
178
+
175
179
  end
176
180
 
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
3
3
  specification_version: 1
4
4
  name: mongrel
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.3.6
7
- date: 2006-02-22 00:00:00 -05:00
6
+ version: 0.3.7
7
+ date: 2006-03-02 00:00:00 -05:00
8
8
  summary: A small fast HTTP library and server that runs Rails, Camping, and Nitro apps.
9
9
  require_paths:
10
10
  - lib
@@ -45,13 +45,8 @@ files:
45
45
  - doc/rdoc/fr_method_index.html
46
46
  - doc/rdoc/index.html
47
47
  - doc/rdoc/rdoc-style.css
48
- - doc/rdoc/classes/FactoryError.html
49
- - doc/rdoc/classes/FactoryError.src
50
48
  - doc/rdoc/classes/Mongrel
51
49
  - doc/rdoc/classes/Mongrel.html
52
- - doc/rdoc/classes/PluginFactory.html
53
- - doc/rdoc/classes/PluginFactory.src
54
- - doc/rdoc/classes/FactoryError.src/M000001.html
55
50
  - doc/rdoc/classes/Mongrel/Const.html
56
51
  - doc/rdoc/classes/Mongrel/HeaderOut.html
57
52
  - doc/rdoc/classes/Mongrel/HeaderOut.src
@@ -64,48 +59,38 @@ files:
64
59
  - doc/rdoc/classes/Mongrel/HttpServer.html
65
60
  - doc/rdoc/classes/Mongrel/HttpServer.src
66
61
  - doc/rdoc/classes/Mongrel/StopServer.html
62
+ - doc/rdoc/classes/Mongrel/TimeoutWorker.html
67
63
  - doc/rdoc/classes/Mongrel/URIClassifier.html
68
64
  - doc/rdoc/classes/Mongrel/URIClassifier.src
69
- - doc/rdoc/classes/Mongrel/HeaderOut.src/M000028.html
70
- - doc/rdoc/classes/Mongrel/HeaderOut.src/M000029.html
71
- - doc/rdoc/classes/Mongrel/HttpParser.src/M000015.html
72
- - doc/rdoc/classes/Mongrel/HttpParser.src/M000016.html
73
- - doc/rdoc/classes/Mongrel/HttpParser.src/M000017.html
74
- - doc/rdoc/classes/Mongrel/HttpParser.src/M000018.html
75
- - doc/rdoc/classes/Mongrel/HttpParser.src/M000019.html
76
- - doc/rdoc/classes/Mongrel/HttpParser.src/M000020.html
77
- - doc/rdoc/classes/Mongrel/HttpParser.src/M000021.html
78
- - doc/rdoc/classes/Mongrel/HttpRequest.src/M000041.html
79
- - doc/rdoc/classes/Mongrel/HttpResponse.src/M000034.html
80
- - doc/rdoc/classes/Mongrel/HttpResponse.src/M000035.html
81
- - doc/rdoc/classes/Mongrel/HttpResponse.src/M000036.html
82
- - doc/rdoc/classes/Mongrel/HttpResponse.src/M000037.html
83
- - doc/rdoc/classes/Mongrel/HttpResponse.src/M000038.html
84
- - doc/rdoc/classes/Mongrel/HttpResponse.src/M000039.html
85
- - doc/rdoc/classes/Mongrel/HttpResponse.src/M000040.html
86
- - doc/rdoc/classes/Mongrel/HttpServer.src/M000022.html
87
- - doc/rdoc/classes/Mongrel/HttpServer.src/M000023.html
88
- - doc/rdoc/classes/Mongrel/HttpServer.src/M000024.html
89
- - doc/rdoc/classes/Mongrel/HttpServer.src/M000025.html
90
- - doc/rdoc/classes/Mongrel/HttpServer.src/M000026.html
91
- - doc/rdoc/classes/Mongrel/HttpServer.src/M000027.html
92
- - doc/rdoc/classes/Mongrel/URIClassifier.src/M000030.html
93
- - doc/rdoc/classes/Mongrel/URIClassifier.src/M000031.html
94
- - doc/rdoc/classes/Mongrel/URIClassifier.src/M000032.html
95
- - doc/rdoc/classes/Mongrel/URIClassifier.src/M000033.html
96
- - doc/rdoc/classes/PluginFactory.src/M000002.html
97
- - doc/rdoc/classes/PluginFactory.src/M000003.html
98
- - doc/rdoc/classes/PluginFactory.src/M000004.html
99
- - doc/rdoc/classes/PluginFactory.src/M000005.html
100
- - doc/rdoc/classes/PluginFactory.src/M000006.html
101
- - doc/rdoc/classes/PluginFactory.src/M000007.html
102
- - doc/rdoc/classes/PluginFactory.src/M000008.html
103
- - doc/rdoc/classes/PluginFactory.src/M000009.html
104
- - doc/rdoc/classes/PluginFactory.src/M000010.html
105
- - doc/rdoc/classes/PluginFactory.src/M000011.html
106
- - doc/rdoc/classes/PluginFactory.src/M000012.html
107
- - doc/rdoc/classes/PluginFactory.src/M000013.html
108
- - doc/rdoc/classes/PluginFactory.src/M000014.html
65
+ - doc/rdoc/classes/Mongrel/HeaderOut.src/M000014.html
66
+ - doc/rdoc/classes/Mongrel/HeaderOut.src/M000015.html
67
+ - doc/rdoc/classes/Mongrel/HttpParser.src/M000001.html
68
+ - doc/rdoc/classes/Mongrel/HttpParser.src/M000002.html
69
+ - doc/rdoc/classes/Mongrel/HttpParser.src/M000003.html
70
+ - doc/rdoc/classes/Mongrel/HttpParser.src/M000004.html
71
+ - doc/rdoc/classes/Mongrel/HttpParser.src/M000005.html
72
+ - doc/rdoc/classes/Mongrel/HttpParser.src/M000006.html
73
+ - doc/rdoc/classes/Mongrel/HttpParser.src/M000007.html
74
+ - doc/rdoc/classes/Mongrel/HttpRequest.src/M000029.html
75
+ - doc/rdoc/classes/Mongrel/HttpResponse.src/M000016.html
76
+ - doc/rdoc/classes/Mongrel/HttpResponse.src/M000017.html
77
+ - doc/rdoc/classes/Mongrel/HttpResponse.src/M000018.html
78
+ - doc/rdoc/classes/Mongrel/HttpResponse.src/M000019.html
79
+ - doc/rdoc/classes/Mongrel/HttpResponse.src/M000020.html
80
+ - doc/rdoc/classes/Mongrel/HttpResponse.src/M000021.html
81
+ - doc/rdoc/classes/Mongrel/HttpResponse.src/M000022.html
82
+ - doc/rdoc/classes/Mongrel/HttpServer.src/M000008.html
83
+ - doc/rdoc/classes/Mongrel/HttpServer.src/M000009.html
84
+ - doc/rdoc/classes/Mongrel/HttpServer.src/M000010.html
85
+ - doc/rdoc/classes/Mongrel/HttpServer.src/M000011.html
86
+ - doc/rdoc/classes/Mongrel/HttpServer.src/M000012.html
87
+ - doc/rdoc/classes/Mongrel/HttpServer.src/M000013.html
88
+ - doc/rdoc/classes/Mongrel/URIClassifier.src/M000023.html
89
+ - doc/rdoc/classes/Mongrel/URIClassifier.src/M000024.html
90
+ - doc/rdoc/classes/Mongrel/URIClassifier.src/M000025.html
91
+ - doc/rdoc/classes/Mongrel/URIClassifier.src/M000026.html
92
+ - doc/rdoc/classes/Mongrel/URIClassifier.src/M000027.html
93
+ - doc/rdoc/classes/Mongrel/URIClassifier.src/M000028.html
109
94
  - doc/rdoc/files/COPYING.html
110
95
  - doc/rdoc/files/ext
111
96
  - doc/rdoc/files/lib
@@ -114,18 +99,22 @@ files:
114
99
  - doc/rdoc/files/ext/http11
115
100
  - doc/rdoc/files/ext/http11/http11_c.html
116
101
  - doc/rdoc/files/lib/mongrel_rb.html
117
- - doc/rdoc/files/lib/pluginfactory_rb.html
102
+ - test/plugins
118
103
  - test/test_http11.rb
104
+ - test/test_plugins.rb
119
105
  - test/test_response.rb
120
106
  - test/test_uriclassifier.rb
121
107
  - test/test_ws.rb
108
+ - test/plugins/commands
109
+ - test/plugins/commands/test1.rb
122
110
  - lib/mongrel
123
111
  - lib/mongrel.rb
124
- - lib/pluginfactory.rb
125
112
  - lib/mongrel/cgi.rb
126
113
  - lib/mongrel/command
127
114
  - lib/mongrel/command.rb
128
115
  - lib/mongrel/handlers.rb
116
+ - lib/mongrel/plugins.rb
117
+ - lib/mongrel/rails.rb
129
118
  - ext/http11/ext_help.h
130
119
  - ext/http11/http11_parser.h
131
120
  - ext/http11/tst.h
@@ -1,23 +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>new (FactoryError)</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 87</span>
14
- 87: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>( <span class="ruby-operator">*</span><span class="ruby-identifier">args</span> )
15
- 88: <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">empty?</span>
16
- 89: <span class="ruby-identifier">msg</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">collect</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">a</span><span class="ruby-operator">|</span> <span class="ruby-identifier">a</span>.<span class="ruby-identifier">to_s</span>}.<span class="ruby-identifier">join</span>
17
- 90: <span class="ruby-keyword kw">super</span>( <span class="ruby-identifier">msg</span> )
18
- 91: <span class="ruby-keyword kw">else</span>
19
- 92: <span class="ruby-keyword kw">super</span>( <span class="ruby-identifier">message</span> )
20
- 93: <span class="ruby-keyword kw">end</span>
21
- 94: <span class="ruby-keyword kw">end</span></pre>
22
- </body>
23
- </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>new (Mongrel::HttpServer)</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/mongrel.rb, line 324</span>
14
- 324: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">host</span>, <span class="ruby-identifier">port</span>, <span class="ruby-identifier">num_processors</span>=<span class="ruby-value">20</span>, <span class="ruby-identifier">timeout</span>=<span class="ruby-value">120</span>)
15
- 325: <span class="ruby-ivar">@socket</span> = <span class="ruby-constant">TCPServer</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">host</span>, <span class="ruby-identifier">port</span>)
16
- 326:
17
- 327: <span class="ruby-ivar">@classifier</span> = <span class="ruby-constant">URIClassifier</span>.<span class="ruby-identifier">new</span>
18
- 328: <span class="ruby-ivar">@req_queue</span> = <span class="ruby-constant">Queue</span>.<span class="ruby-identifier">new</span>
19
- 329: <span class="ruby-ivar">@host</span> = <span class="ruby-identifier">host</span>
20
- 330: <span class="ruby-ivar">@port</span> = <span class="ruby-identifier">port</span>
21
- 331: <span class="ruby-ivar">@processors</span> = []
22
- 332: <span class="ruby-ivar">@timeout</span> = <span class="ruby-identifier">timeout</span>
23
- 333:
24
- 334: <span class="ruby-identifier">num_processors</span>.<span class="ruby-identifier">times</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span>
25
- 335: <span class="ruby-ivar">@processors</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-constant">Thread</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword kw">do</span>
26
- 336: <span class="ruby-keyword kw">while</span> <span class="ruby-identifier">client</span> = <span class="ruby-ivar">@req_queue</span>.<span class="ruby-identifier">deq</span>
27
- 337: <span class="ruby-identifier">process_client</span>(<span class="ruby-identifier">client</span>)
28
- 338: <span class="ruby-keyword kw">end</span>
29
- 339: <span class="ruby-keyword kw">end</span>
30
- 340: }
31
- 341: <span class="ruby-keyword kw">end</span></pre>
32
- </body>
33
- </html>
@@ -1,19 +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>stop (Mongrel::HttpServer)</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/mongrel.rb, line 442</span>
14
- 442: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">stop</span>
15
- 443: <span class="ruby-ivar">@acceptor</span>[<span class="ruby-identifier">:stopped</span>] = <span class="ruby-keyword kw">true</span>
16
- 444: <span class="ruby-ivar">@acceptor</span>.<span class="ruby-identifier">raise</span>(<span class="ruby-constant">StopServer</span>.<span class="ruby-identifier">new</span>)
17
- 445: <span class="ruby-keyword kw">end</span></pre>
18
- </body>
19
- </html>
@@ -1,409 +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>Module: PluginFactory</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>Module</strong></td>
53
- <td class="class-name-in-header">PluginFactory</td>
54
- </tr>
55
- <tr class="top-aligned-row">
56
- <td><strong>In:</strong></td>
57
- <td>
58
- <a href="../files/lib/pluginfactory_rb.html">
59
- lib/pluginfactory.rb
60
- </a>
61
- <br />
62
- </td>
63
- </tr>
64
-
65
- </table>
66
- </div>
67
- <!-- banner header -->
68
-
69
- <div id="bodyContent">
70
-
71
-
72
-
73
- <div id="contextContent">
74
-
75
- <div id="description">
76
- <p>
77
- A mixin that adds <a href="PluginFactory.html">PluginFactory</a> class
78
- methods to a base class, so that subclasses may be instantiated by name.
79
- </p>
80
-
81
- </div>
82
-
83
-
84
- </div>
85
-
86
- <div id="method-list">
87
- <h3 class="section-bar">Methods</h3>
88
-
89
- <div class="name-list">
90
- <a href="#M000009">create</a>&nbsp;&nbsp;
91
- <a href="#M000008">derivativeClasses</a>&nbsp;&nbsp;
92
- <a href="#M000005">derivatives</a>&nbsp;&nbsp;
93
- <a href="#M000004">extend_object</a>&nbsp;&nbsp;
94
- <a href="#M000006">factoryType</a>&nbsp;&nbsp;
95
- <a href="#M000012">getModuleName</a>&nbsp;&nbsp;
96
- <a href="#M000010">getSubclass</a>&nbsp;&nbsp;
97
- <a href="#M000003">included</a>&nbsp;&nbsp;
98
- <a href="#M000007">inherited</a>&nbsp;&nbsp;
99
- <a href="#M000011">loadDerivative</a>&nbsp;&nbsp;
100
- <a href="#M000002">log</a>&nbsp;&nbsp;
101
- <a href="#M000014">makeRequirePath</a>&nbsp;&nbsp;
102
- <a href="#M000013">requireDerivative</a>&nbsp;&nbsp;
103
- </div>
104
- </div>
105
-
106
- </div>
107
-
108
-
109
- <!-- if includes -->
110
-
111
- <div id="section">
112
-
113
-
114
-
115
-
116
-
117
- <div id="attribute-list">
118
- <h3 class="section-bar">Attributes</h3>
119
-
120
- <div class="name-list">
121
- <table>
122
- <tr class="top-aligned-row context-row">
123
- <td class="context-item-name">logger_callback</td>
124
- <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
125
- <td class="context-item-desc"></td>
126
- </tr>
127
- </table>
128
- </div>
129
- </div>
130
-
131
-
132
-
133
- <!-- if method_list -->
134
- <div id="methods">
135
- <h3 class="section-bar">Public Class methods</h3>
136
-
137
- <div id="method-M000004" class="method-detail">
138
- <a name="M000004"></a>
139
-
140
- <div class="method-heading">
141
- <a href="PluginFactory.src/M000004.html" target="Code" class="method-signature"
142
- onclick="popupCode('PluginFactory.src/M000004.html');return false;">
143
- <span class="method-name">extend_object</span><span class="method-args">( obj )</span>
144
- </a>
145
- </div>
146
-
147
- <div class="method-description">
148
- <p>
149
- Raise an exception if the object being extended is anything but a class.
150
- </p>
151
- </div>
152
- </div>
153
-
154
- <div id="method-M000003" class="method-detail">
155
- <a name="M000003"></a>
156
-
157
- <div class="method-heading">
158
- <a href="PluginFactory.src/M000003.html" target="Code" class="method-signature"
159
- onclick="popupCode('PluginFactory.src/M000003.html');return false;">
160
- <span class="method-name">included</span><span class="method-args">( klass )</span>
161
- </a>
162
- </div>
163
-
164
- <div class="method-description">
165
- <p>
166
- Inclusion callback &#8212; extends the including class.
167
- </p>
168
- </div>
169
- </div>
170
-
171
- <div id="method-M000002" class="method-detail">
172
- <a name="M000002"></a>
173
-
174
- <div class="method-heading">
175
- <a href="PluginFactory.src/M000002.html" target="Code" class="method-signature"
176
- onclick="popupCode('PluginFactory.src/M000002.html');return false;">
177
- <span class="method-name">log</span><span class="method-args">(level, *msg)</span>
178
- </a>
179
- </div>
180
-
181
- <div class="method-description">
182
- <p>
183
- If the logger callback is set, use it to pass on a log entry. First
184
- argument is
185
- </p>
186
- </div>
187
- </div>
188
-
189
- <h3 class="section-bar">Public Instance methods</h3>
190
-
191
- <div id="method-M000009" class="method-detail">
192
- <a name="M000009"></a>
193
-
194
- <div class="method-heading">
195
- <a href="PluginFactory.src/M000009.html" target="Code" class="method-signature"
196
- onclick="popupCode('PluginFactory.src/M000009.html');return false;">
197
- <span class="method-name">create</span><span class="method-args">( subType, *args, &amp;block )</span>
198
- </a>
199
- </div>
200
-
201
- <div class="method-description">
202
- <p>
203
- Given the <tt>className</tt> of the class to instantiate, and other
204
- arguments bound for the constructor of the new object, this method loads
205
- the derivative class if it is not loaded already (raising a LoadError if an
206
- appropriately-named file cannot be found), and instantiates it with the
207
- given <tt>args</tt>. The <tt>className</tt> may be the the fully qualified
208
- name of the class, the class object itself, or the unique part of the class
209
- name. The following examples would all try to load and instantiate a class
210
- called &quot;FooListener&quot; if Listener included Factory
211
- </p>
212
- <pre>
213
- obj = Listener::create( 'FooListener' )
214
- obj = Listener::create( FooListener )
215
- obj = Listener::create( 'Foo' )
216
- </pre>
217
- </div>
218
- </div>
219
-
220
- <div id="method-M000008" class="method-detail">
221
- <a name="M000008"></a>
222
-
223
- <div class="method-heading">
224
- <a href="PluginFactory.src/M000008.html" target="Code" class="method-signature"
225
- onclick="popupCode('PluginFactory.src/M000008.html');return false;">
226
- <span class="method-name">derivativeClasses</span><span class="method-args">()</span>
227
- </a>
228
- </div>
229
-
230
- <div class="method-description">
231
- <p>
232
- Returns an Array of registered derivatives
233
- </p>
234
- </div>
235
- </div>
236
-
237
- <div id="method-M000005" class="method-detail">
238
- <a name="M000005"></a>
239
-
240
- <div class="method-heading">
241
- <a href="PluginFactory.src/M000005.html" target="Code" class="method-signature"
242
- onclick="popupCode('PluginFactory.src/M000005.html');return false;">
243
- <span class="method-name">derivatives</span><span class="method-args">()</span>
244
- </a>
245
- </div>
246
-
247
- <div class="method-description">
248
- <p>
249
- Return the Hash of derivative classes, keyed by various versions of the
250
- class name.
251
- </p>
252
- </div>
253
- </div>
254
-
255
- <div id="method-M000006" class="method-detail">
256
- <a name="M000006"></a>
257
-
258
- <div class="method-heading">
259
- <a href="PluginFactory.src/M000006.html" target="Code" class="method-signature"
260
- onclick="popupCode('PluginFactory.src/M000006.html');return false;">
261
- <span class="method-name">factoryType</span><span class="method-args">()</span>
262
- </a>
263
- </div>
264
-
265
- <div class="method-description">
266
- <p>
267
- Returns the type name used when searching for a derivative.
268
- </p>
269
- </div>
270
- </div>
271
-
272
- <div id="method-M000012" class="method-detail">
273
- <a name="M000012"></a>
274
-
275
- <div class="method-heading">
276
- <a href="PluginFactory.src/M000012.html" target="Code" class="method-signature"
277
- onclick="popupCode('PluginFactory.src/M000012.html');return false;">
278
- <span class="method-name">getModuleName</span><span class="method-args">( className )</span>
279
- </a>
280
- </div>
281
-
282
- <div class="method-description">
283
- <p>
284
- Build and return the unique part of the given <tt>className</tt> either by
285
- stripping leading namespaces if the name already has the name of the
286
- factory type in it (eg., &#8216;My::FooService&#8217; for Service, or by
287
- appending the factory type if it doesn&#8217;t.
288
- </p>
289
- </div>
290
- </div>
291
-
292
- <div id="method-M000010" class="method-detail">
293
- <a name="M000010"></a>
294
-
295
- <div class="method-heading">
296
- <a href="PluginFactory.src/M000010.html" target="Code" class="method-signature"
297
- onclick="popupCode('PluginFactory.src/M000010.html');return false;">
298
- <span class="method-name">getSubclass</span><span class="method-args">( className )</span>
299
- </a>
300
- </div>
301
-
302
- <div class="method-description">
303
- <p>
304
- Given a <tt>className</tt> like that of the first argument to <a
305
- href="PluginFactory.html#M000009">create</a>, attempt to load the
306
- corresponding class if it is not already loaded and return the class
307
- object.
308
- </p>
309
- </div>
310
- </div>
311
-
312
- <div id="method-M000007" class="method-detail">
313
- <a name="M000007"></a>
314
-
315
- <div class="method-heading">
316
- <a href="PluginFactory.src/M000007.html" target="Code" class="method-signature"
317
- onclick="popupCode('PluginFactory.src/M000007.html');return false;">
318
- <span class="method-name">inherited</span><span class="method-args">( subclass )</span>
319
- </a>
320
- </div>
321
-
322
- <div class="method-description">
323
- <p>
324
- Inheritance callback &#8212; Register subclasses in the derivatives hash so
325
- that ::create knows about them.
326
- </p>
327
- </div>
328
- </div>
329
-
330
- <div id="method-M000011" class="method-detail">
331
- <a name="M000011"></a>
332
-
333
- <div class="method-heading">
334
- <a href="PluginFactory.src/M000011.html" target="Code" class="method-signature"
335
- onclick="popupCode('PluginFactory.src/M000011.html');return false;">
336
- <span class="method-name">loadDerivative</span><span class="method-args">( className )</span>
337
- </a>
338
- </div>
339
-
340
- <div class="method-description">
341
- <p>
342
- Calculates an appropriate filename for the derived class using the name of
343
- the base class and tries to load it via <tt>require</tt>. If the including
344
- class responds to a method named <tt>derivativeDirs</tt>, its return value
345
- (either a String, or an array of Strings) is added to the list of prefix
346
- directories to try when attempting to require a modules. Eg., if
347
- <tt>class.derivativeDirs</tt> returns
348
- <tt>[&#8216;foo&#8217;,&#8217;bar&#8217;]</tt> the require line is tried
349
- with both <tt>&#8216;foo/&#8217;</tt> and <tt>&#8216;bar/&#8217;</tt>
350
- prepended to it.
351
- </p>
352
- </div>
353
- </div>
354
-
355
- <div id="method-M000014" class="method-detail">
356
- <a name="M000014"></a>
357
-
358
- <div class="method-heading">
359
- <a href="PluginFactory.src/M000014.html" target="Code" class="method-signature"
360
- onclick="popupCode('PluginFactory.src/M000014.html');return false;">
361
- <span class="method-name">makeRequirePath</span><span class="method-args">( modname, subdir )</span>
362
- </a>
363
- </div>
364
-
365
- <div class="method-description">
366
- <p>
367
- Make a list of permutations of the given <tt>modname</tt> for the given
368
- <tt>subdir</tt>. Called on a <tt>DataDriver</tt> class with the arguments
369
- &#8216;Socket&#8217; and &#8216;drivers&#8217;, returns:
370
- </p>
371
- <pre>
372
- [&quot;drivers/socketdatadriver&quot;, &quot;drivers/socketDataDriver&quot;,
373
- &quot;drivers/SocketDataDriver&quot;, &quot;drivers/socket&quot;, &quot;drivers/Socket&quot;]
374
- </pre>
375
- </div>
376
- </div>
377
-
378
- <div id="method-M000013" class="method-detail">
379
- <a name="M000013"></a>
380
-
381
- <div class="method-heading">
382
- <a href="PluginFactory.src/M000013.html" target="Code" class="method-signature"
383
- onclick="popupCode('PluginFactory.src/M000013.html');return false;">
384
- <span class="method-name">requireDerivative</span><span class="method-args">( modName )</span>
385
- </a>
386
- </div>
387
-
388
- <div class="method-description">
389
- <p>
390
- If the factory responds to the derivativeDirs method, call it and use the
391
- returned array as a list of directories to search for the module with the
392
- specified <tt>modName</tt>.
393
- </p>
394
- </div>
395
- </div>
396
-
397
-
398
- </div>
399
-
400
-
401
- </div>
402
-
403
-
404
- <div id="validator-badges">
405
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
406
- </div>
407
-
408
- </body>
409
- </html>