siffer 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. data/Rakefile +2 -2
  2. data/doc/rdoc/classes/Siffer.html +253 -368
  3. data/doc/rdoc/classes/Siffer/Agent.html +169 -288
  4. data/doc/rdoc/classes/Siffer/Container.html +158 -279
  5. data/doc/rdoc/classes/Siffer/Messages.html +79 -139
  6. data/doc/rdoc/classes/Siffer/Messages/Ack.html +109 -210
  7. data/doc/rdoc/classes/Siffer/Messages/Acl.html +78 -155
  8. data/doc/rdoc/classes/Siffer/Messages/Error.html +151 -242
  9. data/doc/rdoc/classes/Siffer/Messages/Message.html +227 -351
  10. data/doc/rdoc/classes/Siffer/Messages/Message/Header.html +102 -176
  11. data/doc/rdoc/classes/Siffer/Messages/Register.html +147 -250
  12. data/doc/rdoc/classes/Siffer/Messages/RequestBody.html +177 -292
  13. data/doc/rdoc/classes/Siffer/Messages/Status.html +149 -262
  14. data/doc/rdoc/classes/Siffer/Messaging.html +204 -323
  15. data/doc/rdoc/classes/Siffer/Protocol.html +246 -380
  16. data/doc/rdoc/classes/Siffer/Protocol/NonPostRequest.html +53 -110
  17. data/doc/rdoc/classes/Siffer/Protocol/UnknownPath.html +53 -110
  18. data/doc/rdoc/classes/Siffer/Registration.html +243 -383
  19. data/doc/rdoc/classes/Siffer/Request.html +97 -203
  20. data/doc/rdoc/classes/Siffer/RequestLogger.html +102 -204
  21. data/doc/rdoc/classes/Siffer/Response.html +85 -176
  22. data/doc/rdoc/classes/Siffer/Server.html +150 -236
  23. data/doc/rdoc/created.rid +1 -1
  24. data/doc/rdoc/files/LICENSE.html +75 -128
  25. data/doc/rdoc/files/README_rdoc.html +130 -183
  26. data/doc/rdoc/files/lib/siffer/agent_rb.html +49 -0
  27. data/doc/rdoc/files/lib/siffer/container_rb.html +57 -0
  28. data/doc/rdoc/files/lib/siffer/messages/ack_rb.html +49 -0
  29. data/doc/rdoc/files/lib/siffer/messages/acl_rb.html +49 -0
  30. data/doc/rdoc/files/lib/siffer/messages/error_rb.html +49 -0
  31. data/doc/rdoc/files/lib/siffer/messages/message_rb.html +49 -0
  32. data/doc/rdoc/files/lib/siffer/messages/register_rb.html +49 -0
  33. data/doc/rdoc/files/lib/siffer/messages/request_body_rb.html +49 -0
  34. data/doc/rdoc/files/lib/siffer/messages/status_rb.html +49 -0
  35. data/doc/rdoc/files/lib/siffer/messages_rb.html +63 -0
  36. data/doc/rdoc/files/lib/siffer/messaging_rb.html +49 -0
  37. data/doc/rdoc/files/lib/siffer/protocol_rb.html +49 -0
  38. data/doc/rdoc/files/lib/siffer/registration_rb.html +49 -0
  39. data/doc/rdoc/files/lib/siffer/request_logger_rb.html +49 -0
  40. data/doc/rdoc/files/lib/siffer/request_rb.html +49 -0
  41. data/doc/rdoc/files/lib/siffer/response_rb.html +49 -0
  42. data/doc/rdoc/files/lib/siffer/server_rb.html +49 -0
  43. data/doc/rdoc/files/lib/siffer_rb.html +62 -113
  44. data/doc/rdoc/fr_class_index.html +25 -47
  45. data/doc/rdoc/fr_file_index.html +39 -46
  46. data/doc/rdoc/fr_method_index.html +4539 -96
  47. data/doc/rdoc/index.html +14 -23
  48. data/doc/rdoc/rdoc-style.css +314 -203
  49. data/lib/siffer.rb +6 -6
  50. data/lib/{agent.rb → siffer/agent.rb} +5 -3
  51. data/lib/{container.rb → siffer/container.rb} +3 -5
  52. data/lib/siffer/messages.rb +7 -0
  53. data/lib/{messages → siffer/messages}/ack.rb +0 -0
  54. data/lib/{messages → siffer/messages}/acl.rb +0 -0
  55. data/lib/{messages → siffer/messages}/error.rb +0 -0
  56. data/lib/{messages → siffer/messages}/message.rb +0 -0
  57. data/lib/{messages → siffer/messages}/register.rb +0 -0
  58. data/lib/{messages → siffer/messages}/request_body.rb +0 -0
  59. data/lib/{messages → siffer/messages}/status.rb +0 -0
  60. data/lib/{messaging.rb → siffer/messaging.rb} +8 -5
  61. data/lib/{protocol.rb → siffer/protocol.rb} +37 -32
  62. data/lib/{registration.rb → siffer/registration.rb} +2 -2
  63. data/lib/siffer/request.rb +28 -0
  64. data/lib/{request_logger.rb → siffer/request_logger.rb} +8 -7
  65. data/lib/{response.rb → siffer/response.rb} +1 -1
  66. data/lib/{server.rb → siffer/server.rb} +5 -3
  67. data/spec/agent_spec.rb +6 -11
  68. data/spec/container_spec.rb +2 -2
  69. data/spec/default_agent +1 -1
  70. data/spec/messaging_spec.rb +3 -6
  71. data/spec/protocol_spec.rb +27 -26
  72. data/spec/registration_spec.rb +2 -2
  73. data/spec/request_logger_spec.rb +22 -9
  74. data/spec/request_spec.rb +15 -0
  75. data/spec/response_spec.rb +2 -2
  76. data/spec/server_spec.rb +0 -5
  77. data/spec/spec_helper.rb +9 -0
  78. metadata +40 -38
  79. data/doc/rdoc/files/lib/agent_rb.html +0 -101
  80. data/doc/rdoc/files/lib/container_rb.html +0 -108
  81. data/doc/rdoc/files/lib/messages/ack_rb.html +0 -101
  82. data/doc/rdoc/files/lib/messages/acl_rb.html +0 -101
  83. data/doc/rdoc/files/lib/messages/error_rb.html +0 -101
  84. data/doc/rdoc/files/lib/messages/message_rb.html +0 -101
  85. data/doc/rdoc/files/lib/messages/register_rb.html +0 -101
  86. data/doc/rdoc/files/lib/messages/request_body_rb.html +0 -101
  87. data/doc/rdoc/files/lib/messages/status_rb.html +0 -101
  88. data/doc/rdoc/files/lib/messages_rb.html +0 -114
  89. data/doc/rdoc/files/lib/messaging_rb.html +0 -101
  90. data/doc/rdoc/files/lib/protocol_rb.html +0 -101
  91. data/doc/rdoc/files/lib/registration_rb.html +0 -101
  92. data/doc/rdoc/files/lib/request_logger_rb.html +0 -101
  93. data/doc/rdoc/files/lib/request_rb.html +0 -101
  94. data/doc/rdoc/files/lib/response_rb.html +0 -101
  95. data/doc/rdoc/files/lib/server_rb.html +0 -101
  96. data/lib/messages.rb +0 -7
  97. data/lib/request.rb +0 -25
