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.
Files changed (91) hide show
  1. data/LICENSE +20 -0
  2. data/README.rdoc +65 -0
  3. data/Rakefile +64 -0
  4. data/bin/siffer +71 -0
  5. data/doc/SIF ImplementationSpecification.pdf +0 -0
  6. data/doc/rdoc/classes/Siffer.html +374 -0
  7. data/doc/rdoc/classes/Siffer/Agent.html +296 -0
  8. data/doc/rdoc/classes/Siffer/Container.html +286 -0
  9. data/doc/rdoc/classes/Siffer/Messages.html +141 -0
  10. data/doc/rdoc/classes/Siffer/Messages/Ack.html +216 -0
  11. data/doc/rdoc/classes/Siffer/Messages/Acl.html +160 -0
  12. data/doc/rdoc/classes/Siffer/Messages/Error.html +248 -0
  13. data/doc/rdoc/classes/Siffer/Messages/Message.html +359 -0
  14. data/doc/rdoc/classes/Siffer/Messages/Message/Header.html +181 -0
  15. data/doc/rdoc/classes/Siffer/Messages/Register.html +257 -0
  16. data/doc/rdoc/classes/Siffer/Messages/RequestBody.html +300 -0
  17. data/doc/rdoc/classes/Siffer/Messages/Status.html +269 -0
  18. data/doc/rdoc/classes/Siffer/Messaging.html +331 -0
  19. data/doc/rdoc/classes/Siffer/Protocol.html +388 -0
  20. data/doc/rdoc/classes/Siffer/Protocol/NonPostRequest.html +111 -0
  21. data/doc/rdoc/classes/Siffer/Protocol/UnknownPath.html +111 -0
  22. data/doc/rdoc/classes/Siffer/Registration.html +391 -0
  23. data/doc/rdoc/classes/Siffer/Request.html +209 -0
  24. data/doc/rdoc/classes/Siffer/RequestLogger.html +211 -0
  25. data/doc/rdoc/classes/Siffer/Response.html +182 -0
  26. data/doc/rdoc/classes/Siffer/Server.html +242 -0
  27. data/doc/rdoc/created.rid +1 -0
  28. data/doc/rdoc/files/LICENSE.html +129 -0
  29. data/doc/rdoc/files/README_rdoc.html +184 -0
  30. data/doc/rdoc/files/lib/agent_rb.html +101 -0
  31. data/doc/rdoc/files/lib/container_rb.html +108 -0
  32. data/doc/rdoc/files/lib/messages/ack_rb.html +101 -0
  33. data/doc/rdoc/files/lib/messages/acl_rb.html +101 -0
  34. data/doc/rdoc/files/lib/messages/error_rb.html +101 -0
  35. data/doc/rdoc/files/lib/messages/message_rb.html +101 -0
  36. data/doc/rdoc/files/lib/messages/register_rb.html +101 -0
  37. data/doc/rdoc/files/lib/messages/request_body_rb.html +101 -0
  38. data/doc/rdoc/files/lib/messages/status_rb.html +101 -0
  39. data/doc/rdoc/files/lib/messages_rb.html +114 -0
  40. data/doc/rdoc/files/lib/messaging_rb.html +101 -0
  41. data/doc/rdoc/files/lib/protocol_rb.html +101 -0
  42. data/doc/rdoc/files/lib/registration_rb.html +101 -0
  43. data/doc/rdoc/files/lib/request_logger_rb.html +101 -0
  44. data/doc/rdoc/files/lib/request_rb.html +101 -0
  45. data/doc/rdoc/files/lib/response_rb.html +101 -0
  46. data/doc/rdoc/files/lib/server_rb.html +101 -0
  47. data/doc/rdoc/files/lib/siffer_rb.html +115 -0
  48. data/doc/rdoc/fr_class_index.html +47 -0
  49. data/doc/rdoc/fr_file_index.html +46 -0
  50. data/doc/rdoc/fr_method_index.html +96 -0
  51. data/doc/rdoc/index.html +24 -0
  52. data/doc/rdoc/rdoc-style.css +208 -0
  53. data/lib/agent.rb +43 -0
  54. data/lib/container.rb +96 -0
  55. data/lib/messages.rb +7 -0
  56. data/lib/messages/ack.rb +43 -0
  57. data/lib/messages/acl.rb +25 -0
  58. data/lib/messages/error.rb +174 -0
  59. data/lib/messages/message.rb +71 -0
  60. data/lib/messages/register.rb +60 -0
  61. data/lib/messages/request_body.rb +66 -0
  62. data/lib/messages/status.rb +55 -0
  63. data/lib/messaging.rb +96 -0
  64. data/lib/protocol.rb +159 -0
  65. data/lib/registration.rb +87 -0
  66. data/lib/request.rb +25 -0
  67. data/lib/request_logger.rb +31 -0
  68. data/lib/response.rb +26 -0
  69. data/lib/server.rb +40 -0
  70. data/lib/siffer.rb +44 -0
  71. data/spec/agent_spec.rb +53 -0
  72. data/spec/cli_spec.rb +40 -0
  73. data/spec/container_spec.rb +103 -0
  74. data/spec/default_agent +6 -0
  75. data/spec/default_server +5 -0
  76. data/spec/message_specs/ack_spec.rb +28 -0
  77. data/spec/message_specs/error_spec.rb +24 -0
  78. data/spec/message_specs/header_spec.rb +25 -0
  79. data/spec/message_specs/message_spec.rb +57 -0
  80. data/spec/message_specs/register_spec.rb +86 -0
  81. data/spec/message_specs/request_body_spec.rb +58 -0
  82. data/spec/message_specs/status_spec.rb +25 -0
  83. data/spec/messaging_spec.rb +88 -0
  84. data/spec/protocol_spec.rb +49 -0
  85. data/spec/registration_spec.rb +33 -0
  86. data/spec/request_logger_spec.rb +15 -0
  87. data/spec/request_spec.rb +10 -0
  88. data/spec/response_spec.rb +24 -0
  89. data/spec/server_spec.rb +35 -0
  90. data/spec/spec_helper.rb +26 -0
  91. metadata +191 -0
