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,269 +1,156 @@
1
- <?xml version="1.0" encoding="iso-8859-1"?>
2
- <!DOCTYPE html
3
- PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
-
6
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
- <head>
8
- <title>Class: Siffer::Messages::Status</title>
9
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
- <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
- <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
12
- <script type="text/javascript">
13
- // <![CDATA[
14
-
15
- function popupCode( url ) {
16
- window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
- }
18
-
19
- function toggleCode( id ) {
20
- if ( document.getElementById )
21
- elem = document.getElementById( id );
22
- else if ( document.all )
23
- elem = eval( "document.all." + id );
24
- else
25
- return false;
26
-
27
- elemStyle = elem.style;
28
-
29
- if ( elemStyle.display != "block" ) {
30
- elemStyle.display = "block"
31
- } else {
32
- elemStyle.display = "none"
33
- }
34
-
35
- return true;
36
- }
37
-
38
- // Make codeblocks hidden by default
39
- document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
-
41
- // ]]>
42
- </script>
43
-
44
- </head>
45
- <body>
46
-
47
-
48
-
49
- <div id="classHeader">
50
- <table class="header-table">
51
- <tr class="top-aligned-row">
52
- <td><strong>Class</strong></td>
53
- <td class="class-name-in-header">Siffer::Messages::Status</td>
54
- </tr>
55
- <tr class="top-aligned-row">
56
- <td><strong>In:</strong></td>
57
- <td>
58
- <a href="../../../files/lib/messages/status_rb.html">
59
- lib/messages/status.rb
60
- </a>
61
- <br />
62
- </td>
63
- </tr>
64
-
65
- <tr class="top-aligned-row">
66
- <td><strong>Parent:</strong></td>
67
- <td>
68
- Object
69
- </td>
70
- </tr>
71
- </table>
72
- </div>
73
- <!-- banner header -->
74
-
75
- <div id="bodyContent">
76
-
77
-
78
-
79
- <div id="contextContent">
80
-
81
-
82
-
83
- </div>
84
-
85
- <div id="method-list">
86
- <h3 class="section-bar">Methods</h3>
87
-
88
- <div class="name-list">
89
- <a href="#M000016">method_missing</a>&nbsp;&nbsp;
90
- <a href="#M000013">new</a>&nbsp;&nbsp;
91
- <a href="#M000014">read</a>&nbsp;&nbsp;
92
- <a href="#M000015">to_str</a>&nbsp;&nbsp;
93
- </div>
94
- </div>
95
-
96
- </div>
97
-
98
-
99
- <!-- if includes -->
100
-
101
- <div id="section">
102
-
103
-
104
- <div id="constants-list">
105
- <h3 class="section-bar">Constants</h3>
106
-
107
- <div class="name-list">
108
- <table summary="Constants">
109
- <tr class="top-aligned-row context-row">
110
- <td class="context-item-name">CODES</td>
111
- <td>=</td>
112
- <td class="context-item-value">{ 0 =&gt; &quot;Success&quot;, 1 =&gt; &quot;Immediate&quot;, 2 =&gt; &quot;Intermediate&quot;, 3 =&gt; &quot;Final&quot;, 7 =&gt; &quot;Duplicate&quot;, 8 =&gt; &quot;Sleeping&quot;, 9 =&gt; &quot;No Messages&quot;</td>
113
- </tr>
114
- </table>
115
- </div>
116
- </div>
117
-
118
-
119
-
120
- <div id="attribute-list">
121
- <h3 class="section-bar">Attributes</h3>
122
-
123
- <div class="name-list">
124
- <table>
125
- <tr class="top-aligned-row context-row">
126
- <td class="context-item-name">code</td>
127
- <td class="context-item-value">&nbsp;[R]&nbsp;</td>
128
- <td class="context-item-desc"></td>
129
- </tr>
130
- <tr class="top-aligned-row context-row">
131
- <td class="context-item-name">data</td>
132
- <td class="context-item-value">&nbsp;[R]&nbsp;</td>
133
- <td class="context-item-desc"></td>
134
- </tr>
135
- <tr class="top-aligned-row context-row">
136
- <td class="context-item-name">description</td>
137
- <td class="context-item-value">&nbsp;[R]&nbsp;</td>
138
- <td class="context-item-desc"></td>
139
- </tr>
140
- </table>
141
- </div>
142
- </div>
143
-
144
-
145
-
146
- <!-- if method_list -->
147
- <div id="methods">
148
- <h3 class="section-bar">Public Class methods</h3>
149
-
150
- <div id="method-M000016" class="method-detail">
151
- <a name="M000016"></a>
152
-
153
- <div class="method-heading">
154
- <a href="#M000016" class="method-signature">
155
- <span class="method-name">method_missing</span><span class="method-args">(sym,*args)</span>
156
- </a>
157
- </div>
158
-
159
- <div class="method-description">
160
- <p><a class="source-toggle" href="#"
161
- onclick="toggleCode('M000016-source');return false;">[Source]</a></p>
162
- <div class="method-source-code" id="M000016-source">
163
- <pre>
164
- <span class="ruby-comment cmt"># File lib/messages/status.rb, line 28</span>
165
- 28: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">method_missing</span>(<span class="ruby-identifier">sym</span>,<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
166
- 29: <span class="ruby-identifier">data</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">first</span>
167
- 30: <span class="ruby-identifier">status</span> = <span class="ruby-keyword kw">nil</span>
168
- 31: <span class="ruby-constant">CODES</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">val</span><span class="ruby-operator">|</span>
169
- 32: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">val</span>.<span class="ruby-identifier">downcase</span>.<span class="ruby-identifier">to_sym</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">sym</span>
170
- 33: <span class="ruby-identifier">status</span> = <span class="ruby-constant">Status</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">key</span>,<span class="ruby-identifier">data</span>)
171
- 34: <span class="ruby-keyword kw">end</span>
172
- 35: <span class="ruby-keyword kw">end</span>
173
- 36: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">status</span>
174
- 37: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">status</span>
175
- 38: <span class="ruby-keyword kw">else</span>
176
- 39: <span class="ruby-keyword kw">super</span>(<span class="ruby-identifier">sym</span>,<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
177
- 40: <span class="ruby-keyword kw">end</span>
178
- 41: <span class="ruby-keyword kw">end</span>
179
- </pre>
180
- </div>
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>Class: Siffer::Messages::Status [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'>Class</span>
30
+ Siffer::Messages::Status
31
+ </h1>
32
+ <ol class='paths'>
33
+ <li>
34
+ <a href="../../../files/lib/siffer/messages/status_rb.html">lib/siffer/messages/status.rb</a>
35
+ </li>
36
+ </ol>
37
+ <div class='parent'>
38
+ Parent:
39
+ <strong>Object</strong>
181
40
  </div>
182
41
  </div>
183
-
184
- <div id="method-M000013" class="method-detail">
185
- <a name="M000013"></a>
186
-
187
- <div class="method-heading">
188
- <a href="#M000013" class="method-signature">
189
- <span class="method-name">new</span><span class="method-args">(code,data)</span>
190
- </a>
191
- </div>
192
-
193
- <div class="method-description">
194
- <p><a class="source-toggle" href="#"
195
- onclick="toggleCode('M000013-source');return false;">[Source]</a></p>
196
- <div class="method-source-code" id="M000013-source">
197
- <pre>
198
- <span class="ruby-comment cmt"># File lib/messages/status.rb, line 8</span>
199
- 8: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">code</span>,<span class="ruby-identifier">data</span>)
200
- 9: <span class="ruby-ivar">@code</span> = <span class="ruby-identifier">code</span>
201
- 10: <span class="ruby-ivar">@description</span> = <span class="ruby-constant">CODES</span>[<span class="ruby-identifier">code</span>]
202
- 11: <span class="ruby-ivar">@data</span> = <span class="ruby-identifier">data</span>
203
- 12: <span class="ruby-keyword kw">end</span>
204
- </pre>
42
+ <div id='content'>
43
+ <div id='text'>
44
+ <div id='method-list'>
45
+ <h2>Methods</h2>
46
+ <h3>public class</h3>
47
+ <ol>
48
+ <li><a href="#M000017">method_missing</a></li>
49
+ <li><a href="#M000014">new</a></li>
50
+ </ol>
51
+ <h3>public instance</h3>
52
+ <ol>
53
+ <li><a href="#M000015">read</a></li>
54
+ <li><a href="#M000016">to_str</a></li>
55
+ </ol>
205
56
  </div>
206
- </div>
207
- </div>
208
-
209
- <h3 class="section-bar">Public Instance methods</h3>
210
-
211
- <div id="method-M000014" class="method-detail">
212
- <a name="M000014"></a>
213
-
214
- <div class="method-heading">
215
- <a href="#M000014" class="method-signature">
216
- <span class="method-name">read</span><span class="method-args">()</span>
217
- </a>
218
- </div>
219
-
220
- <div class="method-description">
221
- <p><a class="source-toggle" href="#"
222
- onclick="toggleCode('M000014-source');return false;">[Source]</a></p>
223
- <div class="method-source-code" id="M000014-source">
224
- <pre>
225
- <span class="ruby-comment cmt"># File lib/messages/status.rb, line 14</span>
226
- 14: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">read</span>
227
- 15: <span class="ruby-identifier">xml</span> = <span class="ruby-constant">Builder</span><span class="ruby-operator">::</span><span class="ruby-constant">XmlMarkup</span>.<span class="ruby-identifier">new</span>
228
- 16: <span class="ruby-identifier">xml</span>.<span class="ruby-constant">SIF_Status</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">status</span><span class="ruby-operator">|</span>
229
- 17: <span class="ruby-identifier">status</span>.<span class="ruby-constant">SIF_Code</span>(<span class="ruby-identifier">code</span>)
230
- 18: <span class="ruby-identifier">status</span>.<span class="ruby-constant">SIF_Description</span>(<span class="ruby-identifier">description</span>)
231
- 19: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">data</span>.<span class="ruby-identifier">nil?</span>
232
- 20: <span class="ruby-identifier">status</span>.<span class="ruby-constant">SIF_Data</span>
233
- 21: <span class="ruby-keyword kw">else</span>
234
- 22: <span class="ruby-identifier">status</span>.<span class="ruby-constant">SIF_Data</span>{ <span class="ruby-operator">|</span><span class="ruby-identifier">data_node</span><span class="ruby-operator">|</span> <span class="ruby-identifier">data_node</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">data</span>.<span class="ruby-identifier">read</span> }
235
- 23: <span class="ruby-keyword kw">end</span>
236
- 24: }
237
- 25: <span class="ruby-keyword kw">end</span>
238
- </pre>
57
+ <div id='section'>
58
+ <div id='constants-list'>
59
+ <h2>Constants</h2>
60
+ <div class='name-list'>
61
+ <table summary='Constants'>
62
+ <tr class='top-aligned-row context-row'>
63
+ <td class='context-item-name'>CODES</td>
64
+ <td>=</td>
65
+ <td class='context-item-value'>{ 0 =&gt; &quot;Success&quot;, 1 =&gt; &quot;Immediate&quot;, 2 =&gt; &quot;Intermediate&quot;, 3 =&gt; &quot;Final&quot;, 7 =&gt; &quot;Duplicate&quot;, 8 =&gt; &quot;Sleeping&quot;, 9 =&gt; &quot;No Messages&quot; }</td>
66
+ </tr>
67
+ </table>
68
+ </div>
69
+ </div>
70
+ <div id='attribute-list'>
71
+ <h2 class='section-bar'>Attributes</h2>
72
+ <div class='name-list'>
73
+ <table>
74
+ <tr class='top-aligned-row context-row'>
75
+ <td class='context-item-name'>code</td>
76
+ <td class='context-item-value'>[R]</td>
77
+ <td class='context-item-desc'></td>
78
+ </tr>
79
+ <tr class='top-aligned-row context-row'>
80
+ <td class='context-item-name'>data</td>
81
+ <td class='context-item-value'>[R]</td>
82
+ <td class='context-item-desc'></td>
83
+ </tr>
84
+ <tr class='top-aligned-row context-row'>
85
+ <td class='context-item-name'>description</td>
86
+ <td class='context-item-value'>[R]</td>
87
+ <td class='context-item-desc'></td>
88
+ </tr>
89
+ </table>
90
+ </div>
91
+ </div>
92
+ <div id='methods'>
93
+ <h2>Public class methods</h2>
94
+ <div class='public-class method' id='method-M000017'>
95
+ <a name='M000017'> </a>
96
+ <div class='synopsis'>
97
+ <span class='name'>method_missing</span>
98
+ <span class='arguments'>(sym,*args)</span>
99
+ </div>
100
+ <div class='source'>
101
+ <a class='source-toggle' href='#' onclick="toggleCode('M000017-source'); return false">
102
+ [show source]
103
+ </a>
104
+ <pre id='M000017-source'> <span class="ruby-comment cmt"># File lib/siffer/messages/status.rb, line 28</span>&#x000A;28: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">method_missing</span>(<span class="ruby-identifier">sym</span>,<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)&#x000A;29: <span class="ruby-identifier">data</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">first</span>&#x000A;30: <span class="ruby-identifier">status</span> = <span class="ruby-keyword kw">nil</span>&#x000A;31: <span class="ruby-constant">CODES</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">val</span><span class="ruby-operator">|</span>&#x000A;32: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">val</span>.<span class="ruby-identifier">downcase</span>.<span class="ruby-identifier">to_sym</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">sym</span>&#x000A;33: <span class="ruby-identifier">status</span> = <span class="ruby-constant">Status</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">key</span>,<span class="ruby-identifier">data</span>)&#x000A;34: <span class="ruby-keyword kw">end</span>&#x000A;35: <span class="ruby-keyword kw">end</span>&#x000A;36: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">status</span>&#x000A;37: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">status</span>&#x000A;38: <span class="ruby-keyword kw">else</span>&#x000A;39: <span class="ruby-keyword kw">super</span>(<span class="ruby-identifier">sym</span>,<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)&#x000A;40: <span class="ruby-keyword kw">end</span>&#x000A;41: <span class="ruby-keyword kw">end</span></pre>
105
+ </div>
106
+ </div>
107
+ <div class='public-class method' id='method-M000014'>
108
+ <a name='M000014'> </a>
109
+ <div class='synopsis'>
110
+ <span class='name'>new</span>
111
+ <span class='arguments'>(code,data)</span>
112
+ </div>
113
+ <div class='source'>
114
+ <a class='source-toggle' href='#' onclick="toggleCode('M000014-source'); return false">
115
+ [show source]
116
+ </a>
117
+ <pre id='M000014-source'> <span class="ruby-comment cmt"># File lib/siffer/messages/status.rb, line 8</span>&#x000A; 8: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">code</span>,<span class="ruby-identifier">data</span>)&#x000A; 9: <span class="ruby-ivar">@code</span> = <span class="ruby-identifier">code</span>&#x000A;10: <span class="ruby-ivar">@description</span> = <span class="ruby-constant">CODES</span>[<span class="ruby-identifier">code</span>]&#x000A;11: <span class="ruby-ivar">@data</span> = <span class="ruby-identifier">data</span>&#x000A;12: <span class="ruby-keyword kw">end</span></pre>
118
+ </div>
119
+ </div>
120
+ <h2>Public instance methods</h2>
121
+ <div class='public-instance method' id='method-M000015'>
122
+ <a name='M000015'> </a>
123
+ <div class='synopsis'>
124
+ <span class='name'>read</span>
125
+ <span class='arguments'>()</span>
126
+ </div>
127
+ <div class='source'>
128
+ <a class='source-toggle' href='#' onclick="toggleCode('M000015-source'); return false">
129
+ [show source]
130
+ </a>
131
+ <pre id='M000015-source'> <span class="ruby-comment cmt"># File lib/siffer/messages/status.rb, line 14</span>&#x000A;14: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">read</span>&#x000A;15: <span class="ruby-identifier">xml</span> = <span class="ruby-constant">Builder</span><span class="ruby-operator">::</span><span class="ruby-constant">XmlMarkup</span>.<span class="ruby-identifier">new</span>&#x000A;16: <span class="ruby-identifier">xml</span>.<span class="ruby-constant">SIF_Status</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">status</span><span class="ruby-operator">|</span>&#x000A;17: <span class="ruby-identifier">status</span>.<span class="ruby-constant">SIF_Code</span>(<span class="ruby-identifier">code</span>)&#x000A;18: <span class="ruby-identifier">status</span>.<span class="ruby-constant">SIF_Description</span>(<span class="ruby-identifier">description</span>)&#x000A;19: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">data</span>.<span class="ruby-identifier">nil?</span>&#x000A;20: <span class="ruby-identifier">status</span>.<span class="ruby-constant">SIF_Data</span>&#x000A;21: <span class="ruby-keyword kw">else</span>&#x000A;22: <span class="ruby-identifier">status</span>.<span class="ruby-constant">SIF_Data</span>{ <span class="ruby-operator">|</span><span class="ruby-identifier">data_node</span><span class="ruby-operator">|</span> <span class="ruby-identifier">data_node</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">data</span>.<span class="ruby-identifier">read</span> }&#x000A;23: <span class="ruby-keyword kw">end</span>&#x000A;24: }&#x000A;25: <span class="ruby-keyword kw">end</span></pre>
132
+ </div>
133
+ </div>
134
+ <div class='public-instance method' id='method-M000016'>
135
+ <a name='M000016'> </a>
136
+ <div class='synopsis'>
137
+ <span class='name'>to_str</span>
138
+ <span class='arguments'>()</span>
139
+ </div>
140
+ <div class='description'>
141
+ <p>
142
+ Alias for <a href="Status.html#M000015">read</a>
143
+ </p>
144
+ </div>
145
+ </div>
146
+ </div>
239
147
  </div>
240
148
  </div>
241
149
  </div>
242
-
243
- <div id="method-M000015" class="method-detail">
244
- <a name="M000015"></a>
245
-
246
- <div class="method-heading">
247
- <span class="method-name">to_str</span><span class="method-args">()</span>
248
- </div>
249
-
250
- <div class="method-description">
251
- <p>
252
- Alias for <a href="Status.html#M000014">read</a>
253
- </p>
254
- </div>
255
- </div>
256
-
257
-
150
+ <div id='footer-push'></div>
151
+ </div>
152
+ <div id='footer'>
153
+ <a href="http://github.com/mislav/hanna/tree/master"><strong>Hanna</strong> RDoc template</a>
258
154
  </div>
259
-
260
-
261
- </div>
262
-
263
-
264
- <div id="validator-badges">
265
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
266
- </div>
267
-
268
- </body>
269
- </html>
155
+ </body>
156
+ </html>
@@ -1,331 +1,212 @@
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::Messaging</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::Messaging</td>
54
- </tr>
55
- <tr class="top-aligned-row">
56
- <td><strong>In:</strong></td>
57
- <td>
58
- <a href="../../files/lib/messaging_rb.html">
59
- lib/messaging.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="Messaging.html">Messaging</a> module takes care of all of the
78
- Message handling for <a href="../Siffer.html">Siffer</a>. It will check
79
- messages against content-type constraints as well as validate the message
80
- XML against constraints outlined in the SIF Implementation Specification.
81
- </p>
82
-
83
- </div>
84
-
85
-
86
- </div>
87
-
88
- <div id="method-list">
89
- <h3 class="section-bar">Methods</h3>
90
-
91
- <div class="name-list">
92
- <a href="#M000050">check_content_type</a>&nbsp;&nbsp;
93
- <a href="#M000048">request_failed_messaging?</a>&nbsp;&nbsp;
94
- <a href="#M000049">using_message_from</a>&nbsp;&nbsp;
95
- <a href="#M000051">validate_message</a>&nbsp;&nbsp;
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::Messaging [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::Messaging
31
+ </h1>
32
+ <ol class='paths'>
33
+ <li>
34
+ <a href="../../files/lib/siffer/messaging_rb.html">lib/siffer/messaging.rb</a>
35
+ </li>
36
+ </ol>
96
37
  </div>
97
- </div>
98
-
99
- </div>
100
-
101
-
102
- <!-- if includes -->
103
- <div id="includes">
104
- <h3 class="section-bar">Included Modules</h3>
105
-
106
- <div id="includes-list">
107
- <span class="include-name"><a href="Messages.html">Siffer::Messages</a></span>
108
- </div>
109
- </div>
110
-
111
- <div id="section">
112
-
113
-
114
- <div id="constants-list">
115
- <h3 class="section-bar">Constants</h3>
116
-
117
- <div class="name-list">
118
- <table summary="Constants">
119
- <tr class="top-aligned-row context-row">
120
- <td class="context-item-name">MIME_TYPES</td>
121
- <td>=</td>
122
- <td class="context-item-value">{ &quot;appxml&quot; =&gt; &quot;application/xml;charset=utf-8&quot;, &quot;htm&quot; =&gt; &quot;text/html&quot;, &quot;html&quot; =&gt; &quot;text/html&quot;, &quot;xml&quot; =&gt; &quot;text/xml&quot;</td>
123
- <td width="3em">&nbsp;</td>
124
- <td class="context-item-desc">
125
- MIME Types used in <a href="../Siffer.html">Siffer</a>
126
-
127
- </td>
128
- </tr>
129
- </table>
130
- </div>
131
- </div>
132
-
133
-
134
-
135
-
136
-
137
-
138
- <!-- if method_list -->
139
- <div id="methods">
140
- <h3 class="section-bar">Public Instance methods</h3>
141
-
142
- <div id="method-M000050" class="method-detail">
143
- <a name="M000050"></a>
144
-
145
- <div class="method-heading">
146
- <a href="#M000050" class="method-signature">
147
- <span class="method-name">check_content_type</span><span class="method-args">()</span>
148
- </a>
149
- </div>
150
-
151
- <div class="method-description">
152
- <p>
153
- Reads request content type and validates it&#8216;s either text/xml or
154
- application/xml;charset=utf-8. If it isn&#8216;t it will raise a
155
- BadContentType exception.
156
- </p>
157
- <p><a class="source-toggle" href="#"
158
- onclick="toggleCode('M000050-source');return false;">[Source]</a></p>
159
- <div class="method-source-code" id="M000050-source">
160
- <pre>
161
- <span class="ruby-comment cmt"># File lib/messaging.rb, line 49</span>
162
- 49: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">check_content_type</span>
163
- 50: <span class="ruby-identifier">content_type</span> = <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">content_type</span>
164
- 51: <span class="ruby-keyword kw">unless</span> [<span class="ruby-constant">MIME_TYPES</span>[<span class="ruby-value str">&quot;xml&quot;</span>], <span class="ruby-constant">MIME_TYPES</span>[<span class="ruby-value str">&quot;appxml&quot;</span>]].<span class="ruby-identifier">include?</span> <span class="ruby-identifier">content_type</span>
165
- 52: <span class="ruby-identifier">raise</span> <span class="ruby-constant">BadContentType</span>
166
- 53: <span class="ruby-keyword kw">end</span>
167
- 54: <span class="ruby-keyword kw">end</span>
168
- </pre>
38
+ <div id='content'>
39
+ <div id='text'>
40
+ <div id='description'>
41
+ <p>
42
+ The <a href="Messaging.html">Messaging</a> module takes care of all of the
43
+ Message handling for <a href="../Siffer.html">Siffer</a>. It will check
44
+ messages against content-type constraints as well as validate the message
45
+ XML against constraints outlined in the SIF Implementation Specification.
46
+ </p>
169
47
  </div>
170
- </div>
171
- </div>
172
-
173
- <div id="method-M000048" class="method-detail">
174
- <a name="M000048"></a>
175
-
176
- <div class="method-heading">
177
- <a href="#M000048" class="method-signature">
178
- <span class="method-name">request_failed_messaging?</span><span class="method-args">()</span>
179
- </a>
180
- </div>
181
-
182
- <div class="method-description">
183
- <p>
184
- Checks the request against the messaging constraints:
185
- </p>
186
- <ul>
187
- <li><a href="Messaging.html#M000050">check_content_type</a>
188
-
189
- </li>
190
- <li><a href="Messaging.html#M000051">validate_message</a>
191
-
192
- </li>
193
- </ul>
194
- <p>
195
- Raises exceptions accordingly.
196
- </p>
197
- <p><a class="source-toggle" href="#"
198
- onclick="toggleCode('M000048-source');return false;">[Source]</a></p>
199
- <div class="method-source-code" id="M000048-source">
200
- <pre>
201
- <span class="ruby-comment cmt"># File lib/messaging.rb, line 25</span>
202
- 25: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">request_failed_messaging?</span>
203
- 26: <span class="ruby-keyword kw">begin</span>
204
- 27: <span class="ruby-identifier">check_content_type</span>
205
- 28: <span class="ruby-identifier">validate_message</span>
206
- 29: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">BadContentType</span>
207
- 30: <span class="ruby-comment cmt"># Make a better Not Acceptable response</span>
208
- 31: <span class="ruby-ivar">@response</span> = <span class="ruby-constant">Response</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">Siffer</span><span class="ruby-operator">::</span><span class="ruby-constant">Protocol</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP_STATUS_CODES</span>[<span class="ruby-value">406</span>],
209
- 32: <span class="ruby-value">406</span>,
210
- 33: {<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>]})
211
- 34: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">MalformedXml</span>; <span class="ruby-identifier">error_response</span>(<span class="ruby-value">1</span>,<span class="ruby-value">2</span>);
212
- 35: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">MalformedSIFMessage</span>; <span class="ruby-identifier">error_response</span>(<span class="ruby-value">12</span>,<span class="ruby-value">2</span>);
213
- 36: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">VersionMismatch</span>; <span class="ruby-identifier">error_response</span>(<span class="ruby-value">12</span>,<span class="ruby-value">3</span>);
214
- 37: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">XmlNsMismatch</span>; <span class="ruby-identifier">error_response</span>(<span class="ruby-value">1</span>,<span class="ruby-value">4</span>,<span class="ruby-value str">&quot;XMLNS not compatible with SIF&quot;</span>)
215
- 38: <span class="ruby-keyword kw">end</span>
216
- 39: <span class="ruby-keyword kw">end</span>
217
- </pre>
48
+ <div id='method-list'>
49
+ <h2>Methods</h2>
50
+ <h3>public instance</h3>
51
+ <ol>
52
+ <li><a href="#M000051">check_content_type</a></li>
53
+ <li><a href="#M000049">request_failed_messaging?</a></li>
54
+ <li><a href="#M000050">using_message_from</a></li>
55
+ <li><a href="#M000052">validate_message</a></li>
56
+ </ol>
218
57
  </div>
219
- </div>
220
- </div>
221
-
222
- <div id="method-M000049" class="method-detail">
223
- <a name="M000049"></a>
224
-
225
- <div class="method-heading">
226
- <a href="#M000049" class="method-signature">
227
- <span class="method-name">using_message_from</span><span class="method-args">(request) {|if block_given?| ...}</span>
228
- </a>
229
- </div>
230
-
231
- <div class="method-description">
232
- <p>
233
- Provides a context for the original message.
234
- </p>
235
- <p><a class="source-toggle" href="#"
236
- onclick="toggleCode('M000049-source');return false;">[Source]</a></p>
237
- <div class="method-source-code" id="M000049-source">
238
- <pre>
239
- <span class="ruby-comment cmt"># File lib/messaging.rb, line 42</span>
240
- 42: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">using_message_from</span>(<span class="ruby-identifier">request</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
241
- 43: <span class="ruby-keyword kw">yield</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
242
- 44: <span class="ruby-keyword kw">end</span>
243
- </pre>
58
+ <div id='context'>
59
+ <div id='includes'>
60
+ <h2>Included modules</h2>
61
+ <ol>
62
+ <li><a href="Messages.html">Siffer::Messages</a></li>
63
+ </ol>
64
+ </div>
244
65
  </div>
245
- </div>
246
- </div>
247
-
248
- <div id="method-M000051" class="method-detail">
249
- <a name="M000051"></a>
250
-
251
- <div class="method-heading">
252
- <a href="#M000051" class="method-signature">
253
- <span class="method-name">validate_message</span><span class="method-args">()</span>
254
- </a>
255
- </div>
256
-
257
- <div class="method-description">
258
- <p>
259
- Validates the <a href="Request.html">Request</a> Body against the
260
- constraints of SIF <a href="Messaging.html">Messaging</a>. The word
261
- &quot;validate&quot; is used loosely as there is no XML validation
262
- currently.
263
- </p>
264
- <p>
265
- Currently validates:
266
- </p>
267
- <ul>
268
- <li><tt>well-formed XML</tt> - XML must be well formed.
269
-
270
- </li>
271
- <li><tt>message root</tt> - XML must be a SIF message.
272
-
273
- </li>
274
- <li><tt>version</tt> - Must match SIF version implemented.
275
-
276
- </li>
277
- <li><tt>xmlns</tt> - Must match xmlns implemented.
278
-
279
- </li>
280
- </ul>
281
- <p>
282
- Does not validate:
283
- </p>
284
- <ul>
285
- <li>valid XML
286
-
287
- </li>
288
- <li>different versions of SIF
289
-
290
- </li>
291
- </ul>
292
- <p><a class="source-toggle" href="#"
293
- onclick="toggleCode('M000051-source');return false;">[Source]</a></p>
294
- <div class="method-source-code" id="M000051-source">
295
- <pre>
296
- <span class="ruby-comment cmt"># File lib/messaging.rb, line 69</span>
297
- 69: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">validate_message</span>
298
- 70: <span class="ruby-keyword kw">begin</span>
299
- 71: <span class="ruby-identifier">body</span> = (<span class="ruby-ivar">@request</span>.<span class="ruby-identifier">body</span>.<span class="ruby-identifier">respond_to?</span> <span class="ruby-identifier">:read</span>) <span class="ruby-operator">?</span> <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">body</span>.<span class="ruby-identifier">read</span> <span class="ruby-operator">:</span> <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">body</span>
300
- 72: <span class="ruby-identifier">xml</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Document</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">body</span>)
301
- 73: <span class="ruby-comment cmt"># validate Message Root</span>
302
- 74: <span class="ruby-identifier">raise</span> <span class="ruby-constant">MalformedXml</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">nil?</span>
303
- 75: <span class="ruby-comment cmt"># validate Message Root is a SIF_Message</span>
304
- 76: <span class="ruby-identifier">raise</span> <span class="ruby-constant">MalformedSIFMessage</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">name</span> <span class="ruby-operator">!=</span> <span class="ruby-value str">&quot;SIF_Message&quot;</span>
305
- 77: <span class="ruby-comment cmt"># validate SIF version</span>
306
- 78: <span class="ruby-identifier">raise</span> <span class="ruby-constant">VersionMismatch</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">attributes</span>[<span class="ruby-value str">&quot;version&quot;</span>] <span class="ruby-operator">!=</span> <span class="ruby-constant">Siffer</span>.<span class="ruby-identifier">sif_version</span>
307
- 79: <span class="ruby-comment cmt"># validate SIF xmlns</span>
308
- 80: <span class="ruby-identifier">raise</span> <span class="ruby-constant">XmlNsMismatch</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">attributes</span>[<span class="ruby-value str">&quot;xmlns&quot;</span>] <span class="ruby-operator">!=</span> <span class="ruby-constant">Siffer</span>.<span class="ruby-identifier">sif_xmlns</span>
309
- 81: <span class="ruby-comment cmt"># any others?</span>
310
- 82: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">ParseException</span>
311
- 83: <span class="ruby-identifier">raise</span> <span class="ruby-constant">MalformedXml</span>
312
- 84: <span class="ruby-keyword kw">end</span>
313
- 85: <span class="ruby-keyword kw">end</span>
314
- </pre>
66
+ <div id='section'>
67
+ <div id='constants-list'>
68
+ <h2>Constants</h2>
69
+ <div class='name-list'>
70
+ <table summary='Constants'>
71
+ <tr class='top-aligned-row context-row'>
72
+ <td class='context-item-name'>MIME_TYPES</td>
73
+ <td>=</td>
74
+ <td class='context-item-value'>{ &quot;appxmlencoded&quot; =&gt; &quot;application/xml;charset=utf-8&quot;, &quot;appxml&quot; =&gt; &quot;application/xml&quot;, &quot;htm&quot; =&gt; &quot;text/html&quot;, &quot;html&quot; =&gt; &quot;text/html&quot;, &quot;xml&quot; =&gt; &quot;text/xml&quot; }</td>
75
+ <td>&nbsp;</td>
76
+ <td class='context-item-desc'>
77
+
78
+ MIME Types used in <a href="../Siffer.html">Siffer</a>
79
+ </td>
80
+ </tr>
81
+ </table>
82
+ </div>
83
+ </div>
84
+ <div id='methods'>
85
+ <h2>Public instance methods</h2>
86
+ <div class='public-instance method' id='method-M000051'>
87
+ <a name='M000051'> </a>
88
+ <div class='synopsis'>
89
+ <span class='name'>check_content_type</span>
90
+ <span class='arguments'>()</span>
91
+ </div>
92
+ <div class='description'>
93
+ <p>
94
+ Reads request content type and validates it&#8217;s either text/xml or
95
+ application/xml;charset=utf-8. If it isn&#8217;t it will raise a
96
+ BadContentType exception.
97
+ </p>
98
+ </div>
99
+ <div class='source'>
100
+ <a class='source-toggle' href='#' onclick="toggleCode('M000051-source'); return false">
101
+ [show source]
102
+ </a>
103
+ <pre id='M000051-source'> <span class="ruby-comment cmt"># File lib/siffer/messaging.rb, line 49</span>&#x000A;49: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">check_content_type</span>&#x000A;50: <span class="ruby-identifier">content_type</span> = <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">content_type</span>&#x000A;51: <span class="ruby-keyword kw">unless</span> [<span class="ruby-constant">MIME_TYPES</span>[<span class="ruby-value str">&quot;xml&quot;</span>], &#x000A;52: <span class="ruby-constant">MIME_TYPES</span>[<span class="ruby-value str">&quot;appxml&quot;</span>], &#x000A;53: <span class="ruby-constant">MIME_TYPES</span>[<span class="ruby-value str">&quot;appxmlencoded&quot;</span>]].<span class="ruby-identifier">include?</span> <span class="ruby-identifier">content_type</span>&#x000A;54: <span class="ruby-identifier">raise</span> <span class="ruby-constant">BadContentType</span>&#x000A;55: <span class="ruby-keyword kw">end</span>&#x000A;56: <span class="ruby-keyword kw">end</span></pre>
104
+ </div>
105
+ </div>
106
+ <div class='public-instance method' id='method-M000049'>
107
+ <a name='M000049'> </a>
108
+ <div class='synopsis'>
109
+ <span class='name'>request_failed_messaging?</span>
110
+ <span class='arguments'>()</span>
111
+ </div>
112
+ <div class='description'>
113
+ <p>
114
+ Checks the request against the messaging constraints:
115
+ </p>
116
+ <ul>
117
+ <li><a href="Messaging.html#M000051">check_content_type</a>
118
+
119
+ </li>
120
+ <li><a href="Messaging.html#M000052">validate_message</a>
121
+
122
+ </li>
123
+ </ul>
124
+ <p>
125
+ Raises exceptions accordingly.
126
+ </p>
127
+ </div>
128
+ <div class='source'>
129
+ <a class='source-toggle' href='#' onclick="toggleCode('M000049-source'); return false">
130
+ [show source]
131
+ </a>
132
+ <pre id='M000049-source'> <span class="ruby-comment cmt"># File lib/siffer/messaging.rb, line 25</span>&#x000A;25: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">request_failed_messaging?</span>&#x000A;26: <span class="ruby-keyword kw">begin</span>&#x000A;27: <span class="ruby-identifier">check_content_type</span>&#x000A;28: <span class="ruby-identifier">validate_message</span>&#x000A;29: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">BadContentType</span>&#x000A;30: <span class="ruby-comment cmt"># Make a better Not Acceptable response</span>&#x000A;31: <span class="ruby-ivar">@response</span> = <span class="ruby-constant">Response</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">Siffer</span><span class="ruby-operator">::</span><span class="ruby-constant">Protocol</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP_STATUS_CODES</span>[<span class="ruby-value">406</span>],&#x000A;32: <span class="ruby-value">406</span>,&#x000A;33: {<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;34: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">MalformedXml</span>; <span class="ruby-identifier">error_response</span>(<span class="ruby-value">1</span>,<span class="ruby-value">2</span>,<span class="ruby-value str">&quot;There was no XML body to parse.&quot;</span>);&#x000A;35: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">MalformedSIFMessage</span>; <span class="ruby-identifier">error_response</span>(<span class="ruby-value">12</span>,<span class="ruby-value">2</span>,<span class="ruby-value str">&quot;The XML was not a recognizable SIF Message.&quot;</span>);&#x000A;36: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">VersionMismatch</span>; <span class="ruby-identifier">error_response</span>(<span class="ruby-value">12</span>,<span class="ruby-value">3</span>,<span class="ruby-value str">&quot;The SIF version did not match supported versions.&quot;</span>);&#x000A;37: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">XmlNsMismatch</span>; <span class="ruby-identifier">error_response</span>(<span class="ruby-value">1</span>,<span class="ruby-value">4</span>,<span class="ruby-value str">&quot;XMLNS not compatible with SIF&quot;</span>)&#x000A;38: <span class="ruby-keyword kw">end</span>&#x000A;39: <span class="ruby-keyword kw">end</span></pre>
133
+ </div>
134
+ </div>
135
+ <div class='public-instance method' id='method-M000050'>
136
+ <a name='M000050'> </a>
137
+ <div class='synopsis'>
138
+ <span class='name'>using_message_from</span>
139
+ <span class='arguments'>(request) {|if block_given?| ...}</span>
140
+ </div>
141
+ <div class='description'>
142
+ <p>
143
+ Provides a context for the original message.
144
+ </p>
145
+ </div>
146
+ <div class='source'>
147
+ <a class='source-toggle' href='#' onclick="toggleCode('M000050-source'); return false">
148
+ [show source]
149
+ </a>
150
+ <pre id='M000050-source'> <span class="ruby-comment cmt"># File lib/siffer/messaging.rb, line 42</span>&#x000A;42: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">using_message_from</span>(<span class="ruby-identifier">request</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)&#x000A;43: <span class="ruby-keyword kw">yield</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>&#x000A;44: <span class="ruby-keyword kw">end</span></pre>
151
+ </div>
152
+ </div>
153
+ <div class='public-instance method' id='method-M000052'>
154
+ <a name='M000052'> </a>
155
+ <div class='synopsis'>
156
+ <span class='name'>validate_message</span>
157
+ <span class='arguments'>()</span>
158
+ </div>
159
+ <div class='description'>
160
+ <p>
161
+ Validates the <a href="Request.html">Request</a> Body against the
162
+ constraints of SIF <a href="Messaging.html">Messaging</a>. The word
163
+ &#8220;validate&#8221; is used loosely as there is no XML validation
164
+ currently.
165
+ </p>
166
+ <p>
167
+ Currently validates:
168
+ </p>
169
+ <ul>
170
+ <li><tt>well-formed XML</tt> - XML must be well formed.
171
+
172
+ </li>
173
+ <li><tt>message root</tt> - XML must be a SIF message.
174
+
175
+ </li>
176
+ <li><tt>version</tt> - Must match SIF version implemented.
177
+
178
+ </li>
179
+ <li><tt>xmlns</tt> - Must match xmlns implemented.
180
+
181
+ </li>
182
+ </ul>
183
+ <p>
184
+ Does not validate:
185
+ </p>
186
+ <ul>
187
+ <li>valid XML
188
+
189
+ </li>
190
+ <li>different versions of SIF
191
+
192
+ </li>
193
+ </ul>
194
+ </div>
195
+ <div class='source'>
196
+ <a class='source-toggle' href='#' onclick="toggleCode('M000052-source'); return false">
197
+ [show source]
198
+ </a>
199
+ <pre id='M000052-source'> <span class="ruby-comment cmt"># File lib/siffer/messaging.rb, line 71</span>&#x000A;71: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">validate_message</span>&#x000A;72: <span class="ruby-keyword kw">begin</span>&#x000A;73: <span class="ruby-identifier">body</span> = (<span class="ruby-ivar">@request</span>.<span class="ruby-identifier">body</span>.<span class="ruby-identifier">respond_to?</span> <span class="ruby-identifier">:read</span>) <span class="ruby-operator">?</span> <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">body</span>.<span class="ruby-identifier">read</span> <span class="ruby-operator">:</span> <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">body</span>&#x000A;74: <span class="ruby-identifier">xml</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Document</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">body</span>)&#x000A;75: <span class="ruby-comment cmt"># validate Message Root</span>&#x000A;76: <span class="ruby-identifier">raise</span> <span class="ruby-constant">MalformedXml</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">nil?</span>&#x000A;77: <span class="ruby-comment cmt"># validate Message Root is a SIF_Message</span>&#x000A;78: <span class="ruby-identifier">raise</span> <span class="ruby-constant">MalformedSIFMessage</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">name</span> <span class="ruby-operator">!=</span> <span class="ruby-value str">&quot;SIF_Message&quot;</span>&#x000A;79: <span class="ruby-comment cmt"># validate SIF version</span>&#x000A;80: <span class="ruby-identifier">raise</span> <span class="ruby-constant">VersionMismatch</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">attributes</span>[<span class="ruby-value str">&quot;version&quot;</span>] <span class="ruby-operator">!=</span> <span class="ruby-constant">Siffer</span>.<span class="ruby-identifier">sif_version</span>&#x000A;81: <span class="ruby-comment cmt"># validate SIF xmlns</span>&#x000A;82: <span class="ruby-identifier">raise</span> <span class="ruby-constant">XmlNsMismatch</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">attributes</span>[<span class="ruby-value str">&quot;xmlns&quot;</span>] <span class="ruby-operator">!=</span> <span class="ruby-constant">Siffer</span>.<span class="ruby-identifier">sif_xmlns</span>&#x000A;83: <span class="ruby-comment cmt"># any others?</span>&#x000A;84: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">ParseException</span>&#x000A;85: <span class="ruby-identifier">raise</span> <span class="ruby-constant">MalformedXml</span>&#x000A;86: <span class="ruby-keyword kw">end</span>&#x000A;87: <span class="ruby-keyword kw">end</span></pre>
200
+ </div>
201
+ </div>
202
+ </div>
315
203
  </div>
316
204
  </div>
317
205
  </div>
318
-
319
-
206
+ <div id='footer-push'></div>
207
+ </div>
208
+ <div id='footer'>
209
+ <a href="http://github.com/mislav/hanna/tree/master"><strong>Hanna</strong> RDoc template</a>
320
210
  </div>
321
-
322
-
323
- </div>
324
-
325
-
326
- <div id="validator-badges">
327
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
328
- </div>
329
-
330
- </body>
331
- </html>
211
+ </body>
212
+ </html>