siffer 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +20 -0
- data/README.rdoc +65 -0
- data/Rakefile +64 -0
- data/bin/siffer +71 -0
- data/doc/SIF ImplementationSpecification.pdf +0 -0
- data/doc/rdoc/classes/Siffer.html +374 -0
- data/doc/rdoc/classes/Siffer/Agent.html +296 -0
- data/doc/rdoc/classes/Siffer/Container.html +286 -0
- data/doc/rdoc/classes/Siffer/Messages.html +141 -0
- data/doc/rdoc/classes/Siffer/Messages/Ack.html +216 -0
- data/doc/rdoc/classes/Siffer/Messages/Acl.html +160 -0
- data/doc/rdoc/classes/Siffer/Messages/Error.html +248 -0
- data/doc/rdoc/classes/Siffer/Messages/Message.html +359 -0
- data/doc/rdoc/classes/Siffer/Messages/Message/Header.html +181 -0
- data/doc/rdoc/classes/Siffer/Messages/Register.html +257 -0
- data/doc/rdoc/classes/Siffer/Messages/RequestBody.html +300 -0
- data/doc/rdoc/classes/Siffer/Messages/Status.html +269 -0
- data/doc/rdoc/classes/Siffer/Messaging.html +331 -0
- data/doc/rdoc/classes/Siffer/Protocol.html +388 -0
- data/doc/rdoc/classes/Siffer/Protocol/NonPostRequest.html +111 -0
- data/doc/rdoc/classes/Siffer/Protocol/UnknownPath.html +111 -0
- data/doc/rdoc/classes/Siffer/Registration.html +391 -0
- data/doc/rdoc/classes/Siffer/Request.html +209 -0
- data/doc/rdoc/classes/Siffer/RequestLogger.html +211 -0
- data/doc/rdoc/classes/Siffer/Response.html +182 -0
- data/doc/rdoc/classes/Siffer/Server.html +242 -0
- data/doc/rdoc/created.rid +1 -0
- data/doc/rdoc/files/LICENSE.html +129 -0
- data/doc/rdoc/files/README_rdoc.html +184 -0
- data/doc/rdoc/files/lib/agent_rb.html +101 -0
- data/doc/rdoc/files/lib/container_rb.html +108 -0
- data/doc/rdoc/files/lib/messages/ack_rb.html +101 -0
- data/doc/rdoc/files/lib/messages/acl_rb.html +101 -0
- data/doc/rdoc/files/lib/messages/error_rb.html +101 -0
- data/doc/rdoc/files/lib/messages/message_rb.html +101 -0
- data/doc/rdoc/files/lib/messages/register_rb.html +101 -0
- data/doc/rdoc/files/lib/messages/request_body_rb.html +101 -0
- data/doc/rdoc/files/lib/messages/status_rb.html +101 -0
- data/doc/rdoc/files/lib/messages_rb.html +114 -0
- data/doc/rdoc/files/lib/messaging_rb.html +101 -0
- data/doc/rdoc/files/lib/protocol_rb.html +101 -0
- data/doc/rdoc/files/lib/registration_rb.html +101 -0
- data/doc/rdoc/files/lib/request_logger_rb.html +101 -0
- data/doc/rdoc/files/lib/request_rb.html +101 -0
- data/doc/rdoc/files/lib/response_rb.html +101 -0
- data/doc/rdoc/files/lib/server_rb.html +101 -0
- data/doc/rdoc/files/lib/siffer_rb.html +115 -0
- data/doc/rdoc/fr_class_index.html +47 -0
- data/doc/rdoc/fr_file_index.html +46 -0
- data/doc/rdoc/fr_method_index.html +96 -0
- data/doc/rdoc/index.html +24 -0
- data/doc/rdoc/rdoc-style.css +208 -0
- data/lib/agent.rb +43 -0
- data/lib/container.rb +96 -0
- data/lib/messages.rb +7 -0
- data/lib/messages/ack.rb +43 -0
- data/lib/messages/acl.rb +25 -0
- data/lib/messages/error.rb +174 -0
- data/lib/messages/message.rb +71 -0
- data/lib/messages/register.rb +60 -0
- data/lib/messages/request_body.rb +66 -0
- data/lib/messages/status.rb +55 -0
- data/lib/messaging.rb +96 -0
- data/lib/protocol.rb +159 -0
- data/lib/registration.rb +87 -0
- data/lib/request.rb +25 -0
- data/lib/request_logger.rb +31 -0
- data/lib/response.rb +26 -0
- data/lib/server.rb +40 -0
- data/lib/siffer.rb +44 -0
- data/spec/agent_spec.rb +53 -0
- data/spec/cli_spec.rb +40 -0
- data/spec/container_spec.rb +103 -0
- data/spec/default_agent +6 -0
- data/spec/default_server +5 -0
- data/spec/message_specs/ack_spec.rb +28 -0
- data/spec/message_specs/error_spec.rb +24 -0
- data/spec/message_specs/header_spec.rb +25 -0
- data/spec/message_specs/message_spec.rb +57 -0
- data/spec/message_specs/register_spec.rb +86 -0
- data/spec/message_specs/request_body_spec.rb +58 -0
- data/spec/message_specs/status_spec.rb +25 -0
- data/spec/messaging_spec.rb +88 -0
- data/spec/protocol_spec.rb +49 -0
- data/spec/registration_spec.rb +33 -0
- data/spec/request_logger_spec.rb +15 -0
- data/spec/request_spec.rb +10 -0
- data/spec/response_spec.rb +24 -0
- data/spec/server_spec.rb +35 -0
- data/spec/spec_helper.rb +26 -0
- metadata +191 -0
|
@@ -0,0 +1,269 @@
|
|
|
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>
|
|
90
|
+
<a href="#M000013">new</a>
|
|
91
|
+
<a href="#M000014">read</a>
|
|
92
|
+
<a href="#M000015">to_str</a>
|
|
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 => "Success", 1 => "Immediate", 2 => "Intermediate", 3 => "Final", 7 => "Duplicate", 8 => "Sleeping", 9 => "No Messages"</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"> [R] </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"> [R] </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"> [R] </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>
|
|
181
|
+
</div>
|
|
182
|
+
</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>
|
|
205
|
+
</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"><<</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>
|
|
239
|
+
</div>
|
|
240
|
+
</div>
|
|
241
|
+
</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
|
+
|
|
258
|
+
</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>
|
|
@@ -0,0 +1,331 @@
|
|
|
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>
|
|
93
|
+
<a href="#M000048">request_failed_messaging?</a>
|
|
94
|
+
<a href="#M000049">using_message_from</a>
|
|
95
|
+
<a href="#M000051">validate_message</a>
|
|
96
|
+
</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">{ "appxml" => "application/xml;charset=utf-8", "htm" => "text/html", "html" => "text/html", "xml" => "text/xml"</td>
|
|
123
|
+
<td width="3em"> </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‘s either text/xml or
|
|
154
|
+
application/xml;charset=utf-8. If it isn‘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">"xml"</span>], <span class="ruby-constant">MIME_TYPES</span>[<span class="ruby-value str">"appxml"</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>
|
|
169
|
+
</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">"Content-Type"</span> =<span class="ruby-operator">></span> <span class="ruby-constant">MIME_TYPES</span>[<span class="ruby-value str">"htm"</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">"XMLNS not compatible with SIF"</span>)
|
|
215
|
+
38: <span class="ruby-keyword kw">end</span>
|
|
216
|
+
39: <span class="ruby-keyword kw">end</span>
|
|
217
|
+
</pre>
|
|
218
|
+
</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">&</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>
|
|
244
|
+
</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
|
+
"validate" 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">"SIF_Message"</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">"version"</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">"xmlns"</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>
|
|
315
|
+
</div>
|
|
316
|
+
</div>
|
|
317
|
+
</div>
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
</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>
|