@@ -0,0 +1,209 @@
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::Request</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::Request</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../../files/lib/request_rb.html">
59
+ lib/request.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
+ Rack::Request
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
+ <div id="description">
82
+ <p>
83
+ <a href="Request.html">Request</a> represents each <a
84
+ href="Request.html#M000069">message</a> received by the <a
85
+ href="Server.html">Server</a> or <a href="Agent.html">Agent</a> in <a
86
+ href="../Siffer.html">Siffer</a>.
87
+ </p>
88
+
89
+ </div>
90
+
91
+
92
+ </div>
93
+
94
+ <div id="method-list">
95
+ <h3 class="section-bar">Methods</h3>
96
+
97
+ <div class="name-list">
98
+ <a href="#M000069">message</a>&nbsp;&nbsp;
99
+ <a href="#M000068">new</a>&nbsp;&nbsp;
100
+ <a href="#M000070">original</a>&nbsp;&nbsp;
101
+ </div>
102
+ </div>
103
+
104
+ </div>
105
+
106
+
107
+ <!-- if includes -->
108
+
109
+ <div id="section">
110
+
111
+
112
+
113
+
114
+
115
+
116
+
117
+
118
+ <!-- if method_list -->
119
+ <div id="methods">
120
+ <h3 class="section-bar">Public Class methods</h3>
121
+
122
+ <div id="method-M000068" class="method-detail">
123
+ <a name="M000068"></a>
124
+
125
+ <div class="method-heading">
126
+ <a href="#M000068" class="method-signature">
127
+ <span class="method-name">new</span><span class="method-args">(env)</span>
128
+ </a>
129
+ </div>
130
+
131
+ <div class="method-description">
132
+ <p>
133
+ Constructor will assure that <a href="Request.html#M000069">message</a> is
134
+ always populated with the body of the request for easy access throughout
135
+ the call.
136
+ </p>
137
+ <p><a class="source-toggle" href="#"
138
+ onclick="toggleCode('M000068-source');return false;">[Source]</a></p>
139
+ <div class="method-source-code" id="M000068-source">
140
+ <pre>
141
+ <span class="ruby-comment cmt"># File lib/request.rb, line 8</span>
142
+ 8: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">env</span>)
143
+ 9: <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;CONTENT_TYPE&quot;</span>] <span class="ruby-operator">||=</span> <span class="ruby-constant">Siffer</span><span class="ruby-operator">::</span><span class="ruby-constant">Messaging</span><span class="ruby-operator">::</span><span class="ruby-constant">MIME_TYPES</span>[<span class="ruby-value str">&quot;appxml&quot;</span>]
144
+ 10: <span class="ruby-keyword kw">super</span>(<span class="ruby-identifier">env</span>)
145
+ 11: <span class="ruby-keyword kw">end</span>
146
+ </pre>
147
+ </div>
148
+ </div>
149
+ </div>
150
+
151
+ <h3 class="section-bar">Public Instance methods</h3>
152
+
153
+ <div id="method-M000069" class="method-detail">
154
+ <a name="M000069"></a>
155
+
156
+ <div class="method-heading">
157
+ <a href="#M000069" class="method-signature">
158
+ <span class="method-name">message</span><span class="method-args">()</span>
159
+ </a>
160
+ </div>
161
+
162
+ <div class="method-description">
163
+ <p>
164
+ Provides access to the request <a href="Request.html#M000069">message</a>
165
+ in <a href="Messages/Message.html">Siffer::Messages::Message</a> format.
166
+ </p>
167
+ <p><a class="source-toggle" href="#"
168
+ onclick="toggleCode('M000069-source');return false;">[Source]</a></p>
169
+ <div class="method-source-code" id="M000069-source">
170
+ <pre>
171
+ <span class="ruby-comment cmt"># File lib/request.rb, line 15</span>
172
+ 15: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">message</span>
173
+ 16: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">body</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">StringIO</span>) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">body</span>.<span class="ruby-identifier">pos</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">body</span>.<span class="ruby-identifier">length</span>
174
+ 17: <span class="ruby-identifier">body</span>.<span class="ruby-identifier">rewind</span>
175
+ 18: <span class="ruby-keyword kw">end</span>
176
+ 19: <span class="ruby-constant">Siffer</span><span class="ruby-operator">::</span><span class="ruby-constant">Messages</span><span class="ruby-operator">::</span><span class="ruby-constant">RequestBody</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">body</span>)
177
+ 20: <span class="ruby-keyword kw">end</span>
178
+ </pre>
179
+ </div>
180
+ </div>
181
+ </div>
182
+
183
+ <div id="method-M000070" class="method-detail">
184
+ <a name="M000070"></a>
185
+
186
+ <div class="method-heading">
187
+ <span class="method-name">original</span><span class="method-args">()</span>
188
+ </div>
189
+
190
+ <div class="method-description">
191
+ <p>
192
+ Alias for <a href="Request.html#M000069">message</a>
193
+ </p>
194
+ </div>
195
+ </div>
196
+
197
+
198
+ </div>
199
+
200
+
201
+ </div>
202
+
203
+
204
+ <div id="validator-badges">
205
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
206
+ </div>
207
+
208
+ </body>
209
+ </html>
@@ -0,0 +1,211 @@
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::RequestLogger</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::RequestLogger</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../../files/lib/request_logger_rb.html">
59
+ lib/request_logger.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="#M000057">call</a>&nbsp;&nbsp;
90
+ <a href="#M000058">log_request</a>&nbsp;&nbsp;
91
+ <a href="#M000056">new</a>&nbsp;&nbsp;
92
+ </div>
93
+ </div>
94
+
95
+ </div>
96
+
97
+
98
+ <!-- if includes -->
99
+
100
+ <div id="section">
101
+
102
+
103
+
104
+
105
+
106
+
107
+
108
+
109
+ <!-- if method_list -->
110
+ <div id="methods">
111
+ <h3 class="section-bar">Public Class methods</h3>
112
+
113
+ <div id="method-M000056" class="method-detail">
114
+ <a name="M000056"></a>
115
+
116
+ <div class="method-heading">
117
+ <a href="#M000056" class="method-signature">
118
+ <span class="method-name">new</span><span class="method-args">(app, log=nil)</span>
119
+ </a>
120
+ </div>
121
+
122
+ <div class="method-description">
123
+ <p><a class="source-toggle" href="#"
124
+ onclick="toggleCode('M000056-source');return false;">[Source]</a></p>
125
+ <div class="method-source-code" id="M000056-source">
126
+ <pre>
127
+ <span class="ruby-comment cmt"># File lib/request_logger.rb, line 3</span>
128
+ 3: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">app</span>, <span class="ruby-identifier">log</span>=<span class="ruby-keyword kw">nil</span>)
129
+ 4: <span class="ruby-ivar">@app</span> = <span class="ruby-identifier">app</span>
130
+ 5: <span class="ruby-ivar">@log</span> = <span class="ruby-identifier">log</span> <span class="ruby-operator">||</span> <span class="ruby-constant">STDERR</span>
131
+ 6: <span class="ruby-keyword kw">end</span>
132
+ </pre>
133
+ </div>
134
+ </div>
135
+ </div>
136
+
137
+ <h3 class="section-bar">Public Instance methods</h3>
138
+
139
+ <div id="method-M000057" class="method-detail">
140
+ <a name="M000057"></a>
141
+
142
+ <div class="method-heading">
143
+ <a href="#M000057" class="method-signature">
144
+ <span class="method-name">call</span><span class="method-args">(env)</span>
145
+ </a>
146
+ </div>
147
+
148
+ <div class="method-description">
149
+ <p><a class="source-toggle" href="#"
150
+ onclick="toggleCode('M000057-source');return false;">[Source]</a></p>
151
+ <div class="method-source-code" id="M000057-source">
152
+ <pre>
153
+ <span class="ruby-comment cmt"># File lib/request_logger.rb, line 8</span>
154
+ 8: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>)
155
+ 9: <span class="ruby-ivar">@env</span> = <span class="ruby-identifier">env</span>
156
+ 10: <span class="ruby-comment cmt"># Maybe there is a better way to pick the body of the input</span>
157
+ 11: <span class="ruby-comment cmt"># instead of reading it then stuffing it back in ??</span>
158
+ 12: <span class="ruby-ivar">@msg</span> = <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;rack.input&quot;</span>].<span class="ruby-identifier">read</span>
159
+ 13: <span class="ruby-identifier">log_request</span>
160
+ 14: <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;rack.input&quot;</span>] = <span class="ruby-constant">StringIO</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@msg</span>)
161
+ 15: <span class="ruby-ivar">@app</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>)
162
+ 16: <span class="ruby-keyword kw">end</span>
163
+ </pre>
164
+ </div>
165
+ </div>
166
+ </div>
167
+
168
+ <div id="method-M000058" class="method-detail">
169
+ <a name="M000058"></a>
170
+
171
+ <div class="method-heading">
172
+ <a href="#M000058" class="method-signature">
173
+ <span class="method-name">log_request</span><span class="method-args">()</span>
174
+ </a>
175
+ </div>
176
+
177
+ <div class="method-description">
178
+ <p><a class="source-toggle" href="#"
179
+ onclick="toggleCode('M000058-source');return false;">[Source]</a></p>
180
+ <div class="method-source-code" id="M000058-source">
181
+ <pre>
182
+ <span class="ruby-comment cmt"># File lib/request_logger.rb, line 18</span>
183
+ 18: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">log_request</span>
184
+ 19: <span class="ruby-ivar">@now</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>
185
+ 20: <span class="ruby-identifier">message</span> = <span class="ruby-constant">Siffer</span><span class="ruby-operator">::</span><span class="ruby-constant">Messages</span><span class="ruby-operator">::</span><span class="ruby-constant">RequestBody</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-ivar">@msg</span>)
186
+ 21: <span class="ruby-ivar">@log</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">%{%s request made by %s on %s at %s\n}</span> <span class="ruby-operator">%</span>
187
+ 22: [
188
+ 23: <span class="ruby-identifier">message</span>.<span class="ruby-identifier">type</span>,
189
+ 24: <span class="ruby-ivar">@env</span>[<span class="ruby-value str">&quot;REMOTE_USER&quot;</span>],
190
+ 25: <span class="ruby-ivar">@now</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-value str">&quot;%b/%d/%Y&quot;</span>),
191
+ 26: <span class="ruby-ivar">@now</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-value str">&quot;%H:%M:%S&quot;</span>)
192
+ 27: ]
193
+ 28: <span class="ruby-keyword kw">end</span>
194
+ </pre>
195
+ </div>
196
+ </div>
197
+ </div>
198
+
199
+
200
+ </div>
201
+
202
+
203
+ </div>
204
+
205
+
206
+ <div id="validator-badges">
207
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
208
+ </div>
209
+
210
+ </body>
211
+ </html>
@@ -0,0 +1,182 @@
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::Response</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::Response</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../../files/lib/response_rb.html">
59
+ lib/response.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
+ Rack::Response
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="#M000060">from</a>&nbsp;&nbsp;
90
+ <a href="#M000059">new</a>&nbsp;&nbsp;
91
+ </div>
92
+ </div>
93
+
94
+ </div>
95
+
96
+
97
+ <!-- if includes -->
98
+
99
+ <div id="section">
100
+
101
+
102
+
103
+
104
+
105
+
106
+
107
+
108
+ <!-- if method_list -->
109
+ <div id="methods">
110
+ <h3 class="section-bar">Public Class methods</h3>
111
+
112
+ <div id="method-M000060" class="method-detail">
113
+ <a name="M000060"></a>
114
+
115
+ <div class="method-heading">
116
+ <a href="#M000060" class="method-signature">
117
+ <span class="method-name">from</span><span class="method-args">(url,data)</span>
118
+ </a>
119
+ </div>
120
+
121
+ <div class="method-description">
122
+ <p><a class="source-toggle" href="#"
123
+ onclick="toggleCode('M000060-source');return false;">[Source]</a></p>
124
+ <div class="method-source-code" id="M000060-source">
125
+ <pre>
126
+ <span class="ruby-comment cmt"># File lib/response.rb, line 10</span>
127
+ 10: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">from</span>(<span class="ruby-identifier">url</span>,<span class="ruby-identifier">data</span>)
128
+ 11: <span class="ruby-identifier">uri</span> = <span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">url</span>)
129
+ 12: <span class="ruby-keyword kw">begin</span>
130
+ 13: <span class="ruby-identifier">response</span> = <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span>.<span class="ruby-identifier">start</span>(<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">host</span>,<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">port</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">http</span><span class="ruby-operator">|</span>
131
+ 14: <span class="ruby-identifier">post</span> = <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span><span class="ruby-operator">::</span><span class="ruby-constant">Post</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">path</span>, {})
132
+ 15: <span class="ruby-identifier">post</span>.<span class="ruby-identifier">body</span> = (<span class="ruby-identifier">data</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value str">&quot;read&quot;</span>)) <span class="ruby-operator">?</span> <span class="ruby-identifier">data</span>.<span class="ruby-identifier">read</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">data</span>
133
+ 16: <span class="ruby-identifier">post</span>.<span class="ruby-identifier">content_type</span> = <span class="ruby-constant">Siffer</span><span class="ruby-operator">::</span><span class="ruby-constant">Messaging</span><span class="ruby-operator">::</span><span class="ruby-constant">MIME_TYPES</span>[<span class="ruby-value str">&quot;appxml&quot;</span>]
134
+ 17: <span class="ruby-identifier">http</span>.<span class="ruby-identifier">request</span>(<span class="ruby-identifier">post</span>)
135
+ 18: }
136
+ 19: <span class="ruby-constant">Response</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">response</span>.<span class="ruby-identifier">body</span>,<span class="ruby-identifier">response</span>.<span class="ruby-identifier">code</span>.<span class="ruby-identifier">to_i</span>,<span class="ruby-identifier">response</span>.<span class="ruby-identifier">header</span>.<span class="ruby-identifier">to_hash</span>)
137
+ 20: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">ECONNREFUSED</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
138
+ 21: <span class="ruby-constant">Response</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">e</span>.<span class="ruby-identifier">message</span>, <span class="ruby-value">500</span>, {})
139
+ 22: <span class="ruby-keyword kw">end</span>
140
+ 23: <span class="ruby-keyword kw">end</span>
141
+ </pre>
142
+ </div>
143
+ </div>
144
+ </div>
145
+
146
+ <div id="method-M000059" class="method-detail">
147
+ <a name="M000059"></a>
148
+
149
+ <div class="method-heading">
150
+ <a href="#M000059" class="method-signature">
151
+ <span class="method-name">new</span><span class="method-args">(body=[], status=200, header={}, &amp;block)</span>
152
+ </a>
153
+ </div>
154
+
155
+ <div class="method-description">
156
+ <p><a class="source-toggle" href="#"
157
+ onclick="toggleCode('M000059-source');return false;">[Source]</a></p>
158
+ <div class="method-source-code" id="M000059-source">
159
+ <pre>
160
+ <span class="ruby-comment cmt"># File lib/response.rb, line 5</span>
161
+ 5: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">body</span>=[], <span class="ruby-identifier">status</span>=<span class="ruby-value">200</span>, <span class="ruby-identifier">header</span>={}, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
162
+ 6: <span class="ruby-identifier">header</span>[<span class="ruby-value str">&quot;Content-Type&quot;</span>] <span class="ruby-operator">||=</span> <span class="ruby-constant">Siffer</span><span class="ruby-operator">::</span><span class="ruby-constant">Messaging</span><span class="ruby-operator">::</span><span class="ruby-constant">MIME_TYPES</span>[<span class="ruby-value str">&quot;appxml&quot;</span>]
163
+ 7: <span class="ruby-keyword kw">super</span>(<span class="ruby-identifier">body</span>,<span class="ruby-identifier">status</span>,<span class="ruby-identifier">header</span>,<span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
164
+ 8: <span class="ruby-keyword kw">end</span>
165
+ </pre>
166
+ </div>
167
+ </div>
168
+ </div>
169
+
170
+
171
+ </div>
172
+
173
+
174
+ </div>
175
+
176
+
177
+ <div id="validator-badges">
178
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
179
+ </div>
180
+
181
+ </body>
182
+ </html>