Capcode 0.9.9 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +3 -0
- data/examples/rest.log +15 -0
- data/examples/static.rb +12 -0
- data/examples/static/static-index.html +1 -0
- data/lib/capcode.rb +14 -344
- data/lib/capcode/filters.rb +1 -0
- data/lib/capcode/helpers.rb +246 -0
- data/lib/capcode/http_error.rb +49 -0
- data/lib/capcode/static_files.rb +68 -0
- data/lib/capcode/version.rb +1 -1
- metadata +46 -61
- data/doc/rdoc/classes/Capcode.html +0 -1076
- data/doc/rdoc/classes/Capcode/Base.html +0 -136
- data/doc/rdoc/classes/Capcode/Configuration.html +0 -290
- data/doc/rdoc/classes/Capcode/HTTPError.html +0 -148
- data/doc/rdoc/classes/Capcode/Helpers.html +0 -674
- data/doc/rdoc/classes/Capcode/Helpers/Authorization.html +0 -219
- data/doc/rdoc/classes/Capcode/Resource.html +0 -111
- data/doc/rdoc/classes/Capcode/StaticFiles.html +0 -199
- data/doc/rdoc/classes/Capcode/Views.html +0 -112
- data/doc/rdoc/created.rid +0 -1
- data/doc/rdoc/files/AUTHORS.html +0 -107
- data/doc/rdoc/files/COPYING.html +0 -531
- data/doc/rdoc/files/README_rdoc.html +0 -887
- data/doc/rdoc/files/lib/capcode/base/db_rb.html +0 -101
- data/doc/rdoc/files/lib/capcode/configuration_rb.html +0 -101
- data/doc/rdoc/files/lib/capcode/filters_rb.html +0 -101
- data/doc/rdoc/files/lib/capcode/helpers/auth_rb.html +0 -101
- data/doc/rdoc/files/lib/capcode/render/text_rb.html +0 -101
- data/doc/rdoc/files/lib/capcode_rb.html +0 -144
- data/doc/rdoc/fr_class_index.html +0 -35
- data/doc/rdoc/fr_file_index.html +0 -35
- data/doc/rdoc/fr_method_index.html +0 -56
- data/doc/rdoc/index.html +0 -24
- data/doc/rdoc/rdoc-style.css +0 -208
- data/lib/capcode.rbSAVE +0 -881
@@ -1,219 +0,0 @@
|
|
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: Capcode::Helpers::Authorization</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">Capcode::Helpers::Authorization</td>
|
54
|
-
</tr>
|
55
|
-
<tr class="top-aligned-row">
|
56
|
-
<td><strong>In:</strong></td>
|
57
|
-
<td>
|
58
|
-
<a href="../../../files/lib/capcode/helpers/auth_rb.html">
|
59
|
-
lib/capcode/helpers/auth.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
|
-
Because this helper was trully inspired by this post : <a
|
78
|
-
href="http://www.gittr.com/index.php/archive/sinatra-basic-authentication-selectively-applied">www.gittr.com/index.php/archive/sinatra-basic-authentication-selectively-applied</a>/
|
79
|
-
and because the code in this post was extracted out of Wink, this file
|
80
|
-
follow the Wink license :
|
81
|
-
</p>
|
82
|
-
<p>
|
83
|
-
Permission is hereby granted, free of charge, to any person obtaining a
|
84
|
-
copy of this software and associated documentation files (the
|
85
|
-
"Software"), to deal in the Software without restriction,
|
86
|
-
including without limitation the rights to use, copy, modify, merge,
|
87
|
-
publish, distribute, sublicense, and/or sell copies of the Software, and to
|
88
|
-
permit persons to whom the Software is furnished to do so, subject to the
|
89
|
-
following conditions:
|
90
|
-
</p>
|
91
|
-
<p>
|
92
|
-
The above copyright notice and this permission notice shall be included in
|
93
|
-
all copies or substantial portions of the Software.
|
94
|
-
</p>
|
95
|
-
<p>
|
96
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
97
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
98
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
99
|
-
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
100
|
-
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
101
|
-
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
102
|
-
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
103
|
-
</p>
|
104
|
-
|
105
|
-
</div>
|
106
|
-
|
107
|
-
|
108
|
-
</div>
|
109
|
-
|
110
|
-
<div id="method-list">
|
111
|
-
<h3 class="section-bar">Methods</h3>
|
112
|
-
|
113
|
-
<div class="name-list">
|
114
|
-
<a href="#M000024">http_authentication</a>
|
115
|
-
</div>
|
116
|
-
</div>
|
117
|
-
|
118
|
-
</div>
|
119
|
-
|
120
|
-
|
121
|
-
<!-- if includes -->
|
122
|
-
|
123
|
-
<div id="section">
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
<!-- if method_list -->
|
133
|
-
<div id="methods">
|
134
|
-
<h3 class="section-bar">Public Instance methods</h3>
|
135
|
-
|
136
|
-
<div id="method-M000024" class="method-detail">
|
137
|
-
<a name="M000024"></a>
|
138
|
-
|
139
|
-
<div class="method-heading">
|
140
|
-
<a href="#M000024" class="method-signature">
|
141
|
-
<span class="method-name">http_authentication</span><span class="method-args">( opts = {}, &b )</span>
|
142
|
-
</a>
|
143
|
-
</div>
|
144
|
-
|
145
|
-
<div class="method-description">
|
146
|
-
<p>
|
147
|
-
Allow you to add and HTTP Authentication (Basic or Digest) to a controller
|
148
|
-
</p>
|
149
|
-
<p>
|
150
|
-
Options :
|
151
|
-
</p>
|
152
|
-
<ul>
|
153
|
-
<li><tt>:type</tt> : Authentication type (<tt>:basic</tt> or <tt>:digest</tt>)
|
154
|
-
- default : <tt>:basic</tt>
|
155
|
-
|
156
|
-
</li>
|
157
|
-
<li><tt>:realm</tt> : realm ;) - default : "Capcode.app"
|
158
|
-
|
159
|
-
</li>
|
160
|
-
<li><tt>:opaque</tt> : Your secret passphrase. You MUST set it if you use
|
161
|
-
Digest Auth - default : "opaque"
|
162
|
-
|
163
|
-
</li>
|
164
|
-
</ul>
|
165
|
-
<p>
|
166
|
-
The block must return a Hash of username => password like that :
|
167
|
-
</p>
|
168
|
-
<pre>
|
169
|
-
{
|
170
|
-
"user1" => "pass1",
|
171
|
-
"user2" => "pass2",
|
172
|
-
# ...
|
173
|
-
}
|
174
|
-
</pre>
|
175
|
-
<p><a class="source-toggle" href="#"
|
176
|
-
onclick="toggleCode('M000024-source');return false;">[Source]</a></p>
|
177
|
-
<div class="method-source-code" id="M000024-source">
|
178
|
-
<pre>
|
179
|
-
<span class="ruby-comment cmt"># File lib/capcode/helpers/auth.rb, line 105</span>
|
180
|
-
105: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">http_authentication</span>( <span class="ruby-identifier">opts</span> = {}, <span class="ruby-operator">&</span><span class="ruby-identifier">b</span> )
|
181
|
-
106: <span class="ruby-ivar">@auth</span> = <span class="ruby-keyword kw">nil</span>
|
182
|
-
107:
|
183
|
-
108: <span class="ruby-ivar">@auth_type</span> = <span class="ruby-identifier">opts</span>[<span class="ruby-identifier">:type</span>]<span class="ruby-operator">||</span><span class="ruby-identifier">:basic</span>
|
184
|
-
109: <span class="ruby-identifier">realm</span> = <span class="ruby-identifier">opts</span>[<span class="ruby-identifier">:realm</span>]<span class="ruby-operator">||</span><span class="ruby-value str">"Capcode.app"</span>
|
185
|
-
110: <span class="ruby-identifier">opaque</span> = <span class="ruby-identifier">opts</span>[<span class="ruby-identifier">:opaque</span>]<span class="ruby-operator">||</span><span class="ruby-value str">"opaque"</span>
|
186
|
-
111: <span class="ruby-ivar">@authorizations</span> = <span class="ruby-identifier">b</span>
|
187
|
-
112:
|
188
|
-
113: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">authorized?</span>
|
189
|
-
114:
|
190
|
-
115: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@auth_type</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:basic</span>
|
191
|
-
116: <span class="ruby-identifier">basic_unauthorized!</span>(<span class="ruby-identifier">realm</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">auth</span>.<span class="ruby-identifier">provided?</span>
|
192
|
-
117: <span class="ruby-identifier">bad_request!</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">auth</span>.<span class="ruby-identifier">basic?</span>
|
193
|
-
118: <span class="ruby-identifier">basic_unauthorized!</span>(<span class="ruby-identifier">realm</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">basic_authorize</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">auth</span>.<span class="ruby-identifier">credentials</span>)
|
194
|
-
119: <span class="ruby-keyword kw">else</span>
|
195
|
-
120: <span class="ruby-identifier">digest_unauthorized!</span>(<span class="ruby-identifier">realm</span>, <span class="ruby-identifier">opaque</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">auth</span>.<span class="ruby-identifier">provided?</span>
|
196
|
-
121: <span class="ruby-identifier">bad_request!</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">auth</span>.<span class="ruby-identifier">digest?</span>
|
197
|
-
122: <span class="ruby-identifier">digest_unauthorized!</span>(<span class="ruby-identifier">realm</span>, <span class="ruby-identifier">opaque</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">digest_authorize</span>
|
198
|
-
123: <span class="ruby-keyword kw">end</span>
|
199
|
-
124:
|
200
|
-
125: <span class="ruby-identifier">request</span>.<span class="ruby-identifier">env</span>[<span class="ruby-value str">'REMOTE_USER'</span>] = <span class="ruby-identifier">auth</span>.<span class="ruby-identifier">username</span>
|
201
|
-
126: <span class="ruby-keyword kw">end</span>
|
202
|
-
</pre>
|
203
|
-
</div>
|
204
|
-
</div>
|
205
|
-
</div>
|
206
|
-
|
207
|
-
|
208
|
-
</div>
|
209
|
-
|
210
|
-
|
211
|
-
</div>
|
212
|
-
|
213
|
-
|
214
|
-
<div id="validator-badges">
|
215
|
-
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
216
|
-
</div>
|
217
|
-
|
218
|
-
</body>
|
219
|
-
</html>
|
@@ -1,111 +0,0 @@
|
|
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: Capcode::Resource</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">Capcode::Resource</td>
|
54
|
-
</tr>
|
55
|
-
<tr class="top-aligned-row">
|
56
|
-
<td><strong>In:</strong></td>
|
57
|
-
<td>
|
58
|
-
<a href="../../files/lib/capcode/base/db_rb.html">
|
59
|
-
lib/capcode/base/db.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
|
-
This module contains the resources needed in a model
|
78
|
-
</p>
|
79
|
-
|
80
|
-
</div>
|
81
|
-
|
82
|
-
|
83
|
-
</div>
|
84
|
-
|
85
|
-
|
86
|
-
</div>
|
87
|
-
|
88
|
-
|
89
|
-
<!-- if includes -->
|
90
|
-
|
91
|
-
<div id="section">
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
<!-- if method_list -->
|
101
|
-
|
102
|
-
|
103
|
-
</div>
|
104
|
-
|
105
|
-
|
106
|
-
<div id="validator-badges">
|
107
|
-
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
108
|
-
</div>
|
109
|
-
|
110
|
-
</body>
|
111
|
-
</html>
|
@@ -1,199 +0,0 @@
|
|
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: Capcode::StaticFiles</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">Capcode::StaticFiles</td>
|
54
|
-
</tr>
|
55
|
-
<tr class="top-aligned-row">
|
56
|
-
<td><strong>In:</strong></td>
|
57
|
-
<td>
|
58
|
-
<a href="../../files/lib/capcode_rb.html">
|
59
|
-
lib/capcode.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
|
-
<div id="description">
|
82
|
-
<p>
|
83
|
-
Static file loader
|
84
|
-
</p>
|
85
|
-
<p>
|
86
|
-
Use :
|
87
|
-
</p>
|
88
|
-
<pre>
|
89
|
-
set :static, "path/to/static"
|
90
|
-
</pre>
|
91
|
-
|
92
|
-
</div>
|
93
|
-
|
94
|
-
|
95
|
-
</div>
|
96
|
-
|
97
|
-
<div id="method-list">
|
98
|
-
<h3 class="section-bar">Methods</h3>
|
99
|
-
|
100
|
-
<div class="name-list">
|
101
|
-
<a href="#M000026">call</a>
|
102
|
-
<a href="#M000025">new</a>
|
103
|
-
</div>
|
104
|
-
</div>
|
105
|
-
|
106
|
-
</div>
|
107
|
-
|
108
|
-
|
109
|
-
<!-- if includes -->
|
110
|
-
|
111
|
-
<div id="section">
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
<!-- if method_list -->
|
121
|
-
<div id="methods">
|
122
|
-
<h3 class="section-bar">Public Class methods</h3>
|
123
|
-
|
124
|
-
<div id="method-M000025" class="method-detail">
|
125
|
-
<a name="M000025"></a>
|
126
|
-
|
127
|
-
<div class="method-heading">
|
128
|
-
<a href="#M000025" class="method-signature">
|
129
|
-
<span class="method-name">new</span><span class="method-args">(app)</span>
|
130
|
-
</a>
|
131
|
-
</div>
|
132
|
-
|
133
|
-
<div class="method-description">
|
134
|
-
<p><a class="source-toggle" href="#"
|
135
|
-
onclick="toggleCode('M000025-source');return false;">[Source]</a></p>
|
136
|
-
<div class="method-source-code" id="M000025-source">
|
137
|
-
<pre>
|
138
|
-
<span class="ruby-comment cmt"># File lib/capcode.rb, line 352</span>
|
139
|
-
352: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">app</span>)
|
140
|
-
353: <span class="ruby-ivar">@app</span> = <span class="ruby-identifier">app</span>
|
141
|
-
354: <span class="ruby-keyword kw">end</span>
|
142
|
-
</pre>
|
143
|
-
</div>
|
144
|
-
</div>
|
145
|
-
</div>
|
146
|
-
|
147
|
-
<h3 class="section-bar">Public Instance methods</h3>
|
148
|
-
|
149
|
-
<div id="method-M000026" class="method-detail">
|
150
|
-
<a name="M000026"></a>
|
151
|
-
|
152
|
-
<div class="method-heading">
|
153
|
-
<a href="#M000026" class="method-signature">
|
154
|
-
<span class="method-name">call</span><span class="method-args">(env)</span>
|
155
|
-
</a>
|
156
|
-
</div>
|
157
|
-
|
158
|
-
<div class="method-description">
|
159
|
-
<p><a class="source-toggle" href="#"
|
160
|
-
onclick="toggleCode('M000026-source');return false;">[Source]</a></p>
|
161
|
-
<div class="method-source-code" id="M000026-source">
|
162
|
-
<pre>
|
163
|
-
<span class="ruby-comment cmt"># File lib/capcode.rb, line 356</span>
|
164
|
-
356: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>)
|
165
|
-
357: <span class="ruby-identifier">static</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>( <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:root</span>), <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:static</span>) ) )
|
166
|
-
358: <span class="ruby-identifier">file</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">static</span>, <span class="ruby-identifier">env</span>[<span class="ruby-value str">'REQUEST_PATH'</span>].<span class="ruby-identifier">split</span>(<span class="ruby-value str">"/"</span>) )
|
167
|
-
359: <span class="ruby-identifier">file</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">file</span>, <span class="ruby-value str">"index.html"</span> ) <span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span>(<span class="ruby-identifier">file</span>)
|
168
|
-
360: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-identifier">file</span>)
|
169
|
-
361: <span class="ruby-identifier">body</span> = [<span class="ruby-operator">::</span><span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span>(<span class="ruby-identifier">file</span>)]
|
170
|
-
362: <span class="ruby-identifier">header</span> = {
|
171
|
-
363: <span class="ruby-value str">"Last-Modified"</span> =<span class="ruby-operator">></span> <span class="ruby-operator">::</span><span class="ruby-constant">File</span>.<span class="ruby-identifier">mtime</span>(<span class="ruby-identifier">file</span>).<span class="ruby-identifier">httpdate</span>,
|
172
|
-
364: <span class="ruby-value str">"Content-Type"</span> =<span class="ruby-operator">></span> <span class="ruby-operator">::</span><span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Mime</span>.<span class="ruby-identifier">mime_type</span>(<span class="ruby-operator">::</span><span class="ruby-constant">File</span>.<span class="ruby-identifier">extname</span>(<span class="ruby-identifier">file</span>), <span class="ruby-value str">'text/plain'</span>),
|
173
|
-
365: <span class="ruby-value str">"Content-Length"</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">body</span>.<span class="ruby-identifier">first</span>.<span class="ruby-identifier">size</span>.<span class="ruby-identifier">to_s</span>
|
174
|
-
366: }
|
175
|
-
367: <span class="ruby-keyword kw">return</span> [<span class="ruby-value">200</span>, <span class="ruby-identifier">header</span>, <span class="ruby-identifier">body</span>]
|
176
|
-
368: <span class="ruby-keyword kw">else</span>
|
177
|
-
369: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@app</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>)
|
178
|
-
370: <span class="ruby-keyword kw">end</span>
|
179
|
-
371:
|
180
|
-
372: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@app</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>)
|
181
|
-
373: <span class="ruby-keyword kw">end</span>
|
182
|
-
</pre>
|
183
|
-
</div>
|
184
|
-
</div>
|
185
|
-
</div>
|
186
|
-
|
187
|
-
|
188
|
-
</div>
|
189
|
-
|
190
|
-
|
191
|
-
</div>
|
192
|
-
|
193
|
-
|
194
|
-
<div id="validator-badges">
|
195
|
-
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
196
|
-
</div>
|
197
|
-
|
198
|
-
</body>
|
199
|
-
</html>
|