Capcode 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,125 @@
1
+
2
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
3
+ <html>
4
+ <head>
5
+ <title>
6
+ Capcode, the Documentation &raquo; Class: Capcode::HTTPError
7
+ </title>
8
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
9
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
10
+ <script language="JavaScript" type="text/javascript">
11
+ // <![CDATA[
12
+
13
+ function toggleSource( id )
14
+ {
15
+ var elem
16
+ var link
17
+
18
+ if( document.getElementById )
19
+ {
20
+ elem = document.getElementById( id )
21
+ link = document.getElementById( "l_" + id )
22
+ }
23
+ else if ( document.all )
24
+ {
25
+ elem = eval( "document.all." + id )
26
+ link = eval( "document.all.l_" + id )
27
+ }
28
+ else
29
+ return false;
30
+
31
+ if( elem.style.display == "block" )
32
+ {
33
+ elem.style.display = "none"
34
+ link.innerHTML = "show source"
35
+ }
36
+ else
37
+ {
38
+ elem.style.display = "block"
39
+ link.innerHTML = "hide source"
40
+ }
41
+ }
42
+
43
+ function openCode( url )
44
+ {
45
+ window.open( url, "SOURCE_CODE", "width=400,height=400,scrollbars=yes" )
46
+ }
47
+ // ]]>
48
+ </script>
49
+ </head>
50
+ <body>
51
+ <!--
52
+ <div id="menu">
53
+ <h3 class="title">Class: Capcode::HTTPError</h3>
54
+ </div>
55
+ -->
56
+ <div id="fullpage">
57
+ <div id="pager">
58
+ <table>
59
+ <tr><td><img src="../../rubyfr.png" /></td>
60
+ <td id="pagertd">
61
+ <strong># Class: Capcode::HTTPError<br />
62
+ [
63
+ "<a href="../../files/README.html" value="File: README">README</a>",
64
+ "<a href="../../files/AUTHORS.html" value="File: AUTHORS">AUTHORS</a>",
65
+ "<a href="../../files/COPYING.html" value="File: COPYING">COPYING</a>",
66
+ "<a href="../../files/lib/capcode_rb.html" value="File: capcode.rb">lib/capcode.rb</a>",
67
+ <a href="http://greg.rubyfr.net">nil</a>].each do<br />
68
+ <a href="../../classes/Capcode.html" title="Module: Capcode">Capcode</a>.view_html<br />
69
+ <a href="../../classes/Capcode/Helpers.html" title="Module: Capcode::Helpers">Capcode::Helpers</a>.view_html<br />
70
+ <a href="../../classes/Capcode/HTTPError.html" title="Class: Capcode::HTTPError">Capcode::HTTPError</a>.view_html<br />
71
+ <a href="../../classes/Capcode/ParameterError.html" title="Class: Capcode::ParameterError">Capcode::ParameterError</a>.view_html<br />
72
+ end</strong>
73
+ </td></tr>
74
+ </table>
75
+ </ul>
76
+ </div>
77
+
78
+
79
+ <div id="Capcode::HTTPError" class="page_shade">
80
+ <div class="page">
81
+ <h3>Class Capcode::HTTPError &lt; Object</h3>
82
+
83
+ (in files
84
+ <a href="../../files/lib/capcode_rb.html">lib/capcode.rb</a>
85
+ )
86
+
87
+ <p>
88
+ <a href="HTTPError.html">HTTPError</a> help you to create your own 404, 500
89
+ and/or 501 response
90
+ </p>
91
+ <p>
92
+ To create a custom 404 reponse, create a fonction HTTPError.r404 in your
93
+ application :
94
+ </p>
95
+ <pre>
96
+ module Capcode
97
+ class HTTPError
98
+ def r404(f)
99
+ &quot;#{f} not found :(&quot;
100
+ end
101
+ end
102
+ end
103
+ </pre>
104
+ <p>
105
+ Do the same (r500 and r501) to customize 500 and 501 errors
106
+ </p>
107
+
108
+
109
+
110
+
111
+ <h4>Includes</h4>
112
+ <ul>
113
+ <li>Rack</li>
114
+ <li><a href="Capcode/Helpers.html">Capcode::Helpers</a></li>
115
+ </ul>
116
+
117
+
118
+
119
+ </div>
120
+ </div>
121
+
122
+
123
+ </div>
124
+ </body>
125
+ </html>
@@ -0,0 +1,214 @@
1
+
2
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
3
+ <html>
4
+ <head>
5
+ <title>
6
+ Capcode, the Documentation &raquo; Module: Capcode::Helpers
7
+ </title>
8
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
9
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
10
+ <script language="JavaScript" type="text/javascript">
11
+ // <![CDATA[
12
+
13
+ function toggleSource( id )
14
+ {
15
+ var elem
16
+ var link
17
+
18
+ if( document.getElementById )
19
+ {
20
+ elem = document.getElementById( id )
21
+ link = document.getElementById( "l_" + id )
22
+ }
23
+ else if ( document.all )
24
+ {
25
+ elem = eval( "document.all." + id )
26
+ link = eval( "document.all.l_" + id )
27
+ }
28
+ else
29
+ return false;
30
+
31
+ if( elem.style.display == "block" )
32
+ {
33
+ elem.style.display = "none"
34
+ link.innerHTML = "show source"
35
+ }
36
+ else
37
+ {
38
+ elem.style.display = "block"
39
+ link.innerHTML = "hide source"
40
+ }
41
+ }
42
+
43
+ function openCode( url )
44
+ {
45
+ window.open( url, "SOURCE_CODE", "width=400,height=400,scrollbars=yes" )
46
+ }
47
+ // ]]>
48
+ </script>
49
+ </head>
50
+ <body>
51
+ <!--
52
+ <div id="menu">
53
+ <h3 class="title">Module: Capcode::Helpers</h3>
54
+ </div>
55
+ -->
56
+ <div id="fullpage">
57
+ <div id="pager">
58
+ <table>
59
+ <tr><td><img src="../../rubyfr.png" /></td>
60
+ <td id="pagertd">
61
+ <strong># Module: Capcode::Helpers<br />
62
+ [
63
+ "<a href="../../files/README.html" value="File: README">README</a>",
64
+ "<a href="../../files/AUTHORS.html" value="File: AUTHORS">AUTHORS</a>",
65
+ "<a href="../../files/COPYING.html" value="File: COPYING">COPYING</a>",
66
+ "<a href="../../files/lib/capcode_rb.html" value="File: capcode.rb">lib/capcode.rb</a>",
67
+ <a href="http://greg.rubyfr.net">nil</a>].each do<br />
68
+ <a href="../../classes/Capcode.html" title="Module: Capcode">Capcode</a>.view_html<br />
69
+ <a href="../../classes/Capcode/Helpers.html" title="Module: Capcode::Helpers">Capcode::Helpers</a>.view_html<br />
70
+ <a href="../../classes/Capcode/HTTPError.html" title="Class: Capcode::HTTPError">Capcode::HTTPError</a>.view_html<br />
71
+ <a href="../../classes/Capcode/ParameterError.html" title="Class: Capcode::ParameterError">Capcode::ParameterError</a>.view_html<br />
72
+ end</strong>
73
+ </td></tr>
74
+ </table>
75
+ </ul>
76
+ </div>
77
+
78
+
79
+ <div id="Capcode::Helpers" class="page_shade">
80
+ <div class="page">
81
+ <h3>Module Capcode::Helpers</h3>
82
+
83
+ (in files
84
+ <a href="../../files/lib/capcode_rb.html">lib/capcode.rb</a>
85
+ )
86
+
87
+ <p>
88
+ <a href="Helpers.html">Helpers</a> contains methods available in your
89
+ controllers
90
+ </p>
91
+
92
+
93
+
94
+
95
+ <h4>Includes</h4>
96
+ <ul>
97
+ <li>Rack</li>
98
+ <li><a href="Capcode/Helpers.html">Capcode::Helpers</a></li>
99
+ </ul>
100
+
101
+ <h2 class="ruled">Methods</h2>
102
+ <h4 class="ruled">Public Instance method:
103
+ <strong><a name="M000011">URL( klass, *a )</a></strong> <a href="#M000011"><img src="../../permalink.gif" border="0" title="Permalink to Public Instance method: URL" /></a></h4>
104
+
105
+ <p>
106
+ Builds an <a href="Helpers.html#M000011">URL</a> route to a controller or a
107
+ path
108
+ </p>
109
+ <p>
110
+ if you declare the controller Hello :
111
+ </p>
112
+ <pre>
113
+ module Capcode
114
+ class Hello &lt; Route '/hello/(.*)'
115
+ ...
116
+ end
117
+ end
118
+ </pre>
119
+ <p>
120
+ then
121
+ </p>
122
+ <pre>
123
+ URL( Hello, &quot;you&quot; ) # =&gt; /hello/you
124
+ </pre>
125
+
126
+ <div class="sourcecode">
127
+ <p class="source-link">[ <a href="javascript:toggleSource('M000011_source')" id="l_M000011_source">show source</a> ]</p>
128
+ <div id="M000011_source" class="dyn-source">
129
+ <pre>
130
+ <span class="ruby-comment cmt"># File lib/capcode.rb, line 60</span>
131
+ 60: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">URL</span>( <span class="ruby-identifier">klass</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">a</span> )
132
+ 61: <span class="ruby-identifier">path</span> = <span class="ruby-keyword kw">nil</span>
133
+ 62: <span class="ruby-identifier">a</span> = <span class="ruby-identifier">a</span>.<span class="ruby-identifier">delete_if</span>{ <span class="ruby-operator">|</span><span class="ruby-identifier">x</span><span class="ruby-operator">|</span> <span class="ruby-identifier">x</span>.<span class="ruby-identifier">nil?</span> }
134
+ 63:
135
+ 64: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Class</span>
136
+ 65: <span class="ruby-constant">Capcode</span>.<span class="ruby-identifier">routes</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">p</span>, <span class="ruby-identifier">k</span><span class="ruby-operator">|</span>
137
+ 66: <span class="ruby-identifier">path</span> = <span class="ruby-identifier">p</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">k</span>.<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">klass</span>
138
+ 67: <span class="ruby-keyword kw">end</span>
139
+ 68: <span class="ruby-keyword kw">else</span>
140
+ 69: <span class="ruby-identifier">path</span> = <span class="ruby-identifier">klass</span>
141
+ 70: <span class="ruby-keyword kw">end</span>
142
+ 71:
143
+ 72: <span class="ruby-identifier">path</span><span class="ruby-operator">+</span>((<span class="ruby-identifier">a</span>.<span class="ruby-identifier">size</span><span class="ruby-operator">&gt;</span><span class="ruby-value">0</span>)<span class="ruby-operator">?</span>(<span class="ruby-value str">&quot;/&quot;</span><span class="ruby-operator">+</span><span class="ruby-identifier">a</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">&quot;/&quot;</span>))<span class="ruby-operator">:</span>(<span class="ruby-value str">&quot;&quot;</span>))
144
+ 73: <span class="ruby-keyword kw">end</span>
145
+ </pre>
146
+ </div>
147
+ </div>
148
+ <h4 class="ruled">Public Instance method:
149
+ <strong><a name="M000009">json( d )</a></strong> <a href="#M000009"><img src="../../permalink.gif" border="0" title="Permalink to Public Instance method: json" /></a></h4>
150
+
151
+ <p>
152
+ Help you to return a JSON response
153
+ </p>
154
+ <pre>
155
+ module Capcode
156
+ class JsonResponse &lt; Route '/json/([^\/]*)/(.*)'
157
+ def get( arg1, arg2 )
158
+ json( { :1 =&gt; arg1, :2 =&gt; arg2 })
159
+ end
160
+ end
161
+ end
162
+ </pre>
163
+
164
+ <div class="sourcecode">
165
+ <p class="source-link">[ <a href="javascript:toggleSource('M000009_source')" id="l_M000009_source">show source</a> ]</p>
166
+ <div id="M000009_source" class="dyn-source">
167
+ <pre>
168
+ <span class="ruby-comment cmt"># File lib/capcode.rb, line 25</span>
169
+ 25: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">json</span>( <span class="ruby-identifier">d</span> )
170
+ 26: <span class="ruby-ivar">@response</span>[<span class="ruby-value str">'Content-Type'</span>] = <span class="ruby-value str">'application/json'</span>
171
+ 27: <span class="ruby-identifier">d</span>.<span class="ruby-identifier">to_json</span>
172
+ 28: <span class="ruby-keyword kw">end</span>
173
+ </pre>
174
+ </div>
175
+ </div>
176
+ <h4 class="ruled">Public Instance method:
177
+ <strong><a name="M000010">redirect( klass, *a )</a></strong> <a href="#M000010"><img src="../../permalink.gif" border="0" title="Permalink to Public Instance method: redirect" /></a></h4>
178
+
179
+ <p>
180
+ Send a <a href="Helpers.html#M000010">redirect</a> response
181
+ </p>
182
+ <pre>
183
+ module Capcode
184
+ class Hello &lt; Route '/hello/(.*)'
185
+ def get( you )
186
+ if you.nil?
187
+ redirect( WhoAreYou )
188
+ else
189
+ ...
190
+ end
191
+ end
192
+ end
193
+ end
194
+ </pre>
195
+
196
+ <div class="sourcecode">
197
+ <p class="source-link">[ <a href="javascript:toggleSource('M000010_source')" id="l_M000010_source">show source</a> ]</p>
198
+ <div id="M000010_source" class="dyn-source">
199
+ <pre>
200
+ <span class="ruby-comment cmt"># File lib/capcode.rb, line 43</span>
201
+ 43: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">redirect</span>( <span class="ruby-identifier">klass</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">a</span> )
202
+ 44: [<span class="ruby-value">302</span>, {<span class="ruby-value str">'Location'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">URL</span>(<span class="ruby-identifier">klass</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">a</span>)}, <span class="ruby-value str">''</span>]
203
+ 45: <span class="ruby-keyword kw">end</span>
204
+ </pre>
205
+ </div>
206
+ </div>
207
+
208
+ </div>
209
+ </div>
210
+
211
+
212
+ </div>
213
+ </body>
214
+ </html>
@@ -0,0 +1,125 @@
1
+
2
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
3
+ <html>
4
+ <head>
5
+ <title>
6
+ Capcode, the Documentation &raquo; Class: Capcode::ParameterError
7
+ </title>
8
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
9
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
10
+ <script language="JavaScript" type="text/javascript">
11
+ // <![CDATA[
12
+
13
+ function toggleSource( id )
14
+ {
15
+ var elem
16
+ var link
17
+
18
+ if( document.getElementById )
19
+ {
20
+ elem = document.getElementById( id )
21
+ link = document.getElementById( "l_" + id )
22
+ }
23
+ else if ( document.all )
24
+ {
25
+ elem = eval( "document.all." + id )
26
+ link = eval( "document.all.l_" + id )
27
+ }
28
+ else
29
+ return false;
30
+
31
+ if( elem.style.display == "block" )
32
+ {
33
+ elem.style.display = "none"
34
+ link.innerHTML = "show source"
35
+ }
36
+ else
37
+ {
38
+ elem.style.display = "block"
39
+ link.innerHTML = "hide source"
40
+ }
41
+ }
42
+
43
+ function openCode( url )
44
+ {
45
+ window.open( url, "SOURCE_CODE", "width=400,height=400,scrollbars=yes" )
46
+ }
47
+ // ]]>
48
+ </script>
49
+ </head>
50
+ <body>
51
+ <!--
52
+ <div id="menu">
53
+ <h3 class="title">Class: Capcode::ParameterError</h3>
54
+ </div>
55
+ -->
56
+ <div id="fullpage">
57
+ <div id="pager">
58
+ <table>
59
+ <tr><td><img src="../../rubyfr.png" /></td>
60
+ <td id="pagertd">
61
+ <strong># Class: Capcode::ParameterError<br />
62
+ [
63
+ "<a href="../../files/README.html" value="File: README">README</a>",
64
+ "<a href="../../files/AUTHORS.html" value="File: AUTHORS">AUTHORS</a>",
65
+ "<a href="../../files/COPYING.html" value="File: COPYING">COPYING</a>",
66
+ "<a href="../../files/lib/capcode_rb.html" value="File: capcode.rb">lib/capcode.rb</a>",
67
+ <a href="http://greg.rubyfr.net">nil</a>].each do<br />
68
+ <a href="../../classes/Capcode.html" title="Module: Capcode">Capcode</a>.view_html<br />
69
+ <a href="../../classes/Capcode/Helpers.html" title="Module: Capcode::Helpers">Capcode::Helpers</a>.view_html<br />
70
+ <a href="../../classes/Capcode/HTTPError.html" title="Class: Capcode::HTTPError">Capcode::HTTPError</a>.view_html<br />
71
+ <a href="../../classes/Capcode/ParameterError.html" title="Class: Capcode::ParameterError">Capcode::ParameterError</a>.view_html<br />
72
+ end</strong>
73
+ </td></tr>
74
+ </table>
75
+ </ul>
76
+ </div>
77
+
78
+
79
+ <div id="Capcode::ParameterError" class="page_shade">
80
+ <div class="page">
81
+ <h3>Class Capcode::ParameterError &lt; ArgumentError</h3>
82
+
83
+ (in files
84
+ <a href="../../files/lib/capcode_rb.html">lib/capcode.rb</a>
85
+ )
86
+
87
+ <p>
88
+ <a href="HTTPError.html">HTTPError</a> help you to create your own 404, 500
89
+ and/or 501 response
90
+ </p>
91
+ <p>
92
+ To create a custom 404 reponse, create a fonction HTTPError.r404 in your
93
+ application :
94
+ </p>
95
+ <pre>
96
+ module Capcode
97
+ class HTTPError
98
+ def r404(f)
99
+ &quot;#{f} not found :(&quot;
100
+ end
101
+ end
102
+ end
103
+ </pre>
104
+ <p>
105
+ Do the same (r500 and r501) to customize 500 and 501 errors
106
+ </p>
107
+
108
+
109
+
110
+
111
+ <h4>Includes</h4>
112
+ <ul>
113
+ <li>Rack</li>
114
+ <li><a href="Capcode/Helpers.html">Capcode::Helpers</a></li>
115
+ </ul>
116
+
117
+
118
+
119
+ </div>
120
+ </div>
121
+
122
+
123
+ </div>
124
+ </body>
125
+ </html>