@@ -1,388 +1,254 @@
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: Siffer::Protocol</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">Siffer::Protocol</td>
54
- </tr>
55
- <tr class="top-aligned-row">
56
- <td><strong>In:</strong></td>
57
- <td>
58
- <a href="../../files/lib/protocol_rb.html">
59
- lib/protocol.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
- The <a href="Protocol.html">Protocol</a> module deals with the transport
78
- validation. Provides constants for HTTP statuses as well as acceptable
79
- paths for <a href="../Siffer.html">Siffer</a> Servers and Agents.
80
- </p>
81
-
82
- </div>
83
-
84
-
85
- </div>
86
-
87
- <div id="method-list">
88
- <h3 class="section-bar">Methods</h3>
89
-
90
- <div class="name-list">
91
- <a href="#M000008">check_path_against_protocol</a>&nbsp;&nbsp;
92
- <a href="#M000011">error_response</a>&nbsp;&nbsp;
93
- <a href="#M000012">no_response_available</a>&nbsp;&nbsp;
94
- <a href="#M000007">request_failed_protocol?</a>&nbsp;&nbsp;
95
- <a href="#M000009">uri</a>&nbsp;&nbsp;
96
- <a href="#M000010">with_each_request</a>&nbsp;&nbsp;
97
- </div>
98
- </div>
99
-
100
- </div>
101
-
102
-
103
- <!-- if includes -->
104
- <div id="includes">
105
- <h3 class="section-bar">Included Modules</h3>
106
-
107
- <div id="includes-list">
108
- <span class="include-name"><a href="Messages.html">Siffer::Messages</a></span>
109
- <span class="include-name"><a href="Messaging.html">Siffer::Messaging</a></span>
110
- </div>
111
- </div>
112
-
113
- <div id="section">
114
-
115
- <div id="class-list">
116
- <h3 class="section-bar">Classes and Modules</h3>
117
-
118
- Class <a href="Protocol/NonPostRequest.html" class="link">Siffer::Protocol::NonPostRequest</a><br />
119
- Class <a href="Protocol/UnknownPath.html" class="link">Siffer::Protocol::UnknownPath</a><br />
120
-
121
- </div>
122
-
123
- <div id="constants-list">
124
- <h3 class="section-bar">Constants</h3>
125
-
126
- <div class="name-list">
127
- <table summary="Constants">
128
- <tr class="top-aligned-row context-row">
129
- <td class="context-item-name">ACCEPTABLE_PATHS</td>
130
- <td>=</td>
131
- <td class="context-item-value">{ :root =&gt; &quot;/&quot;, :ping =&gt; &quot;/ping&quot;, :status =&gt; &quot;/status&quot;, :register =&gt; &quot;/register&quot;</td>
132
- <td width="3em">&nbsp;</td>
133
- <td class="context-item-desc">
134
- Paths that comply with the messaging protocol determined by the SIF
135
- Specification. These are <a href="../Siffer.html">Siffer</a> specific and
136
- not spelled out in SIF Specification (rather implied). Each path will
137
- generate it&#8216;s own predicate method (i.e. ping?) that can be used to
138
- determine the requests path based on the content of the message or the
139
- path-info of the request.
140
-
141
- </td>
142
- </tr>
143
- <tr class="top-aligned-row context-row">
144
- <td class="context-item-name">HTTP_STATUS_CODES</td>
145
- <td>=</td>
146
- <td class="context-item-value">{ 100 =&gt; 'Continue', 101 =&gt; 'Switching Protocols', 200 =&gt; 'OK', 201 =&gt; 'Created', 202 =&gt; 'Accepted', 203 =&gt; 'Non-Authoritative Information', 204 =&gt; 'No Content', 205 =&gt; 'Reset Content', 206 =&gt; 'Partial Content', 300 =&gt; 'Multiple Choices', 301 =&gt; 'Moved Permanently', 302 =&gt; 'Moved Temporarily', 303 =&gt; 'See Other', 304 =&gt; 'Not Modified', 305 =&gt; 'Use Proxy', 400 =&gt; 'Bad Request', 401 =&gt; 'Unauthorized', 402 =&gt; 'Payment Required', 403 =&gt; 'Forbidden', 404 =&gt; 'Not Found', 405 =&gt; 'Method Not Allowed', 406 =&gt; 'Not Acceptable', 407 =&gt; 'Proxy Authentication Required', 408 =&gt; 'Request Time-out', 409 =&gt; 'Conflict', 410 =&gt; 'Gone', 411 =&gt; 'Length Required', 412 =&gt; 'Precondition Failed', 413 =&gt; 'Request Entity Too Large', 414 =&gt; 'Request-URI Too Large', 415 =&gt; 'Unsupported Media Type', 500 =&gt; 'Internal Server Error', 501 =&gt; 'Not Implemented', 502 =&gt; 'Bad Gateway', 503 =&gt; 'Service Unavailable', 504 =&gt; 'Gateway Time-out', 505 =&gt; 'HTTP Version not supported'</td>
147
- <td width="3em">&nbsp;</td>
148
- <td class="context-item-desc">
149
- Every standard HTTP code mapped to the appropriate message. Stolen from
150
- Mongrel.
151
-
152
- </td>
153
- </tr>
154
- </table>
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2
+ <html lang='en'>
3
+ <head>
4
+ <title>Module: Siffer::Protocol [Siffer == h3o(software) SIF]</title>
5
+ <meta content='text/html; charset=UTF-8' http-equiv='Content-Type'>
6
+ <link href='../.././rdoc-style.css' media='screen' rel='stylesheet' type='text/css'>
7
+ <script type='text/javascript'>
8
+ //<![CDATA[
9
+ function popupCode(url) {
10
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
11
+ }
12
+
13
+ function toggleCode(id) {
14
+ var code = document.getElementById(id)
15
+
16
+ code.style.display = code.style.display != 'block' ? 'block' : 'none'
17
+ return true
18
+ }
19
+
20
+ // Make codeblocks hidden by default
21
+ document.writeln('<' + 'style type="text/css">.method .source pre { display: none }<\/style>')
22
+ //]]>
23
+ </script>
24
+ </head>
25
+ <body class='page'>
26
+ <div class='class' id='wrapper'>
27
+ <div class='header'>
28
+ <h1 class='name'>
29
+ <span class='type'>Module</span>
30
+ Siffer::Protocol
31
+ </h1>
32
+ <ol class='paths'>
33
+ <li>
34
+ <a href="../../files/lib/siffer/protocol_rb.html">lib/siffer/protocol.rb</a>
35
+ </li>
36
+ </ol>
155
37
  </div>
156
- </div>
157
-
158
-
159
-
160
-
161
-
162
-
163
- <!-- if method_list -->
164
- <div id="methods">
165
- <h3 class="section-bar">Public Instance methods</h3>
166
-
167
- <div id="method-M000008" class="method-detail">
168
- <a name="M000008"></a>
169
-
170
- <div class="method-heading">
171
- <a href="#M000008" class="method-signature">
172
- <span class="method-name">check_path_against_protocol</span><span class="method-args">()</span>
173
- </a>
174
- </div>
175
-
176
- <div class="method-description">
177
- <p>
178
- Validates the request object against the Acceptable Paths (<a
179
- href="../Siffer.html">Siffer</a> spec) and that the request is a POST.
180
- </p>
181
- <p><a class="source-toggle" href="#"
182
- onclick="toggleCode('M000008-source');return false;">[Source]</a></p>
183
- <div class="method-source-code" id="M000008-source">
184
- <pre>
185
- <span class="ruby-comment cmt"># File lib/protocol.rb, line 34</span>
186
- 34: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">check_path_against_protocol</span>
187
- 35: <span class="ruby-keyword kw">unless</span> <span class="ruby-constant">ACCEPTABLE_PATHS</span>.<span class="ruby-identifier">has_value?</span> <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">path_info</span>
188
- 36: <span class="ruby-identifier">raise</span> <span class="ruby-constant">UnknownPath</span>
189
- 37: <span class="ruby-keyword kw">end</span>
190
- 38: <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">post?</span>
191
- 39: <span class="ruby-identifier">raise</span> <span class="ruby-constant">NonPostRequest</span>
192
- 40: <span class="ruby-keyword kw">end</span>
193
- 41: <span class="ruby-keyword kw">end</span>
194
- </pre>
38
+ <div id='content'>
39
+ <div id='text'>
40
+ <div id='description'>
41
+ <p>
42
+ The <a href="Protocol.html">Protocol</a> module deals with the transport
43
+ validation. Provides constants for HTTP statuses as well as acceptable
44
+ paths for <a href="../Siffer.html">Siffer</a> Servers and Agents.
45
+ </p>
195
46
  </div>
196
- </div>
197
- </div>
198
-
199
- <div id="method-M000011" class="method-detail">
200
- <a name="M000011"></a>
201
-
202
- <div class="method-heading">
203
- <a href="#M000011" class="method-signature">
204
- <span class="method-name">error_response</span><span class="method-args">(category,code, desc = nil)</span>
205
- </a>
206
- </div>
207
-
208
- <div class="method-description">
209
- <p>
210
- Sets the @response to a <a
211
- href="Messages/Ack.html">Siffer::Messages::Ack</a> message with the
212
- appropriate Error category and code. Optional description is allowed and
213
- placed in the ExtendedDesc node.
214
- </p>
215
- <p><a class="source-toggle" href="#"
216
- onclick="toggleCode('M000011-source');return false;">[Source]</a></p>
217
- <div class="method-source-code" id="M000011-source">
218
- <pre>
219
- <span class="ruby-comment cmt"># File lib/protocol.rb, line 70</span>
220
- 70: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">error_response</span>(<span class="ruby-identifier">category</span>,<span class="ruby-identifier">code</span>, <span class="ruby-identifier">desc</span> = <span class="ruby-keyword kw">nil</span>)
221
- 71: <span class="ruby-identifier">error</span> = <span class="ruby-constant">Error</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">category</span>,<span class="ruby-identifier">code</span>,<span class="ruby-identifier">desc</span>)
222
- 72: <span class="ruby-identifier">ack</span> = <span class="ruby-constant">Ack</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">name</span>, <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">original</span>, <span class="ruby-identifier">:error</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">error</span>)
223
- 73: <span class="ruby-ivar">@response</span> = <span class="ruby-constant">Response</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">ack</span>)
224
- 74: <span class="ruby-keyword kw">end</span>
225
- </pre>
47
+ <div id='method-list'>
48
+ <h2>Methods</h2>
49
+ <h3>public instance</h3>
50
+ <ol>
51
+ <li><a href="#M000008">check_path_against_protocol</a></li>
52
+ <li><a href="#M000011">error_response</a></li>
53
+ <li><a href="#M000012">no_response_available</a></li>
54
+ <li><a href="#M000007">request_failed_protocol?</a></li>
55
+ <li><a href="#M000013">root_response</a></li>
56
+ <li><a href="#M000009">uri</a></li>
57
+ <li><a href="#M000010">with_each_request</a></li>
58
+ </ol>
226
59
  </div>
227
- </div>
228
- </div>
229
-
230
- <div id="method-M000012" class="method-detail">
231
- <a name="M000012"></a>
232
-
233
- <div class="method-heading">
234
- <a href="#M000012" class="method-signature">
235
- <span class="method-name">no_response_available</span><span class="method-args">()</span>
236
- </a>
237
- </div>
238
-
239
- <div class="method-description">
240
- <p>
241
- Determines if there is a response instance created. If not it creates one
242
- with an Ack/Error describing not having anything to process.
243
- </p>
244
- <p><a class="source-toggle" href="#"
245
- onclick="toggleCode('M000012-source');return false;">[Source]</a></p>
246
- <div class="method-source-code" id="M000012-source">
247
- <pre>
248
- <span class="ruby-comment cmt"># File lib/protocol.rb, line 79</span>
249
- 79: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">no_response_available</span>
250
- 80: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@response</span>.<span class="ruby-identifier">nil?</span>
251
- 81: <span class="ruby-identifier">err</span> = <span class="ruby-value str">&quot;You are receiving this message because you failed to \nprovide enough information to respond to. This is likely due\nto the message type missing (i.e. Register,Provide) or possibly\nnot enough information to process effectively. Please check the \nmessage you are sending and resend after any corrections.\n&quot;</span>
252
- 82: <span class="ruby-operator">!</span><span class="ruby-identifier">error_response</span>(<span class="ruby-value">12</span>,<span class="ruby-value">1</span>,<span class="ruby-identifier">err</span>)
253
- 83: <span class="ruby-keyword kw">end</span>
254
- 84: <span class="ruby-keyword kw">end</span>
255
- </pre>
60
+ <div id='context'>
61
+ <div id='includes'>
62
+ <h2>Included modules</h2>
63
+ <ol>
64
+ <li><a href="Messages.html">Siffer::Messages</a></li>
65
+ <li><a href="Messaging.html">Siffer::Messaging</a></li>
66
+ </ol>
67
+ </div>
256
68
  </div>
257
- </div>
258
- </div>
259
-
260
- <div id="method-M000007" class="method-detail">
261
- <a name="M000007"></a>
262
-
263
- <div class="method-heading">
264
- <a href="#M000007" class="method-signature">
265
- <span class="method-name">request_failed_protocol?</span><span class="method-args">()</span>
266
- </a>
267
- </div>
268
-
269
- <div class="method-description">
270
- <p>
271
- Checks the incoming request against the following protocol constraints:
272
- </p>
273
- <ul>
274
- <li>Unknown PATH
275
-
276
- </li>
277
- <li>Non-POST request
278
-
279
- </li>
280
- </ul>
281
- <p><a class="source-toggle" href="#"
282
- onclick="toggleCode('M000007-source');return false;">[Source]</a></p>
283
- <div class="method-source-code" id="M000007-source">
284
- <pre>
285
- <span class="ruby-comment cmt"># File lib/protocol.rb, line 16</span>
286
- 16: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">request_failed_protocol?</span>
287
- 17: <span class="ruby-keyword kw">begin</span>
288
- 18: <span class="ruby-identifier">check_path_against_protocol</span>
289
- 19: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">UnknownPath</span>
290
- 20: <span class="ruby-comment cmt"># TODO: Make a better Not Found response</span>
291
- 21: <span class="ruby-ivar">@response</span> = <span class="ruby-constant">Response</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">HTTP_STATUS_CODES</span>[<span class="ruby-value">404</span>],
292
- 22: <span class="ruby-value">404</span>,
293
- 23: {<span class="ruby-value str">&quot;Content-Type&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">Siffer</span><span class="ruby-operator">::</span><span class="ruby-constant">Messaging</span><span class="ruby-operator">::</span><span class="ruby-constant">MIME_TYPES</span>[<span class="ruby-value str">&quot;htm&quot;</span>]})
294
- 24: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">NonPostRequest</span>
295
- 25: <span class="ruby-comment cmt"># TODO: Make a better Method Not Allowed response</span>
296
- 26: <span class="ruby-ivar">@response</span> = <span class="ruby-constant">Response</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">HTTP_STATUS_CODES</span>[<span class="ruby-value">405</span>],
297
- 27: <span class="ruby-value">405</span>,
298
- 28: {<span class="ruby-value str">&quot;Content-Type&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">Siffer</span><span class="ruby-operator">::</span><span class="ruby-constant">Messaging</span><span class="ruby-operator">::</span><span class="ruby-constant">MIME_TYPES</span>[<span class="ruby-value str">&quot;htm&quot;</span>]})
299
- 29: <span class="ruby-keyword kw">end</span>
300
- 30: <span class="ruby-keyword kw">end</span>
301
- </pre>
69
+ <div id='section'>
70
+ <div id='class-list'>
71
+ <h2>Classes and Modules</h2>
72
+ Class <a href="Protocol/NonPostRequest.html" class="link">Siffer::Protocol::NonPostRequest</a><br />
73
+ Class <a href="Protocol/UnknownPath.html" class="link">Siffer::Protocol::UnknownPath</a><br />
74
+ </div>
75
+ <div id='constants-list'>
76
+ <h2>Constants</h2>
77
+ <div class='name-list'>
78
+ <table summary='Constants'>
79
+ <tr class='top-aligned-row context-row'>
80
+ <td class='context-item-name'>ACCEPTABLE_PATHS</td>
81
+ <td>=</td>
82
+ <td class='context-item-value'>{ :root =&gt; &quot;/&quot;, :ping =&gt; &quot;/ping&quot;, :status =&gt; &quot;/status&quot;, :register =&gt; &quot;/register&quot; }</td>
83
+ <td>&nbsp;</td>
84
+ <td class='context-item-desc'>
85
+
86
+ Paths that comply with the messaging protocol determined by the SIF
87
+ Specification. These are <a href="../Siffer.html">Siffer</a> specific and
88
+ not spelled out in SIF Specification (rather implied).
89
+ </td>
90
+ </tr>
91
+ <tr class='top-aligned-row context-row'>
92
+ <td class='context-item-name'>HTTP_STATUS_CODES</td>
93
+ <td>=</td>
94
+ <td class='context-item-value'>{ 100 =&gt; 'Continue', 101 =&gt; 'Switching Protocols', 200 =&gt; 'OK', 201 =&gt; 'Created', 202 =&gt; 'Accepted', 203 =&gt; 'Non-Authoritative Information', 204 =&gt; 'No Content', 205 =&gt; 'Reset Content', 206 =&gt; 'Partial Content', 300 =&gt; 'Multiple Choices', 301 =&gt; 'Moved Permanently', 302 =&gt; 'Moved Temporarily', 303 =&gt; 'See Other', 304 =&gt; 'Not Modified', 305 =&gt; 'Use Proxy', 400 =&gt; 'Bad Request', 401 =&gt; 'Unauthorized', 402 =&gt; 'Payment Required', 403 =&gt; 'Forbidden', 404 =&gt; 'Not Found', 405 =&gt; 'Method Not Allowed', 406 =&gt; 'Not Acceptable', 407 =&gt; 'Proxy Authentication Required', 408 =&gt; 'Request Time-out', 409 =&gt; 'Conflict', 410 =&gt; 'Gone', 411 =&gt; 'Length Required', 412 =&gt; 'Precondition Failed', 413 =&gt; 'Request Entity Too Large', 414 =&gt; 'Request-URI Too Large', 415 =&gt; 'Unsupported Media Type', 500 =&gt; 'Internal Server Error', 501 =&gt; 'Not Implemented', 502 =&gt; 'Bad Gateway', 503 =&gt; 'Service Unavailable', 504 =&gt; 'Gateway Time-out', 505 =&gt; 'HTTP Version not supported' }</td>
95
+ <td>&nbsp;</td>
96
+ <td class='context-item-desc'>
97
+
98
+ Every standard HTTP code mapped to the appropriate message. Stolen from
99
+ Mongrel.
100
+ </td>
101
+ </tr>
102
+ </table>
103
+ </div>
104
+ </div>
105
+ <div id='methods'>
106
+ <h2>Public instance methods</h2>
107
+ <div class='public-instance method' id='method-M000008'>
108
+ <a name='M000008'> </a>
109
+ <div class='synopsis'>
110
+ <span class='name'>check_path_against_protocol</span>
111
+ <span class='arguments'>()</span>
112
+ </div>
113
+ <div class='description'>
114
+ <p>
115
+ Validates the request object against the Acceptable Paths (<a
116
+ href="../Siffer.html">Siffer</a> spec) and that the request is a POST.
117
+ </p>
118
+ </div>
119
+ <div class='source'>
120
+ <a class='source-toggle' href='#' onclick="toggleCode('M000008-source'); return false">
121
+ [show source]
122
+ </a>
123
+ <pre id='M000008-source'> <span class="ruby-comment cmt"># File lib/siffer/protocol.rb, line 38</span>&#x000A;38: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">check_path_against_protocol</span>&#x000A;39: <span class="ruby-keyword kw">unless</span> <span class="ruby-constant">ACCEPTABLE_PATHS</span>.<span class="ruby-identifier">has_value?</span> <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">path_info</span>&#x000A;40: <span class="ruby-identifier">raise</span> <span class="ruby-constant">UnknownPath</span>&#x000A;41: <span class="ruby-keyword kw">end</span>&#x000A;42: <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">post?</span>&#x000A;43: <span class="ruby-identifier">raise</span> <span class="ruby-constant">NonPostRequest</span>&#x000A;44: <span class="ruby-keyword kw">end</span>&#x000A;45: <span class="ruby-keyword kw">end</span></pre>
124
+ </div>
125
+ </div>
126
+ <div class='public-instance method' id='method-M000011'>
127
+ <a name='M000011'> </a>
128
+ <div class='synopsis'>
129
+ <span class='name'>error_response</span>
130
+ <span class='arguments'>(category,code, desc = nil)</span>
131
+ </div>
132
+ <div class='description'>
133
+ <p>
134
+ Sets the @response to a <a
135
+ href="Messages/Ack.html">Siffer::Messages::Ack</a> message with the
136
+ appropriate Error category and code. Optional description is allowed and
137
+ placed in the ExtendedDesc node.
138
+ </p>
139
+ </div>
140
+ <div class='source'>
141
+ <a class='source-toggle' href='#' onclick="toggleCode('M000011-source'); return false">
142
+ [show source]
143
+ </a>
144
+ <pre id='M000011-source'> <span class="ruby-comment cmt"># File lib/siffer/protocol.rb, line 74</span>&#x000A;74: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">error_response</span>(<span class="ruby-identifier">category</span>,<span class="ruby-identifier">code</span>, <span class="ruby-identifier">desc</span> = <span class="ruby-keyword kw">nil</span>)&#x000A;75: <span class="ruby-identifier">error</span> = <span class="ruby-constant">Error</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">category</span>,<span class="ruby-identifier">code</span>,<span class="ruby-identifier">desc</span>)&#x000A;76: <span class="ruby-identifier">ack</span> = <span class="ruby-constant">Ack</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">name</span>, <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">original</span>, <span class="ruby-identifier">:error</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">error</span>)&#x000A;77: <span class="ruby-ivar">@response</span> = <span class="ruby-constant">Response</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">ack</span>)&#x000A;78: <span class="ruby-keyword kw">end</span></pre>
145
+ </div>
146
+ </div>
147
+ <div class='public-instance method' id='method-M000012'>
148
+ <a name='M000012'> </a>
149
+ <div class='synopsis'>
150
+ <span class='name'>no_response_available</span>
151
+ <span class='arguments'>()</span>
152
+ </div>
153
+ <div class='description'>
154
+ <p>
155
+ Determines if there is a response instance created. If not it creates one
156
+ with an Ack/Error describing not having anything to process.
157
+ </p>
158
+ </div>
159
+ <div class='source'>
160
+ <a class='source-toggle' href='#' onclick="toggleCode('M000012-source'); return false">
161
+ [show source]
162
+ </a>
163
+ <pre id='M000012-source'> <span class="ruby-comment cmt"># File lib/siffer/protocol.rb, line 83</span>&#x000A;83: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">no_response_available</span>&#x000A;84: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@response</span>.<span class="ruby-identifier">nil?</span>&#x000A;85: <span class="ruby-identifier">err</span> = <span class="ruby-value str">&quot;You are receiving this message because you failed to \nprovide enough information to respond to. This message \nwent completely through the messaging stack and\nfailed to instigate a response.\n \nPlease check the message you are sending and resend after \nany corrections.\n&quot;</span>&#x000A;86: <span class="ruby-operator">!</span><span class="ruby-identifier">error_response</span>(<span class="ruby-value">12</span>,<span class="ruby-value">1</span>,<span class="ruby-identifier">err</span>)&#x000A;87: <span class="ruby-keyword kw">end</span>&#x000A;88: <span class="ruby-keyword kw">end</span></pre>
164
+ </div>
165
+ </div>
166
+ <div class='public-instance method' id='method-M000007'>
167
+ <a name='M000007'> </a>
168
+ <div class='synopsis'>
169
+ <span class='name'>request_failed_protocol?</span>
170
+ <span class='arguments'>()</span>
171
+ </div>
172
+ <div class='description'>
173
+ <p>
174
+ Checks the incoming request against the following protocol constraints:
175
+ </p>
176
+ <ul>
177
+ <li>Unknown PATH
178
+
179
+ </li>
180
+ <li>Non-POST request
181
+
182
+ </li>
183
+ </ul>
184
+ </div>
185
+ <div class='source'>
186
+ <a class='source-toggle' href='#' onclick="toggleCode('M000007-source'); return false">
187
+ [show source]
188
+ </a>
189
+ <pre id='M000007-source'> <span class="ruby-comment cmt"># File lib/siffer/protocol.rb, line 16</span>&#x000A;16: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">request_failed_protocol?</span>&#x000A;17: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">get?</span> <span class="ruby-keyword kw">and</span> <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">path_info</span> <span class="ruby-operator">==</span> <span class="ruby-constant">ACCEPTABLE_PATHS</span>[<span class="ruby-identifier">:root</span>]&#x000A;18: <span class="ruby-identifier">root_response</span>&#x000A;19: <span class="ruby-keyword kw">else</span>&#x000A;20: <span class="ruby-keyword kw">begin</span>&#x000A;21: <span class="ruby-identifier">check_path_against_protocol</span>&#x000A;22: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">UnknownPath</span>&#x000A;23: <span class="ruby-comment cmt"># TODO: Make a better Not Found response</span>&#x000A;24: <span class="ruby-ivar">@response</span> = <span class="ruby-constant">Response</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">HTTP_STATUS_CODES</span>[<span class="ruby-value">404</span>],&#x000A;25: <span class="ruby-value">404</span>,&#x000A;26: {<span class="ruby-value str">&quot;Content-Type&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">MIME_TYPES</span>[<span class="ruby-value str">&quot;htm&quot;</span>]})&#x000A;27: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">NonPostRequest</span>&#x000A;28: <span class="ruby-comment cmt"># TODO: Make a better Method Not Allowed response</span>&#x000A;29: <span class="ruby-ivar">@response</span> = <span class="ruby-constant">Response</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">HTTP_STATUS_CODES</span>[<span class="ruby-value">405</span>],&#x000A;30: <span class="ruby-value">405</span>,&#x000A;31: {<span class="ruby-value str">&quot;Content-Type&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">MIME_TYPES</span>[<span class="ruby-value str">&quot;htm&quot;</span>]})&#x000A;32: <span class="ruby-keyword kw">end</span>&#x000A;33: <span class="ruby-keyword kw">end</span>&#x000A;34: <span class="ruby-keyword kw">end</span></pre>
190
+ </div>
191
+ </div>
192
+ <div class='public-instance method' id='method-M000013'>
193
+ <a name='M000013'> </a>
194
+ <div class='synopsis'>
195
+ <span class='name'>root_response</span>
196
+ <span class='arguments'>()</span>
197
+ </div>
198
+ <div class='source'>
199
+ <a class='source-toggle' href='#' onclick="toggleCode('M000013-source'); return false">
200
+ [show source]
201
+ </a>
202
+ <pre id='M000013-source'> <span class="ruby-comment cmt"># File lib/siffer/protocol.rb, line 99</span>&#x000A; 99: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">root_response</span>&#x000A;100: <span class="ruby-identifier">html</span> = <span class="ruby-value str">&quot;&lt;html&gt;\n &lt;body&gt;\n &lt;h1&gt;Siffer Endpoint&lt;/h1&gt;\n &lt;p&gt;You have reached a Siffer component.&lt;/p&gt;\n &lt;/body&gt;\n&lt;/html&gt;\n&quot;</span>&#x000A;101: <span class="ruby-ivar">@response</span> = <span class="ruby-constant">Response</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">html</span>,<span class="ruby-value">200</span>,{<span class="ruby-value str">&quot;Content-Type&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">MIME_TYPES</span>[<span class="ruby-value str">&quot;htm&quot;</span>]})&#x000A;102: <span class="ruby-keyword kw">end</span></pre>
203
+ </div>
204
+ </div>
205
+ <div class='public-instance method' id='method-M000009'>
206
+ <a name='M000009'> </a>
207
+ <div class='synopsis'>
208
+ <span class='name'>uri</span>
209
+ <span class='arguments'>()</span>
210
+ </div>
211
+ <div class='description'>
212
+ <p>
213
+ Returns the URI of the component (<a href="Server.html">Server</a> or <a
214
+ href="Agent.html">Agent</a>)
215
+ </p>
216
+ </div>
217
+ <div class='source'>
218
+ <a class='source-toggle' href='#' onclick="toggleCode('M000009-source'); return false">
219
+ [show source]
220
+ </a>
221
+ <pre id='M000009-source'> <span class="ruby-comment cmt"># File lib/siffer/protocol.rb, line 48</span>&#x000A;48: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">uri</span>&#x000A;49: <span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-node">&quot;http://#{host.gsub(/(http|https):\/\//,&quot;&quot;)}:#{port}&quot;</span>).<span class="ruby-identifier">to_s</span>&#x000A;50: <span class="ruby-keyword kw">end</span></pre>
222
+ </div>
223
+ </div>
224
+ <div class='public-instance method' id='method-M000010'>
225
+ <a name='M000010'> </a>
226
+ <div class='synopsis'>
227
+ <span class='name'>with_each_request</span>
228
+ <span class='arguments'>(env) {|if block_given?| ...}</span>
229
+ </div>
230
+ <div class='description'>
231
+ <pre>Provides a context for each request. Creates the @request, @response and&#x000A;@original objects to use throughout the call.&#x000A;Validates against Protocol as well as Messaging using #request_failed&#x000A;predicates respectively.&#x000A;&#x000A;Yields the block if provided to allow further processing.</pre>
232
+ <p>
233
+ Finishes by calling finish on the response object or returns the generic
234
+ </p>
235
+ <pre>response message.</pre>
236
+ </div>
237
+ <div class='source'>
238
+ <a class='source-toggle' href='#' onclick="toggleCode('M000010-source'); return false">
239
+ [show source]
240
+ </a>
241
+ <pre id='M000010-source'> <span class="ruby-comment cmt"># File lib/siffer/protocol.rb, line 61</span>&#x000A;61: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">with_each_request</span>(<span class="ruby-identifier">env</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)&#x000A;62: <span class="ruby-ivar">@request</span> = <span class="ruby-constant">Request</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">env</span>)&#x000A;63: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">request_failed_protocol?</span> <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">request_failed_messaging?</span>&#x000A;64: <span class="ruby-identifier">using_message_from</span> <span class="ruby-ivar">@request</span> <span class="ruby-keyword kw">do</span> <span class="ruby-comment cmt"># possibly a concurrency issue here</span>&#x000A;65: <span class="ruby-keyword kw">yield</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>&#x000A;66: <span class="ruby-keyword kw">end</span>&#x000A;67: <span class="ruby-keyword kw">end</span>&#x000A;68: <span class="ruby-ivar">@response</span>.<span class="ruby-identifier">finish</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">no_response_available</span>&#x000A;69: <span class="ruby-keyword kw">end</span></pre>
242
+ </div>
243
+ </div>
244
+ </div>
302
245
  </div>
303
246
  </div>
304
247
  </div>
305
-
306
- <div id="method-M000009" class="method-detail">
307
- <a name="M000009"></a>
308
-
309
- <div class="method-heading">
310
- <a href="#M000009" class="method-signature">
311
- <span class="method-name">uri</span><span class="method-args">()</span>
312
- </a>
313
- </div>
314
-
315
- <div class="method-description">
316
- <p>
317
- Returns the URI of the component (<a href="Server.html">Server</a> or <a
318
- href="Agent.html">Agent</a>)
319
- </p>
320
- <p><a class="source-toggle" href="#"
321
- onclick="toggleCode('M000009-source');return false;">[Source]</a></p>
322
- <div class="method-source-code" id="M000009-source">
323
- <pre>
324
- <span class="ruby-comment cmt"># File lib/protocol.rb, line 44</span>
325
- 44: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">uri</span>
326
- 45: <span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-node">&quot;http://#{host}:#{port}&quot;</span>).<span class="ruby-identifier">to_s</span>
327
- 46: <span class="ruby-keyword kw">end</span>
328
- </pre>
329
- </div>
330
- </div>
331
- </div>
332
-
333
- <div id="method-M000010" class="method-detail">
334
- <a name="M000010"></a>
335
-
336
- <div class="method-heading">
337
- <a href="#M000010" class="method-signature">
338
- <span class="method-name">with_each_request</span><span class="method-args">(env) {|if block_given?| ...}</span>
339
- </a>
340
- </div>
341
-
342
- <div class="method-description">
343
- <pre>
344
- Provides a context for each request. Creates the @request, @response and
345
- @original objects to use throughout the call.
346
- Validates against Protocol as well as Messaging using #request_failed
347
- predicates respectively.
348
-
349
- Yields the block if provided to allow further processing.
350
- </pre>
351
- <p>
352
- Finishes by calling finish on the response object or returns the generic
353
- </p>
354
- <pre>
355
- response message.
356
- </pre>
357
- <p><a class="source-toggle" href="#"
358
- onclick="toggleCode('M000010-source');return false;">[Source]</a></p>
359
- <div class="method-source-code" id="M000010-source">
360
- <pre>
361
- <span class="ruby-comment cmt"># File lib/protocol.rb, line 57</span>
362
- 57: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">with_each_request</span>(<span class="ruby-identifier">env</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
363
- 58: <span class="ruby-ivar">@request</span> = <span class="ruby-constant">Request</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">env</span>)
364
- 59: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">request_failed_protocol?</span> <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">request_failed_messaging?</span>
365
- 60: <span class="ruby-identifier">using_message_from</span> <span class="ruby-ivar">@request</span> <span class="ruby-keyword kw">do</span> <span class="ruby-comment cmt"># possibly a concurrency issue here</span>
366
- 61: <span class="ruby-keyword kw">yield</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
367
- 62: <span class="ruby-keyword kw">end</span>
368
- 63: <span class="ruby-keyword kw">end</span>
369
- 64: <span class="ruby-ivar">@response</span>.<span class="ruby-identifier">finish</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">no_response_available</span>
370
- 65: <span class="ruby-keyword kw">end</span>
371
- </pre>
372
- </div>
373
- </div>
374
- </div>
375
-
376
-
248
+ <div id='footer-push'></div>
249
+ </div>
250
+ <div id='footer'>
251
+ <a href="http://github.com/mislav/hanna/tree/master"><strong>Hanna</strong> RDoc template</a>
377
252
  </div>
378
-
379
-
380
- </div>
381
-
382
-
383
- <div id="validator-badges">
384
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
385
- </div>
386
-
387
- </body>
388
- </html>
253
+ </body>
254
+ </html>