siffer 0.0.5 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +1 -1
- data/README +93 -0
- data/lib/siffer.rb +13 -16
- data/lib/siffer/agent.rb +39 -31
- data/lib/siffer/core_ext/hash.rb +15 -0
- data/lib/siffer/messages.rb +38 -4
- data/lib/siffer/messages/ack.rb +160 -35
- data/lib/siffer/messages/event.rb +20 -0
- data/lib/siffer/messages/message.rb +47 -58
- data/lib/siffer/messages/provide.rb +25 -0
- data/lib/siffer/messages/provision.rb +17 -0
- data/lib/siffer/messages/register.rb +42 -52
- data/lib/siffer/messages/request.rb +138 -0
- data/lib/siffer/messages/response.rb +48 -0
- data/lib/siffer/messages/subscribe.rb +17 -0
- data/lib/siffer/messages/system_control.rb +94 -0
- data/lib/siffer/models.rb +1 -0
- data/lib/siffer/models/address.rb +39 -0
- metadata +25 -146
- data/README.rdoc +0 -65
- data/Rakefile +0 -64
- data/bin/siffer +0 -71
- data/doc/SIF ImplementationSpecification.pdf +0 -0
- data/doc/rdoc/classes/Siffer.html +0 -259
- data/doc/rdoc/classes/Siffer/Agent.html +0 -177
- data/doc/rdoc/classes/Siffer/Container.html +0 -165
- data/doc/rdoc/classes/Siffer/Messages.html +0 -81
- data/doc/rdoc/classes/Siffer/Messages/Ack.html +0 -115
- data/doc/rdoc/classes/Siffer/Messages/Acl.html +0 -83
- data/doc/rdoc/classes/Siffer/Messages/Error.html +0 -157
- data/doc/rdoc/classes/Siffer/Messages/Message.html +0 -235
- data/doc/rdoc/classes/Siffer/Messages/Message/Header.html +0 -107
- data/doc/rdoc/classes/Siffer/Messages/Register.html +0 -154
- data/doc/rdoc/classes/Siffer/Messages/RequestBody.html +0 -185
- data/doc/rdoc/classes/Siffer/Messages/Status.html +0 -156
- data/doc/rdoc/classes/Siffer/Messaging.html +0 -212
- data/doc/rdoc/classes/Siffer/Protocol.html +0 -254
- data/doc/rdoc/classes/Siffer/Protocol/NonPostRequest.html +0 -54
- data/doc/rdoc/classes/Siffer/Protocol/UnknownPath.html +0 -54
- data/doc/rdoc/classes/Siffer/Registration.html +0 -251
- data/doc/rdoc/classes/Siffer/Request.html +0 -103
- data/doc/rdoc/classes/Siffer/RequestLogger.html +0 -109
- data/doc/rdoc/classes/Siffer/Response.html +0 -91
- data/doc/rdoc/classes/Siffer/Server.html +0 -156
- data/doc/rdoc/created.rid +0 -1
- data/doc/rdoc/files/LICENSE.html +0 -76
- data/doc/rdoc/files/README_rdoc.html +0 -131
- data/doc/rdoc/files/lib/siffer/agent_rb.html +0 -49
- data/doc/rdoc/files/lib/siffer/container_rb.html +0 -57
- data/doc/rdoc/files/lib/siffer/messages/ack_rb.html +0 -49
- data/doc/rdoc/files/lib/siffer/messages/acl_rb.html +0 -49
- data/doc/rdoc/files/lib/siffer/messages/error_rb.html +0 -49
- data/doc/rdoc/files/lib/siffer/messages/message_rb.html +0 -49
- data/doc/rdoc/files/lib/siffer/messages/register_rb.html +0 -49
- data/doc/rdoc/files/lib/siffer/messages/request_body_rb.html +0 -49
- data/doc/rdoc/files/lib/siffer/messages/status_rb.html +0 -49
- data/doc/rdoc/files/lib/siffer/messages_rb.html +0 -63
- data/doc/rdoc/files/lib/siffer/messaging_rb.html +0 -49
- data/doc/rdoc/files/lib/siffer/protocol_rb.html +0 -49
- data/doc/rdoc/files/lib/siffer/registration_rb.html +0 -49
- data/doc/rdoc/files/lib/siffer/request_logger_rb.html +0 -49
- data/doc/rdoc/files/lib/siffer/request_rb.html +0 -49
- data/doc/rdoc/files/lib/siffer/response_rb.html +0 -49
- data/doc/rdoc/files/lib/siffer/server_rb.html +0 -49
- data/doc/rdoc/files/lib/siffer_rb.html +0 -64
- data/doc/rdoc/fr_class_index.html +0 -25
- data/doc/rdoc/fr_file_index.html +0 -39
- data/doc/rdoc/fr_method_index.html +0 -4539
- data/doc/rdoc/index.html +0 -15
- data/doc/rdoc/rdoc-style.css +0 -319
- data/lib/siffer/container.rb +0 -94
- data/lib/siffer/messages/acl.rb +0 -25
- data/lib/siffer/messages/error.rb +0 -174
- data/lib/siffer/messages/request_body.rb +0 -66
- data/lib/siffer/messages/status.rb +0 -55
- data/lib/siffer/messaging.rb +0 -99
- data/lib/siffer/protocol.rb +0 -164
- data/lib/siffer/registration.rb +0 -87
- data/lib/siffer/request.rb +0 -28
- data/lib/siffer/request_logger.rb +0 -32
- data/lib/siffer/response.rb +0 -26
- data/lib/siffer/server.rb +0 -42
- data/spec/agent_spec.rb +0 -48
- data/spec/cli_spec.rb +0 -40
- data/spec/container_spec.rb +0 -103
- data/spec/default_agent +0 -6
- data/spec/default_server +0 -5
- data/spec/message_specs/ack_spec.rb +0 -28
- data/spec/message_specs/error_spec.rb +0 -24
- data/spec/message_specs/header_spec.rb +0 -25
- data/spec/message_specs/message_spec.rb +0 -57
- data/spec/message_specs/register_spec.rb +0 -86
- data/spec/message_specs/request_body_spec.rb +0 -58
- data/spec/message_specs/status_spec.rb +0 -25
- data/spec/messaging_spec.rb +0 -85
- data/spec/protocol_spec.rb +0 -50
- data/spec/registration_spec.rb +0 -33
- data/spec/request_logger_spec.rb +0 -28
- data/spec/request_spec.rb +0 -25
- data/spec/response_spec.rb +0 -24
- data/spec/server_spec.rb +0 -30
- data/spec/spec_helper.rb +0 -35
@@ -1,185 +0,0 @@
|
|
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::RequestBody [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::RequestBody
|
31
|
-
</h1>
|
32
|
-
<ol class='paths'>
|
33
|
-
<li>
|
34
|
-
<a href="../../../files/lib/siffer/messages/request_body_rb.html">lib/siffer/messages/request_body.rb</a>
|
35
|
-
</li>
|
36
|
-
</ol>
|
37
|
-
<div class='parent'>
|
38
|
-
Parent:
|
39
|
-
<strong>Object</strong>
|
40
|
-
</div>
|
41
|
-
</div>
|
42
|
-
<div id='content'>
|
43
|
-
<div id='text'>
|
44
|
-
<div id='description'>
|
45
|
-
<p>
|
46
|
-
This class is used to parse the SIF <a href="Message.html">Message</a>
|
47
|
-
information out of the <a href="../Request.html">Request</a> Body. It
|
48
|
-
parses enough information to redirect to other processes. It does not parse
|
49
|
-
details of the <a href="Message.html">Message</a> such as <a
|
50
|
-
href="../Protocol.html">Protocol</a> if a <a
|
51
|
-
href="Register.html">Register</a> message, or <a
|
52
|
-
href="Error.html">Error</a> if an <a href="Ack.html">Ack</a> message. Each
|
53
|
-
message type will inherit this class in order to provide a <a
|
54
|
-
href="RequestBody.html#M000039">parse</a> method that will allow access to
|
55
|
-
those specific attributes. It provides access to:
|
56
|
-
</p>
|
57
|
-
<ul>
|
58
|
-
<li><a href="RequestBody.html#M000037">source_id</a>
|
59
|
-
|
60
|
-
</li>
|
61
|
-
<li><a href="RequestBody.html#M000038">msg_id</a>
|
62
|
-
|
63
|
-
</li>
|
64
|
-
<li>type
|
65
|
-
|
66
|
-
</li>
|
67
|
-
</ul>
|
68
|
-
</div>
|
69
|
-
<div id='method-list'>
|
70
|
-
<h2>Methods</h2>
|
71
|
-
<h3>public class</h3>
|
72
|
-
<ol>
|
73
|
-
<li><a href="#M000035">new</a></li>
|
74
|
-
<li><a href="#M000039">parse</a></li>
|
75
|
-
</ol>
|
76
|
-
<h3>public instance</h3>
|
77
|
-
<ol>
|
78
|
-
<li><a href="#M000038">msg_id</a></li>
|
79
|
-
<li><a href="#M000037">source_id</a></li>
|
80
|
-
<li><a href="#M000036">type</a></li>
|
81
|
-
</ol>
|
82
|
-
</div>
|
83
|
-
<div id='section'>
|
84
|
-
<div id='methods'>
|
85
|
-
<h2>Public class methods</h2>
|
86
|
-
<div class='public-class method' id='method-M000035'>
|
87
|
-
<a name='M000035'> </a>
|
88
|
-
<div class='synopsis'>
|
89
|
-
<span class='name'>new</span>
|
90
|
-
<span class='arguments'>(xml_string)</span>
|
91
|
-
</div>
|
92
|
-
<div class='source'>
|
93
|
-
<a class='source-toggle' href='#' onclick="toggleCode('M000035-source'); return false">
|
94
|
-
[show source]
|
95
|
-
</a>
|
96
|
-
<pre id='M000035-source'> <span class="ruby-comment cmt"># File lib/siffer/messages/request_body.rb, line 17</span>
17: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">xml_string</span>)
18: <span class="ruby-ivar">@xml</span> = <span class="ruby-identifier">xml_string</span>
19: <span class="ruby-ivar">@doc</span> = <span class="ruby-constant">Hpricot</span>(<span class="ruby-ivar">@xml</span>, <span class="ruby-identifier">:xml</span> =<span class="ruby-operator">></span> <span class="ruby-keyword kw">true</span>)
20: <span class="ruby-keyword kw">end</span></pre>
|
97
|
-
</div>
|
98
|
-
</div>
|
99
|
-
<div class='public-class method' id='method-M000039'>
|
100
|
-
<a name='M000039'> </a>
|
101
|
-
<div class='synopsis'>
|
102
|
-
<span class='name'>parse</span>
|
103
|
-
<span class='arguments'>(xml)</span>
|
104
|
-
</div>
|
105
|
-
<div class='description'>
|
106
|
-
<p>
|
107
|
-
Parses the xml provided and returns a <a
|
108
|
-
href="RequestBody.html">RequestBody</a>. Xml must respond to read or be a
|
109
|
-
String.
|
110
|
-
</p>
|
111
|
-
</div>
|
112
|
-
<div class='source'>
|
113
|
-
<a class='source-toggle' href='#' onclick="toggleCode('M000039-source'); return false">
|
114
|
-
[show source]
|
115
|
-
</a>
|
116
|
-
<pre id='M000039-source'> <span class="ruby-comment cmt"># File lib/siffer/messages/request_body.rb, line 48</span>
48: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">xml</span>)
49: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value str">"read"</span>) <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">String</span>)
50: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-value str">"Unable to read Xml"</span> 
51: <span class="ruby-keyword kw">end</span>
52: <span class="ruby-identifier">xml</span> = <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">read</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value str">"read"</span>)
53: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">xml</span>) <span class="ruby-comment cmt"># use self because we are going to inherit this class</span>
54: <span class="ruby-keyword kw">end</span></pre>
|
117
|
-
</div>
|
118
|
-
</div>
|
119
|
-
<h2>Public instance methods</h2>
|
120
|
-
<div class='public-instance method' id='method-M000038'>
|
121
|
-
<a name='M000038'> </a>
|
122
|
-
<div class='synopsis'>
|
123
|
-
<span class='name'>msg_id</span>
|
124
|
-
<span class='arguments'>()</span>
|
125
|
-
</div>
|
126
|
-
<div class='description'>
|
127
|
-
<p>
|
128
|
-
The SIF_MsgId from the SIF_Header
|
129
|
-
</p>
|
130
|
-
</div>
|
131
|
-
<div class='source'>
|
132
|
-
<a class='source-toggle' href='#' onclick="toggleCode('M000038-source'); return false">
|
133
|
-
[show source]
|
134
|
-
</a>
|
135
|
-
<pre id='M000038-source'> <span class="ruby-comment cmt"># File lib/siffer/messages/request_body.rb, line 42</span>
42: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">msg_id</span>
43: (<span class="ruby-ivar">@doc</span><span class="ruby-operator">/</span><span class="ruby-value str">"//SIF_Header/SIF_MsgId/"</span>).<span class="ruby-identifier">text</span>
44: <span class="ruby-keyword kw">end</span></pre>
|
136
|
-
</div>
|
137
|
-
</div>
|
138
|
-
<div class='public-instance method' id='method-M000037'>
|
139
|
-
<a name='M000037'> </a>
|
140
|
-
<div class='synopsis'>
|
141
|
-
<span class='name'>source_id</span>
|
142
|
-
<span class='arguments'>()</span>
|
143
|
-
</div>
|
144
|
-
<div class='description'>
|
145
|
-
<p>
|
146
|
-
The SIF_SourceId from the SIF_Header
|
147
|
-
</p>
|
148
|
-
</div>
|
149
|
-
<div class='source'>
|
150
|
-
<a class='source-toggle' href='#' onclick="toggleCode('M000037-source'); return false">
|
151
|
-
[show source]
|
152
|
-
</a>
|
153
|
-
<pre id='M000037-source'> <span class="ruby-comment cmt"># File lib/siffer/messages/request_body.rb, line 37</span>
37: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">source_id</span>
38: (<span class="ruby-ivar">@doc</span><span class="ruby-operator">/</span><span class="ruby-value str">"//SIF_Header/SIF_SourceId/"</span>).<span class="ruby-identifier">text</span>
39: <span class="ruby-keyword kw">end</span></pre>
|
154
|
-
</div>
|
155
|
-
</div>
|
156
|
-
<div class='public-instance method' id='method-M000036'>
|
157
|
-
<a name='M000036'> </a>
|
158
|
-
<div class='synopsis'>
|
159
|
-
<span class='name'>type</span>
|
160
|
-
<span class='arguments'>()</span>
|
161
|
-
</div>
|
162
|
-
<div class='description'>
|
163
|
-
<p>
|
164
|
-
Will return the name of the element found just inside the root or just
|
165
|
-
inside SIF_SystemControl if present.
|
166
|
-
</p>
|
167
|
-
</div>
|
168
|
-
<div class='source'>
|
169
|
-
<a class='source-toggle' href='#' onclick="toggleCode('M000036-source'); return false">
|
170
|
-
[show source]
|
171
|
-
</a>
|
172
|
-
<pre id='M000036-source'> <span class="ruby-comment cmt"># File lib/siffer/messages/request_body.rb, line 24</span>
24: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">type</span>
25: <span class="ruby-keyword kw">begin</span>
26: <span class="ruby-identifier">msg_type</span> = (<span class="ruby-ivar">@doc</span><span class="ruby-operator">/</span><span class="ruby-identifier">:SIF_Message</span>).<span class="ruby-identifier">first</span>.<span class="ruby-identifier">children</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">name</span>
27: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">msg_type</span> <span class="ruby-operator">==</span> <span class="ruby-value str">"SIF_SystemControl"</span>
28: <span class="ruby-identifier">msg_type</span> = (<span class="ruby-ivar">@doc</span><span class="ruby-operator">/</span><span class="ruby-identifier">:SIF_Message</span><span class="ruby-operator">/</span><span class="ruby-identifier">:SIF_SystemControl</span>).<span class="ruby-identifier">first</span>.<span class="ruby-identifier">children</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">name</span>
29: <span class="ruby-keyword kw">end</span>
30: <span class="ruby-identifier">drop_sif</span> <span class="ruby-identifier">msg_type</span>
31: <span class="ruby-keyword kw">rescue</span>
32: <span class="ruby-identifier">raise</span> <span class="ruby-node">"Failed to parse #{@xml} for SIF Type"</span>
33: <span class="ruby-keyword kw">end</span>
34: <span class="ruby-keyword kw">end</span></pre>
|
173
|
-
</div>
|
174
|
-
</div>
|
175
|
-
</div>
|
176
|
-
</div>
|
177
|
-
</div>
|
178
|
-
</div>
|
179
|
-
<div id='footer-push'></div>
|
180
|
-
</div>
|
181
|
-
<div id='footer'>
|
182
|
-
<a href="http://github.com/mislav/hanna/tree/master"><strong>Hanna</strong> RDoc template</a>
|
183
|
-
</div>
|
184
|
-
</body>
|
185
|
-
</html>
|
@@ -1,156 +0,0 @@
|
|
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>
|
40
|
-
</div>
|
41
|
-
</div>
|
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>
|
56
|
-
</div>
|
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 => "Success", 1 => "Immediate", 2 => "Intermediate", 3 => "Final", 7 => "Duplicate", 8 => "Sleeping", 9 => "No Messages" }</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>
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>)
29: <span class="ruby-identifier">data</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">first</span>
30: <span class="ruby-identifier">status</span> = <span class="ruby-keyword kw">nil</span>
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>
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>
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>)
34: <span class="ruby-keyword kw">end</span>
35: <span class="ruby-keyword kw">end</span>
36: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">status</span>
37: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">status</span>
38: <span class="ruby-keyword kw">else</span>
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>)
40: <span class="ruby-keyword kw">end</span>
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>
 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>)
 9: <span class="ruby-ivar">@code</span> = <span class="ruby-identifier">code</span>
10: <span class="ruby-ivar">@description</span> = <span class="ruby-constant">CODES</span>[<span class="ruby-identifier">code</span>]
11: <span class="ruby-ivar">@data</span> = <span class="ruby-identifier">data</span>
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>
14: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">read</span>
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>
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>
17: <span class="ruby-identifier">status</span>.<span class="ruby-constant">SIF_Code</span>(<span class="ruby-identifier">code</span>)
18: <span class="ruby-identifier">status</span>.<span class="ruby-constant">SIF_Description</span>(<span class="ruby-identifier">description</span>)
19: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">data</span>.<span class="ruby-identifier">nil?</span>
20: <span class="ruby-identifier">status</span>.<span class="ruby-constant">SIF_Data</span>
21: <span class="ruby-keyword kw">else</span>
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> }
23: <span class="ruby-keyword kw">end</span>
24: }
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>
|
147
|
-
</div>
|
148
|
-
</div>
|
149
|
-
</div>
|
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>
|
154
|
-
</div>
|
155
|
-
</body>
|
156
|
-
</html>
|
@@ -1,212 +0,0 @@
|
|
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>
|
37
|
-
</div>
|
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>
|
47
|
-
</div>
|
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>
|
57
|
-
</div>
|
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>
|
65
|
-
</div>
|
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'>{ "appxmlencoded" => "application/xml;charset=utf-8", "appxml" => "application/xml", "htm" => "text/html", "html" => "text/html", "xml" => "text/xml" }</td>
|
75
|
-
<td> </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’s either text/xml or
|
95
|
-
application/xml;charset=utf-8. If it isn’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>
49: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">check_content_type</span>
50: <span class="ruby-identifier">content_type</span> = <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">content_type</span>
51: <span class="ruby-keyword kw">unless</span> [<span class="ruby-constant">MIME_TYPES</span>[<span class="ruby-value str">"xml"</span>], 
52: <span class="ruby-constant">MIME_TYPES</span>[<span class="ruby-value str">"appxml"</span>], 
53: <span class="ruby-constant">MIME_TYPES</span>[<span class="ruby-value str">"appxmlencoded"</span>]].<span class="ruby-identifier">include?</span> <span class="ruby-identifier">content_type</span>
54: <span class="ruby-identifier">raise</span> <span class="ruby-constant">BadContentType</span>
55: <span class="ruby-keyword kw">end</span>
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>
25: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">request_failed_messaging?</span>
26: <span class="ruby-keyword kw">begin</span>
27: <span class="ruby-identifier">check_content_type</span>
28: <span class="ruby-identifier">validate_message</span>
29: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">BadContentType</span>
30: <span class="ruby-comment cmt"># Make a better Not Acceptable response</span>
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>],
32: <span class="ruby-value">406</span>,
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>]})
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">"There was no XML body to parse."</span>);
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">"The XML was not a recognizable SIF Message."</span>);
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">"The SIF version did not match supported versions."</span>);
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>)
38: <span class="ruby-keyword kw">end</span>
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>
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>)
43: <span class="ruby-keyword kw">yield</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
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
|
-
“validate” 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>
71: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">validate_message</span>
72: <span class="ruby-keyword kw">begin</span>
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>
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>)
75: <span class="ruby-comment cmt"># validate Message Root</span>
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>
77: <span class="ruby-comment cmt"># validate Message Root is a SIF_Message</span>
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">"SIF_Message"</span>
79: <span class="ruby-comment cmt"># validate SIF version</span>
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">"version"</span>] <span class="ruby-operator">!=</span> <span class="ruby-constant">Siffer</span>.<span class="ruby-identifier">sif_version</span>
81: <span class="ruby-comment cmt"># validate SIF xmlns</span>
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">"xmlns"</span>] <span class="ruby-operator">!=</span> <span class="ruby-constant">Siffer</span>.<span class="ruby-identifier">sif_xmlns</span>
83: <span class="ruby-comment cmt"># any others?</span>
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>
85: <span class="ruby-identifier">raise</span> <span class="ruby-constant">MalformedXml</span>
86: <span class="ruby-keyword kw">end</span>
87: <span class="ruby-keyword kw">end</span></pre>
|
200
|
-
</div>
|
201
|
-
</div>
|
202
|
-
</div>
|
203
|
-
</div>
|
204
|
-
</div>
|
205
|
-
</div>
|
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>
|
210
|
-
</div>
|
211
|
-
</body>
|
212
|
-
</html>
|