Capcode 0.8.1 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -10,6 +10,13 @@ Capcode is a web microframework
10
10
 
11
11
  == FEATURES/PROBLEMS:
12
12
 
13
+ === 0.8.2
14
+ * Add XML renderer (see rss example)
15
+ * Major bug corrections
16
+ * Add Helpers.static
17
+ * New example : upload.rb
18
+ * The database' configuration file is no more relative to the root directory but to the main file
19
+
13
20
  === 0.8.1
14
21
  * Sorry for 0.8.0 !!
15
22
 
@@ -46,7 +53,7 @@ Capcode is a web microframework
46
53
  === 0.6.0
47
54
  * Add :root option to Capcode.run. This option allow you to specify the root directory for static files
48
55
  * Add :working_directory option to Capcode.run. This option allow you to specify the working directory
49
- * Of '/' route is not defined but /index.html exist, display index
56
+ * If '/' route is not defined but /index.html exist, display index
50
57
  * add mime-types dependency
51
58
  * Bug correction in erb and haml renderer
52
59
 
@@ -130,130 +130,130 @@ If the regexp in the route does not match, all arguments will be
130
130
  <p class="source-link">[ <a href="javascript:toggleSource('M000001_source')" id="l_M000001_source">show source</a> ]</p>
131
131
  <div id="M000001_source" class="dyn-source">
132
132
  <pre>
133
- <span class="ruby-comment cmt"># File lib/capcode.rb, line 202</span>
134
- 202: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">Route</span> <span class="ruby-operator">*</span><span class="ruby-identifier">u</span>
135
- 203: <span class="ruby-constant">Class</span>.<span class="ruby-identifier">new</span> {
136
- 204: <span class="ruby-identifier">meta_def</span>(<span class="ruby-identifier">:__urls__</span>){
137
- 205: <span class="ruby-comment cmt"># &lt; Route '/hello/world/([^\/]*)/id(\d*)', '/hello/(.*)'</span>
138
- 206: <span class="ruby-comment cmt"># # =&gt; [ {'/hello/world' =&gt; '([^\/]*)/id(\d*)', '/hello' =&gt; '(.*)'}, 2, &lt;Capcode::Klass&gt; ]</span>
139
- 207: <span class="ruby-identifier">h</span> = {}
140
- 208: <span class="ruby-identifier">max</span> = <span class="ruby-value">0</span>
141
- 209: <span class="ruby-identifier">u</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">_u</span><span class="ruby-operator">|</span>
142
- 210: <span class="ruby-identifier">m</span> = <span class="ruby-regexp re">/\/([^\/]*\(.*)/</span>.<span class="ruby-identifier">match</span>( <span class="ruby-identifier">_u</span> )
143
- 211: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">m</span>.<span class="ruby-identifier">nil?</span>
144
- 212: <span class="ruby-identifier">raise</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">RouteError</span>, <span class="ruby-node">&quot;Route `#{_u}' already defined with regexp `#{h[_u]}' !&quot;</span>, <span class="ruby-identifier">caller</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">h</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">_u</span>)
145
- 213: <span class="ruby-identifier">h</span>[<span class="ruby-identifier">_u</span>] = <span class="ruby-value str">''</span>
146
- 214: <span class="ruby-keyword kw">else</span>
147
- 215: <span class="ruby-identifier">_pre</span> = <span class="ruby-identifier">m</span>.<span class="ruby-identifier">pre_match</span>
148
- 216: <span class="ruby-identifier">_pre</span> = <span class="ruby-value str">&quot;/&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">_pre</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
149
- 217: <span class="ruby-identifier">raise</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">RouteError</span>, <span class="ruby-node">&quot;Route `#{_pre}' already defined with regexp `#{h[_pre]}' !&quot;</span>, <span class="ruby-identifier">caller</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">h</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">_pre</span>)
150
- 218: <span class="ruby-identifier">h</span>[<span class="ruby-identifier">_pre</span>] = <span class="ruby-identifier">m</span>.<span class="ruby-identifier">captures</span>[<span class="ruby-value">0</span>]
151
- 219: <span class="ruby-identifier">max</span> = <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">m</span>.<span class="ruby-identifier">captures</span>[<span class="ruby-value">0</span>]).<span class="ruby-identifier">number_of_captures</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">max</span> <span class="ruby-operator">&lt;</span> <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">m</span>.<span class="ruby-identifier">captures</span>[<span class="ruby-value">0</span>]).<span class="ruby-identifier">number_of_captures</span>
152
- 220: <span class="ruby-keyword kw">end</span>
153
- 221: <span class="ruby-keyword kw">end</span>
154
- 222: [<span class="ruby-identifier">h</span>, <span class="ruby-identifier">max</span>, <span class="ruby-keyword kw">self</span>]
155
- 223: }
156
- 224:
157
- 225: <span class="ruby-comment cmt"># Hash containing all the request parameters (GET or POST)</span>
158
- 226: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">params</span>
159
- 227: <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">params</span>
160
- 228: <span class="ruby-keyword kw">end</span>
161
- 229:
162
- 230: <span class="ruby-comment cmt"># Hash containing all the environment variables</span>
163
- 231: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">env</span>
164
- 232: <span class="ruby-ivar">@env</span>
165
- 233: <span class="ruby-keyword kw">end</span>
166
- 234:
167
- 235: <span class="ruby-comment cmt"># Hash session</span>
168
- 236: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">session</span>
169
- 237: <span class="ruby-ivar">@env</span>[<span class="ruby-value str">'rack.session'</span>]
170
- 238: <span class="ruby-keyword kw">end</span>
171
- 239:
172
- 240: <span class="ruby-comment cmt"># Return the Rack::Request object</span>
173
- 241: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">request</span>
174
- 242: <span class="ruby-ivar">@request</span>
175
- 243: <span class="ruby-keyword kw">end</span>
176
- 244:
177
- 245: <span class="ruby-comment cmt"># Return the Rack::Response object</span>
178
- 246: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">response</span>
179
- 247: <span class="ruby-ivar">@response</span>
180
- 248: <span class="ruby-keyword kw">end</span>
181
- 249:
182
- 250: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">call</span>( <span class="ruby-identifier">e</span> ) <span class="ruby-comment cmt">#:nodoc:</span>
183
- 251: <span class="ruby-ivar">@env</span> = <span class="ruby-identifier">e</span>
184
- 252: <span class="ruby-ivar">@response</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Response</span>.<span class="ruby-identifier">new</span>
185
- 253: <span class="ruby-ivar">@request</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Request</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@env</span>)
186
- 254:
187
- 255: <span class="ruby-comment cmt"># __k = self.class.to_s.split( /::/ )[-1].downcase.to_sym</span>
188
- 256: <span class="ruby-comment cmt"># @@__FILTERS.each do |f|</span>
189
- 257: <span class="ruby-comment cmt"># proc = f.delete(:action)</span>
190
- 258: <span class="ruby-comment cmt"># __run = true</span>
191
- 259: <span class="ruby-comment cmt"># if f[:only]</span>
192
- 260: <span class="ruby-comment cmt"># __run = f[:only].include?(__k)</span>
193
- 261: <span class="ruby-comment cmt"># end</span>
194
- 262: <span class="ruby-comment cmt"># if f[:except]</span>
195
- 263: <span class="ruby-comment cmt"># __run = !f[:except].include?(__k)</span>
196
- 264: <span class="ruby-comment cmt"># end</span>
197
- 265: <span class="ruby-comment cmt"># </span>
198
- 266: <span class="ruby-comment cmt"># # proc.call(self) if __run</span>
199
- 267: <span class="ruby-comment cmt"># puts &quot;call #{proc} for #{__k}&quot;</span>
200
- 268: <span class="ruby-comment cmt"># end</span>
201
- 269:
202
- 270: <span class="ruby-identifier">r</span> = <span class="ruby-keyword kw">case</span> <span class="ruby-ivar">@env</span>[<span class="ruby-value str">&quot;REQUEST_METHOD&quot;</span>]
203
- 271: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">&quot;GET&quot;</span>
204
- 272: <span class="ruby-identifier">finalPath</span> = <span class="ruby-keyword kw">nil</span>
205
- 273: <span class="ruby-identifier">finalArgs</span> = <span class="ruby-keyword kw">nil</span>
206
- 274: <span class="ruby-identifier">finalNArgs</span> = <span class="ruby-keyword kw">nil</span>
207
- 275:
208
- 276: <span class="ruby-identifier">aPath</span> = <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">path</span>.<span class="ruby-identifier">gsub</span>( <span class="ruby-regexp re">/^\//</span>, <span class="ruby-value str">&quot;&quot;</span> ).<span class="ruby-identifier">split</span>( <span class="ruby-value str">&quot;/&quot;</span> )
209
- 277: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">__urls__</span>[<span class="ruby-value">0</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">r</span><span class="ruby-operator">|</span>
210
- 278: <span class="ruby-identifier">xPath</span> = <span class="ruby-identifier">p</span>.<span class="ruby-identifier">gsub</span>( <span class="ruby-regexp re">/^\//</span>, <span class="ruby-value str">&quot;&quot;</span> ).<span class="ruby-identifier">split</span>( <span class="ruby-value str">&quot;/&quot;</span> )
211
- 279: <span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">xPath</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">aPath</span>).<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
212
- 280: <span class="ruby-identifier">diffArgs</span> = <span class="ruby-identifier">aPath</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">xPath</span>
213
- 281: <span class="ruby-identifier">diffNArgs</span> = <span class="ruby-identifier">diffArgs</span>.<span class="ruby-identifier">size</span>
214
- 282: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">finalNArgs</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">finalNArgs</span> <span class="ruby-operator">&gt;</span> <span class="ruby-identifier">diffNArgs</span>
215
- 283: <span class="ruby-identifier">finalPath</span> = <span class="ruby-identifier">p</span>
216
- 284: <span class="ruby-identifier">finalNArgs</span> = <span class="ruby-identifier">diffNArgs</span>
217
- 285: <span class="ruby-identifier">finalArgs</span> = <span class="ruby-identifier">diffArgs</span>
218
- 286: <span class="ruby-keyword kw">end</span>
219
- 287: <span class="ruby-keyword kw">end</span>
220
- 288:
221
- 289: <span class="ruby-keyword kw">end</span>
222
- 290:
223
- 291: <span class="ruby-identifier">nargs</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">__urls__</span>[<span class="ruby-value">1</span>]
224
- 292: <span class="ruby-identifier">regexp</span> = <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">new</span>( <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">__urls__</span>[<span class="ruby-value">0</span>][<span class="ruby-identifier">finalPath</span>] )
225
- 293: <span class="ruby-identifier">args</span> = <span class="ruby-identifier">regexp</span>.<span class="ruby-identifier">match</span>( <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Utils</span>.<span class="ruby-identifier">unescape</span>(<span class="ruby-ivar">@request</span>.<span class="ruby-identifier">path</span>).<span class="ruby-identifier">gsub</span>( <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">new</span>( <span class="ruby-node">&quot;^#{finalPath}&quot;</span> ), <span class="ruby-value str">&quot;&quot;</span> ).<span class="ruby-identifier">gsub</span>( <span class="ruby-regexp re">/^\//</span>, <span class="ruby-value str">&quot;&quot;</span> ) )
226
- 294: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">nil?</span>
227
- 295: <span class="ruby-identifier">raise</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">ParameterError</span>, <span class="ruby-node">&quot;Path info `#{@request.path_info}' does not match route regexp `#{regexp.source}'&quot;</span>
228
- 296: <span class="ruby-keyword kw">else</span>
229
- 297: <span class="ruby-identifier">args</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">captures</span>.<span class="ruby-identifier">map</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">size</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>)<span class="ruby-operator">?</span><span class="ruby-keyword kw">nil</span><span class="ruby-operator">:</span><span class="ruby-identifier">x</span> }
230
- 298: <span class="ruby-keyword kw">end</span>
231
- 299:
232
- 300: <span class="ruby-keyword kw">while</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">&lt;</span> <span class="ruby-identifier">nargs</span>
233
- 301: <span class="ruby-identifier">args</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-keyword kw">nil</span>
234
- 302: <span class="ruby-keyword kw">end</span>
235
- 303:
236
- 304: <span class="ruby-identifier">get</span>( <span class="ruby-operator">*</span><span class="ruby-identifier">args</span> )
237
- 305: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">&quot;POST&quot;</span>
238
- 306: <span class="ruby-identifier">post</span>
239
- 307: <span class="ruby-keyword kw">end</span>
240
- 308: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">r</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:to_ary</span>)
241
- 309: <span class="ruby-ivar">@response</span>.<span class="ruby-identifier">status</span> = <span class="ruby-identifier">r</span>[<span class="ruby-value">0</span>]
242
- 310: <span class="ruby-identifier">r</span>[<span class="ruby-value">1</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
243
- 311: <span class="ruby-ivar">@response</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-identifier">v</span>
244
- 312: <span class="ruby-keyword kw">end</span>
245
- 313: <span class="ruby-ivar">@response</span>.<span class="ruby-identifier">body</span> = <span class="ruby-identifier">r</span>[<span class="ruby-value">2</span>]
246
- 314: <span class="ruby-keyword kw">else</span>
247
- 315: <span class="ruby-ivar">@response</span>.<span class="ruby-identifier">write</span> <span class="ruby-identifier">r</span>
248
- 316: <span class="ruby-keyword kw">end</span>
249
- 317:
250
- 318: <span class="ruby-ivar">@response</span>.<span class="ruby-identifier">finish</span>
251
- 319: <span class="ruby-keyword kw">end</span>
252
- 320:
253
- 321: <span class="ruby-identifier">include</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Helpers</span>
254
- 322: <span class="ruby-identifier">include</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Views</span>
255
- 323: }
256
- 324: <span class="ruby-keyword kw">end</span>
133
+ <span class="ruby-comment cmt"># File lib/capcode.rb, line 210</span>
134
+ 210: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">Route</span> <span class="ruby-operator">*</span><span class="ruby-identifier">u</span>
135
+ 211: <span class="ruby-constant">Class</span>.<span class="ruby-identifier">new</span> {
136
+ 212: <span class="ruby-identifier">meta_def</span>(<span class="ruby-identifier">:__urls__</span>){
137
+ 213: <span class="ruby-comment cmt"># &lt; Route '/hello/world/([^\/]*)/id(\d*)', '/hello/(.*)'</span>
138
+ 214: <span class="ruby-comment cmt"># # =&gt; [ {'/hello/world' =&gt; '([^\/]*)/id(\d*)', '/hello' =&gt; '(.*)'}, 2, &lt;Capcode::Klass&gt; ]</span>
139
+ 215: <span class="ruby-identifier">h</span> = {}
140
+ 216: <span class="ruby-identifier">max</span> = <span class="ruby-value">0</span>
141
+ 217: <span class="ruby-identifier">u</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">_u</span><span class="ruby-operator">|</span>
142
+ 218: <span class="ruby-identifier">m</span> = <span class="ruby-regexp re">/\/([^\/]*\(.*)/</span>.<span class="ruby-identifier">match</span>( <span class="ruby-identifier">_u</span> )
143
+ 219: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">m</span>.<span class="ruby-identifier">nil?</span>
144
+ 220: <span class="ruby-identifier">raise</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">RouteError</span>, <span class="ruby-node">&quot;Route `#{_u}' already defined with regexp `#{h[_u]}' !&quot;</span>, <span class="ruby-identifier">caller</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">h</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">_u</span>)
145
+ 221: <span class="ruby-identifier">h</span>[<span class="ruby-identifier">_u</span>] = <span class="ruby-value str">''</span>
146
+ 222: <span class="ruby-keyword kw">else</span>
147
+ 223: <span class="ruby-identifier">_pre</span> = <span class="ruby-identifier">m</span>.<span class="ruby-identifier">pre_match</span>
148
+ 224: <span class="ruby-identifier">_pre</span> = <span class="ruby-value str">&quot;/&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">_pre</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
149
+ 225: <span class="ruby-identifier">raise</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">RouteError</span>, <span class="ruby-node">&quot;Route `#{_pre}' already defined with regexp `#{h[_pre]}' !&quot;</span>, <span class="ruby-identifier">caller</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">h</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">_pre</span>)
150
+ 226: <span class="ruby-identifier">h</span>[<span class="ruby-identifier">_pre</span>] = <span class="ruby-identifier">m</span>.<span class="ruby-identifier">captures</span>[<span class="ruby-value">0</span>]
151
+ 227: <span class="ruby-identifier">max</span> = <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">m</span>.<span class="ruby-identifier">captures</span>[<span class="ruby-value">0</span>]).<span class="ruby-identifier">number_of_captures</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">max</span> <span class="ruby-operator">&lt;</span> <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">m</span>.<span class="ruby-identifier">captures</span>[<span class="ruby-value">0</span>]).<span class="ruby-identifier">number_of_captures</span>
152
+ 228: <span class="ruby-keyword kw">end</span>
153
+ 229: <span class="ruby-keyword kw">end</span>
154
+ 230: [<span class="ruby-identifier">h</span>, <span class="ruby-identifier">max</span>, <span class="ruby-keyword kw">self</span>]
155
+ 231: }
156
+ 232:
157
+ 233: <span class="ruby-comment cmt"># Hash containing all the request parameters (GET or POST)</span>
158
+ 234: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">params</span>
159
+ 235: <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">params</span>
160
+ 236: <span class="ruby-keyword kw">end</span>
161
+ 237:
162
+ 238: <span class="ruby-comment cmt"># Hash containing all the environment variables</span>
163
+ 239: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">env</span>
164
+ 240: <span class="ruby-ivar">@env</span>
165
+ 241: <span class="ruby-keyword kw">end</span>
166
+ 242:
167
+ 243: <span class="ruby-comment cmt"># Hash session</span>
168
+ 244: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">session</span>
169
+ 245: <span class="ruby-ivar">@env</span>[<span class="ruby-value str">'rack.session'</span>]
170
+ 246: <span class="ruby-keyword kw">end</span>
171
+ 247:
172
+ 248: <span class="ruby-comment cmt"># Return the Rack::Request object</span>
173
+ 249: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">request</span>
174
+ 250: <span class="ruby-ivar">@request</span>
175
+ 251: <span class="ruby-keyword kw">end</span>
176
+ 252:
177
+ 253: <span class="ruby-comment cmt"># Return the Rack::Response object</span>
178
+ 254: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">response</span>
179
+ 255: <span class="ruby-ivar">@response</span>
180
+ 256: <span class="ruby-keyword kw">end</span>
181
+ 257:
182
+ 258: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">call</span>( <span class="ruby-identifier">e</span> ) <span class="ruby-comment cmt">#:nodoc:</span>
183
+ 259: <span class="ruby-ivar">@env</span> = <span class="ruby-identifier">e</span>
184
+ 260: <span class="ruby-ivar">@response</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Response</span>.<span class="ruby-identifier">new</span>
185
+ 261: <span class="ruby-ivar">@request</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Request</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@env</span>)
186
+ 262:
187
+ 263: <span class="ruby-comment cmt"># __k = self.class.to_s.split( /::/ )[-1].downcase.to_sym</span>
188
+ 264: <span class="ruby-comment cmt"># @@__FILTERS.each do |f|</span>
189
+ 265: <span class="ruby-comment cmt"># proc = f.delete(:action)</span>
190
+ 266: <span class="ruby-comment cmt"># __run = true</span>
191
+ 267: <span class="ruby-comment cmt"># if f[:only]</span>
192
+ 268: <span class="ruby-comment cmt"># __run = f[:only].include?(__k)</span>
193
+ 269: <span class="ruby-comment cmt"># end</span>
194
+ 270: <span class="ruby-comment cmt"># if f[:except]</span>
195
+ 271: <span class="ruby-comment cmt"># __run = !f[:except].include?(__k)</span>
196
+ 272: <span class="ruby-comment cmt"># end</span>
197
+ 273: <span class="ruby-comment cmt"># </span>
198
+ 274: <span class="ruby-comment cmt"># # proc.call(self) if __run</span>
199
+ 275: <span class="ruby-comment cmt"># puts &quot;call #{proc} for #{__k}&quot;</span>
200
+ 276: <span class="ruby-comment cmt"># end</span>
201
+ 277:
202
+ 278: <span class="ruby-identifier">r</span> = <span class="ruby-keyword kw">case</span> <span class="ruby-ivar">@env</span>[<span class="ruby-value str">&quot;REQUEST_METHOD&quot;</span>]
203
+ 279: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">&quot;GET&quot;</span>
204
+ 280: <span class="ruby-identifier">finalPath</span> = <span class="ruby-keyword kw">nil</span>
205
+ 281: <span class="ruby-identifier">finalArgs</span> = <span class="ruby-keyword kw">nil</span>
206
+ 282: <span class="ruby-identifier">finalNArgs</span> = <span class="ruby-keyword kw">nil</span>
207
+ 283:
208
+ 284: <span class="ruby-identifier">aPath</span> = <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">path</span>.<span class="ruby-identifier">gsub</span>( <span class="ruby-regexp re">/^\//</span>, <span class="ruby-value str">&quot;&quot;</span> ).<span class="ruby-identifier">split</span>( <span class="ruby-value str">&quot;/&quot;</span> )
209
+ 285: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">__urls__</span>[<span class="ruby-value">0</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">r</span><span class="ruby-operator">|</span>
210
+ 286: <span class="ruby-identifier">xPath</span> = <span class="ruby-identifier">p</span>.<span class="ruby-identifier">gsub</span>( <span class="ruby-regexp re">/^\//</span>, <span class="ruby-value str">&quot;&quot;</span> ).<span class="ruby-identifier">split</span>( <span class="ruby-value str">&quot;/&quot;</span> )
211
+ 287: <span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">xPath</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">aPath</span>).<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
212
+ 288: <span class="ruby-identifier">diffArgs</span> = <span class="ruby-identifier">aPath</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">xPath</span>
213
+ 289: <span class="ruby-identifier">diffNArgs</span> = <span class="ruby-identifier">diffArgs</span>.<span class="ruby-identifier">size</span>
214
+ 290: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">finalNArgs</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">finalNArgs</span> <span class="ruby-operator">&gt;</span> <span class="ruby-identifier">diffNArgs</span>
215
+ 291: <span class="ruby-identifier">finalPath</span> = <span class="ruby-identifier">p</span>
216
+ 292: <span class="ruby-identifier">finalNArgs</span> = <span class="ruby-identifier">diffNArgs</span>
217
+ 293: <span class="ruby-identifier">finalArgs</span> = <span class="ruby-identifier">diffArgs</span>
218
+ 294: <span class="ruby-keyword kw">end</span>
219
+ 295: <span class="ruby-keyword kw">end</span>
220
+ 296:
221
+ 297: <span class="ruby-keyword kw">end</span>
222
+ 298:
223
+ 299: <span class="ruby-identifier">nargs</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">__urls__</span>[<span class="ruby-value">1</span>]
224
+ 300: <span class="ruby-identifier">regexp</span> = <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">new</span>( <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">__urls__</span>[<span class="ruby-value">0</span>][<span class="ruby-identifier">finalPath</span>] )
225
+ 301: <span class="ruby-identifier">args</span> = <span class="ruby-identifier">regexp</span>.<span class="ruby-identifier">match</span>( <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Utils</span>.<span class="ruby-identifier">unescape</span>(<span class="ruby-ivar">@request</span>.<span class="ruby-identifier">path</span>).<span class="ruby-identifier">gsub</span>( <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">new</span>( <span class="ruby-node">&quot;^#{finalPath}&quot;</span> ), <span class="ruby-value str">&quot;&quot;</span> ).<span class="ruby-identifier">gsub</span>( <span class="ruby-regexp re">/^\//</span>, <span class="ruby-value str">&quot;&quot;</span> ) )
226
+ 302: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">nil?</span>
227
+ 303: <span class="ruby-identifier">raise</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">ParameterError</span>, <span class="ruby-node">&quot;Path info `#{@request.path_info}' does not match route regexp `#{regexp.source}'&quot;</span>
228
+ 304: <span class="ruby-keyword kw">else</span>
229
+ 305: <span class="ruby-identifier">args</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">captures</span>.<span class="ruby-identifier">map</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">size</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>)<span class="ruby-operator">?</span><span class="ruby-keyword kw">nil</span><span class="ruby-operator">:</span><span class="ruby-identifier">x</span> }
230
+ 306: <span class="ruby-keyword kw">end</span>
231
+ 307:
232
+ 308: <span class="ruby-keyword kw">while</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">&lt;</span> <span class="ruby-identifier">nargs</span>
233
+ 309: <span class="ruby-identifier">args</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-keyword kw">nil</span>
234
+ 310: <span class="ruby-keyword kw">end</span>
235
+ 311:
236
+ 312: <span class="ruby-identifier">get</span>( <span class="ruby-operator">*</span><span class="ruby-identifier">args</span> )
237
+ 313: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">&quot;POST&quot;</span>
238
+ 314: <span class="ruby-identifier">post</span>
239
+ 315: <span class="ruby-keyword kw">end</span>
240
+ 316: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">r</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:to_ary</span>)
241
+ 317: <span class="ruby-ivar">@response</span>.<span class="ruby-identifier">status</span> = <span class="ruby-identifier">r</span>[<span class="ruby-value">0</span>]
242
+ 318: <span class="ruby-identifier">r</span>[<span class="ruby-value">1</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
243
+ 319: <span class="ruby-ivar">@response</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-identifier">v</span>
244
+ 320: <span class="ruby-keyword kw">end</span>
245
+ 321: <span class="ruby-ivar">@response</span>.<span class="ruby-identifier">body</span> = <span class="ruby-identifier">r</span>[<span class="ruby-value">2</span>]
246
+ 322: <span class="ruby-keyword kw">else</span>
247
+ 323: <span class="ruby-ivar">@response</span>.<span class="ruby-identifier">write</span> <span class="ruby-identifier">r</span>
248
+ 324: <span class="ruby-keyword kw">end</span>
249
+ 325:
250
+ 326: <span class="ruby-ivar">@response</span>.<span class="ruby-identifier">finish</span>
251
+ 327: <span class="ruby-keyword kw">end</span>
252
+ 328:
253
+ 329: <span class="ruby-identifier">include</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Helpers</span>
254
+ 330: <span class="ruby-identifier">include</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Views</span>
255
+ 331: }
256
+ 332: <span class="ruby-keyword kw">end</span>
257
257
  </pre>
258
258
  </div>
259
259
  </div>
@@ -268,10 +268,10 @@ Hash containing all the environment variables
268
268
  <p class="source-link">[ <a href="javascript:toggleSource('M000003_source')" id="l_M000003_source">show source</a> ]</p>
269
269
  <div id="M000003_source" class="dyn-source">
270
270
  <pre>
271
- <span class="ruby-comment cmt"># File lib/capcode.rb, line 231</span>
272
- 231: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">env</span>
273
- 232: <span class="ruby-ivar">@env</span>
274
- 233: <span class="ruby-keyword kw">end</span>
271
+ <span class="ruby-comment cmt"># File lib/capcode.rb, line 239</span>
272
+ 239: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">env</span>
273
+ 240: <span class="ruby-ivar">@env</span>
274
+ 241: <span class="ruby-keyword kw">end</span>
275
275
  </pre>
276
276
  </div>
277
277
  </div>
@@ -292,10 +292,10 @@ Rack or What you want Helper
292
292
  <p class="source-link">[ <a href="javascript:toggleSource('M000007_source')" id="l_M000007_source">show source</a> ]</p>
293
293
  <div id="M000007_source" class="dyn-source">
294
294
  <pre>
295
- <span class="ruby-comment cmt"># File lib/capcode.rb, line 331</span>
296
- 331: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">map</span>( <span class="ruby-identifier">r</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span> )
297
- 332: <span class="ruby-ivar">@@__ROUTES</span>[<span class="ruby-identifier">r</span>] = <span class="ruby-keyword kw">yield</span>
298
- 333: <span class="ruby-keyword kw">end</span>
295
+ <span class="ruby-comment cmt"># File lib/capcode.rb, line 339</span>
296
+ 339: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">map</span>( <span class="ruby-identifier">r</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span> )
297
+ 340: <span class="ruby-ivar">@@__ROUTES</span>[<span class="ruby-identifier">r</span>] = <span class="ruby-keyword kw">yield</span>
298
+ 341: <span class="ruby-keyword kw">end</span>
299
299
  </pre>
300
300
  </div>
301
301
  </div>
@@ -311,10 +311,10 @@ parameters (GET or POST)
311
311
  <p class="source-link">[ <a href="javascript:toggleSource('M000002_source')" id="l_M000002_source">show source</a> ]</p>
312
312
  <div id="M000002_source" class="dyn-source">
313
313
  <pre>
314
- <span class="ruby-comment cmt"># File lib/capcode.rb, line 226</span>
315
- 226: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">params</span>
316
- 227: <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">params</span>
317
- 228: <span class="ruby-keyword kw">end</span>
314
+ <span class="ruby-comment cmt"># File lib/capcode.rb, line 234</span>
315
+ 234: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">params</span>
316
+ 235: <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">params</span>
317
+ 236: <span class="ruby-keyword kw">end</span>
318
318
  </pre>
319
319
  </div>
320
320
  </div>
@@ -329,10 +329,10 @@ Return the Rack::Request object
329
329
  <p class="source-link">[ <a href="javascript:toggleSource('M000005_source')" id="l_M000005_source">show source</a> ]</p>
330
330
  <div id="M000005_source" class="dyn-source">
331
331
  <pre>
332
- <span class="ruby-comment cmt"># File lib/capcode.rb, line 241</span>
333
- 241: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">request</span>
334
- 242: <span class="ruby-ivar">@request</span>
335
- 243: <span class="ruby-keyword kw">end</span>
332
+ <span class="ruby-comment cmt"># File lib/capcode.rb, line 249</span>
333
+ 249: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">request</span>
334
+ 250: <span class="ruby-ivar">@request</span>
335
+ 251: <span class="ruby-keyword kw">end</span>
336
336
  </pre>
337
337
  </div>
338
338
  </div>
@@ -347,10 +347,10 @@ Return the Rack::Response object
347
347
  <p class="source-link">[ <a href="javascript:toggleSource('M000006_source')" id="l_M000006_source">show source</a> ]</p>
348
348
  <div id="M000006_source" class="dyn-source">
349
349
  <pre>
350
- <span class="ruby-comment cmt"># File lib/capcode.rb, line 246</span>
351
- 246: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">response</span>
352
- 247: <span class="ruby-ivar">@response</span>
353
- 248: <span class="ruby-keyword kw">end</span>
350
+ <span class="ruby-comment cmt"># File lib/capcode.rb, line 254</span>
351
+ 254: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">response</span>
352
+ 255: <span class="ruby-ivar">@response</span>
353
+ 256: <span class="ruby-keyword kw">end</span>
354
354
  </pre>
355
355
  </div>
356
356
  </div>
@@ -403,177 +403,177 @@ This is also the working directory !
403
403
  <p class="source-link">[ <a href="javascript:toggleSource('M000008_source')" id="l_M000008_source">show source</a> ]</p>
404
404
  <div id="M000008_source" class="dyn-source">
405
405
  <pre>
406
- <span class="ruby-comment cmt"># File lib/capcode.rb, line 348</span>
407
- 348: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">run</span>( <span class="ruby-identifier">args</span> = {} )
408
- 349: <span class="ruby-identifier">__VERBOSE</span> = <span class="ruby-keyword kw">false</span>
409
- 350:
410
- 351: <span class="ruby-identifier">conf</span> = {
411
- 352: <span class="ruby-identifier">:port</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:port</span>]<span class="ruby-operator">||</span><span class="ruby-value">3000</span>,
412
- 353: <span class="ruby-identifier">:host</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:host</span>]<span class="ruby-operator">||</span><span class="ruby-value str">&quot;localhost&quot;</span>,
413
- 354: <span class="ruby-identifier">:server</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:server</span>]<span class="ruby-operator">||</span><span class="ruby-keyword kw">nil</span>,
414
- 355: <span class="ruby-identifier">:log</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:log</span>]<span class="ruby-operator">||</span><span class="ruby-identifier">$stdout</span>,
415
- 356: <span class="ruby-identifier">:session</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:session</span>]<span class="ruby-operator">||</span>{},
416
- 357: <span class="ruby-identifier">:pid</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:pid</span>]<span class="ruby-operator">||</span><span class="ruby-node">&quot;#{$0}.pid&quot;</span>,
417
- 358: <span class="ruby-identifier">:daemonize</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:daemonize</span>]<span class="ruby-operator">||</span><span class="ruby-keyword kw">false</span>,
418
- 359: <span class="ruby-identifier">:db_config</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:db_config</span>]<span class="ruby-operator">||</span><span class="ruby-value str">&quot;database.yml&quot;</span>,
419
- 360: <span class="ruby-identifier">:static</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:static</span>]<span class="ruby-operator">||</span><span class="ruby-keyword kw">nil</span>,
420
- 361: <span class="ruby-identifier">:root</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:root</span>]<span class="ruby-operator">||</span><span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">dirname</span>(<span class="ruby-identifier">$0</span>)),
421
- 362:
422
- 363: <span class="ruby-identifier">:console</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">false</span>
423
- 364: }
424
- 365:
425
- 366: <span class="ruby-comment cmt"># Parse options</span>
426
- 367: <span class="ruby-identifier">opts</span> = <span class="ruby-constant">OptionParser</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">opts</span><span class="ruby-operator">|</span>
427
- 368: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">banner</span> = <span class="ruby-node">&quot;Usage: #{File.basename($0)} [options]&quot;</span>
428
- 369: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">separator</span> <span class="ruby-value str">&quot;&quot;</span>
429
- 370: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">separator</span> <span class="ruby-value str">&quot;Specific options:&quot;</span>
430
- 371:
431
- 372: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>( <span class="ruby-value str">&quot;-C&quot;</span>, <span class="ruby-value str">&quot;--console&quot;</span>, <span class="ruby-value str">&quot;Run in console mode with IRB (default: false)&quot;</span> ) {
432
- 373: <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:console</span>] = <span class="ruby-keyword kw">true</span>
433
- 374: }
434
- 375: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>( <span class="ruby-value str">&quot;-h&quot;</span>, <span class="ruby-value str">&quot;--host HOSTNAME&quot;</span>, <span class="ruby-node">&quot;Host for web server to bind to (default: #{conf[:host]})&quot;</span> ) { <span class="ruby-operator">|</span><span class="ruby-identifier">h</span><span class="ruby-operator">|</span>
435
- 376: <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:host</span>] = <span class="ruby-identifier">h</span>
436
- 377: }
437
- 378: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>( <span class="ruby-value str">&quot;-p&quot;</span>, <span class="ruby-value str">&quot;--port NUM&quot;</span>, <span class="ruby-node">&quot;Port for web server (default: #{conf[:port]})&quot;</span> ) { <span class="ruby-operator">|</span><span class="ruby-identifier">p</span><span class="ruby-operator">|</span>
438
- 379: <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:port</span>] = <span class="ruby-identifier">p</span>
439
- 380: }
440
- 381: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>( <span class="ruby-value str">&quot;-d&quot;</span>, <span class="ruby-value str">&quot;--daemonize [true|false]&quot;</span>, <span class="ruby-node">&quot;Daemonize (default: #{conf[:daemonize]})&quot;</span> ) { <span class="ruby-operator">|</span><span class="ruby-identifier">d</span><span class="ruby-operator">|</span>
441
- 382: <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:daemonize</span>] = <span class="ruby-identifier">d</span>
442
- 383: }
443
- 384: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>( <span class="ruby-value str">&quot;-r&quot;</span>, <span class="ruby-value str">&quot;--root PATH&quot;</span>, <span class="ruby-node">&quot;Working directory (default: #{conf[:root]})&quot;</span> ) { <span class="ruby-operator">|</span><span class="ruby-identifier">w</span><span class="ruby-operator">|</span>
444
- 385: <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:root</span>] = <span class="ruby-identifier">w</span>
445
- 386: }
446
- 387: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>( <span class="ruby-value str">&quot;-s&quot;</span>, <span class="ruby-value str">&quot;--static PATH&quot;</span>, <span class="ruby-node">&quot;Static directory -- relative to the root directory (default: #{conf[:static]})&quot;</span> ) { <span class="ruby-operator">|</span><span class="ruby-identifier">r</span><span class="ruby-operator">|</span>
447
- 388: <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:static</span>] = <span class="ruby-identifier">r</span>
448
- 389: }
449
- 390:
450
- 391: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">separator</span> <span class="ruby-value str">&quot;&quot;</span>
451
- 392: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">separator</span> <span class="ruby-value str">&quot;Common options:&quot;</span>
452
- 393:
453
- 394: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-value str">&quot;-?&quot;</span>, <span class="ruby-value str">&quot;--help&quot;</span>, <span class="ruby-value str">&quot;Show this message&quot;</span>) <span class="ruby-keyword kw">do</span>
454
- 395: <span class="ruby-identifier">puts</span> <span class="ruby-identifier">opts</span>
455
- 396: <span class="ruby-identifier">exit</span>
456
- 397: <span class="ruby-keyword kw">end</span>
457
- 398: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-value str">&quot;-v&quot;</span>, <span class="ruby-value str">&quot;--version&quot;</span>, <span class="ruby-value str">&quot;Show versions&quot;</span>) <span class="ruby-keyword kw">do</span>
458
- 399: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Capcode version #{Capcode::CAPCOD_VERION} (ruby v#{RUBY_VERSION})&quot;</span>
459
- 400: <span class="ruby-identifier">exit</span>
460
- 401: <span class="ruby-keyword kw">end</span>
461
- 402: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on_tail</span>( <span class="ruby-value str">&quot;-V&quot;</span>, <span class="ruby-value str">&quot;--verbose&quot;</span>, <span class="ruby-value str">&quot;Run in verbose mode&quot;</span> ) <span class="ruby-keyword kw">do</span>
462
- 403: <span class="ruby-identifier">__VERBOSE</span> = <span class="ruby-keyword kw">true</span>
463
- 404: <span class="ruby-keyword kw">end</span>
464
- 405: <span class="ruby-keyword kw">end</span>
465
- 406:
466
- 407: <span class="ruby-keyword kw">begin</span>
467
- 408: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">parse!</span> <span class="ruby-constant">ARGV</span>
468
- 409: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">OptionParser</span><span class="ruby-operator">::</span><span class="ruby-constant">ParseError</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">ex</span>
469
- 410: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;!! #{ex.message}&quot;</span>
470
- 411: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;** use `#{File.basename($0)} --help` for more details...&quot;</span>
471
- 412: <span class="ruby-identifier">exit</span> <span class="ruby-value">1</span>
406
+ <span class="ruby-comment cmt"># File lib/capcode.rb, line 356</span>
407
+ 356: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">run</span>( <span class="ruby-identifier">args</span> = {} )
408
+ 357: <span class="ruby-identifier">__VERBOSE</span> = <span class="ruby-keyword kw">false</span>
409
+ 358:
410
+ 359: <span class="ruby-identifier">conf</span> = {
411
+ 360: <span class="ruby-identifier">:port</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:port</span>]<span class="ruby-operator">||</span><span class="ruby-value">3000</span>,
412
+ 361: <span class="ruby-identifier">:host</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:host</span>]<span class="ruby-operator">||</span><span class="ruby-value str">&quot;localhost&quot;</span>,
413
+ 362: <span class="ruby-identifier">:server</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:server</span>]<span class="ruby-operator">||</span><span class="ruby-keyword kw">nil</span>,
414
+ 363: <span class="ruby-identifier">:log</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:log</span>]<span class="ruby-operator">||</span><span class="ruby-identifier">$stdout</span>,
415
+ 364: <span class="ruby-identifier">:session</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:session</span>]<span class="ruby-operator">||</span>{},
416
+ 365: <span class="ruby-identifier">:pid</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:pid</span>]<span class="ruby-operator">||</span><span class="ruby-node">&quot;#{$0}.pid&quot;</span>,
417
+ 366: <span class="ruby-identifier">:daemonize</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:daemonize</span>]<span class="ruby-operator">||</span><span class="ruby-keyword kw">false</span>,
418
+ 367: <span class="ruby-identifier">:db_config</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-identifier">args</span>[<span class="ruby-identifier">:db_config</span>]<span class="ruby-operator">||</span><span class="ruby-value str">&quot;database.yml&quot;</span>),
419
+ 368: <span class="ruby-identifier">:static</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:static</span>]<span class="ruby-operator">||</span><span class="ruby-keyword kw">nil</span>,
420
+ 369: <span class="ruby-identifier">:root</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:root</span>]<span class="ruby-operator">||</span><span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">dirname</span>(<span class="ruby-identifier">$0</span>)),
421
+ 370:
422
+ 371: <span class="ruby-identifier">:console</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">false</span>
423
+ 372: }
424
+ 373:
425
+ 374: <span class="ruby-comment cmt"># Parse options</span>
426
+ 375: <span class="ruby-identifier">opts</span> = <span class="ruby-constant">OptionParser</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">opts</span><span class="ruby-operator">|</span>
427
+ 376: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">banner</span> = <span class="ruby-node">&quot;Usage: #{File.basename($0)} [options]&quot;</span>
428
+ 377: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">separator</span> <span class="ruby-value str">&quot;&quot;</span>
429
+ 378: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">separator</span> <span class="ruby-value str">&quot;Specific options:&quot;</span>
430
+ 379:
431
+ 380: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>( <span class="ruby-value str">&quot;-C&quot;</span>, <span class="ruby-value str">&quot;--console&quot;</span>, <span class="ruby-value str">&quot;Run in console mode with IRB (default: false)&quot;</span> ) {
432
+ 381: <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:console</span>] = <span class="ruby-keyword kw">true</span>
433
+ 382: }
434
+ 383: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>( <span class="ruby-value str">&quot;-h&quot;</span>, <span class="ruby-value str">&quot;--host HOSTNAME&quot;</span>, <span class="ruby-node">&quot;Host for web server to bind to (default: #{conf[:host]})&quot;</span> ) { <span class="ruby-operator">|</span><span class="ruby-identifier">h</span><span class="ruby-operator">|</span>
435
+ 384: <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:host</span>] = <span class="ruby-identifier">h</span>
436
+ 385: }
437
+ 386: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>( <span class="ruby-value str">&quot;-p&quot;</span>, <span class="ruby-value str">&quot;--port NUM&quot;</span>, <span class="ruby-node">&quot;Port for web server (default: #{conf[:port]})&quot;</span> ) { <span class="ruby-operator">|</span><span class="ruby-identifier">p</span><span class="ruby-operator">|</span>
438
+ 387: <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:port</span>] = <span class="ruby-identifier">p</span>
439
+ 388: }
440
+ 389: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>( <span class="ruby-value str">&quot;-d&quot;</span>, <span class="ruby-value str">&quot;--daemonize [true|false]&quot;</span>, <span class="ruby-node">&quot;Daemonize (default: #{conf[:daemonize]})&quot;</span> ) { <span class="ruby-operator">|</span><span class="ruby-identifier">d</span><span class="ruby-operator">|</span>
441
+ 390: <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:daemonize</span>] = <span class="ruby-identifier">d</span>
442
+ 391: }
443
+ 392: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>( <span class="ruby-value str">&quot;-r&quot;</span>, <span class="ruby-value str">&quot;--root PATH&quot;</span>, <span class="ruby-node">&quot;Working directory (default: #{conf[:root]})&quot;</span> ) { <span class="ruby-operator">|</span><span class="ruby-identifier">w</span><span class="ruby-operator">|</span>
444
+ 393: <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:root</span>] = <span class="ruby-identifier">w</span>
445
+ 394: }
446
+ 395: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>( <span class="ruby-value str">&quot;-s&quot;</span>, <span class="ruby-value str">&quot;--static PATH&quot;</span>, <span class="ruby-node">&quot;Static directory -- relative to the root directory (default: #{conf[:static]})&quot;</span> ) { <span class="ruby-operator">|</span><span class="ruby-identifier">r</span><span class="ruby-operator">|</span>
447
+ 396: <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:static</span>] = <span class="ruby-identifier">r</span>
448
+ 397: }
449
+ 398:
450
+ 399: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">separator</span> <span class="ruby-value str">&quot;&quot;</span>
451
+ 400: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">separator</span> <span class="ruby-value str">&quot;Common options:&quot;</span>
452
+ 401:
453
+ 402: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-value str">&quot;-?&quot;</span>, <span class="ruby-value str">&quot;--help&quot;</span>, <span class="ruby-value str">&quot;Show this message&quot;</span>) <span class="ruby-keyword kw">do</span>
454
+ 403: <span class="ruby-identifier">puts</span> <span class="ruby-identifier">opts</span>
455
+ 404: <span class="ruby-identifier">exit</span>
456
+ 405: <span class="ruby-keyword kw">end</span>
457
+ 406: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-value str">&quot;-v&quot;</span>, <span class="ruby-value str">&quot;--version&quot;</span>, <span class="ruby-value str">&quot;Show versions&quot;</span>) <span class="ruby-keyword kw">do</span>
458
+ 407: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Capcode version #{Capcode::CAPCOD_VERION} (ruby v#{RUBY_VERSION})&quot;</span>
459
+ 408: <span class="ruby-identifier">exit</span>
460
+ 409: <span class="ruby-keyword kw">end</span>
461
+ 410: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on_tail</span>( <span class="ruby-value str">&quot;-V&quot;</span>, <span class="ruby-value str">&quot;--verbose&quot;</span>, <span class="ruby-value str">&quot;Run in verbose mode&quot;</span> ) <span class="ruby-keyword kw">do</span>
462
+ 411: <span class="ruby-identifier">__VERBOSE</span> = <span class="ruby-keyword kw">true</span>
463
+ 412: <span class="ruby-keyword kw">end</span>
472
464
  413: <span class="ruby-keyword kw">end</span>
473
465
  414:
474
- 415: <span class="ruby-comment cmt"># Run in the Working directory</span>
475
- 416: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;** Go on root directory (#{File.expand_path(conf[:root])})&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">__VERBOSE</span>
476
- 417: <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">chdir</span>( <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:root</span>] ) <span class="ruby-keyword kw">do</span>
477
- 418:
478
- 419: <span class="ruby-comment cmt"># Check that mongrel exists </span>
479
- 420: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:server</span>].<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:server</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;mongrel&quot;</span>
480
- 421: <span class="ruby-keyword kw">begin</span>
481
- 422: <span class="ruby-identifier">require</span> <span class="ruby-value str">'mongrel'</span>
482
- 423: <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:server</span>] = <span class="ruby-value str">&quot;mongrel&quot;</span>
483
- 424: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">LoadError</span>
484
- 425: <span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot;!! could not load mongrel. Falling back to webrick.&quot;</span>
485
- 426: <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:server</span>] = <span class="ruby-value str">&quot;webrick&quot;</span>
486
- 427: <span class="ruby-keyword kw">end</span>
487
- 428: <span class="ruby-keyword kw">end</span>
488
- 429:
489
- 430: <span class="ruby-constant">Capcode</span>.<span class="ruby-identifier">constants</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span><span class="ruby-operator">|</span>
490
- 431: <span class="ruby-keyword kw">begin</span>
491
- 432: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">eval</span> <span class="ruby-node">&quot;Capcode::#{k}.public_methods(true).include?( '__urls__' )&quot;</span>
492
- 433: <span class="ruby-identifier">u</span>, <span class="ruby-identifier">m</span>, <span class="ruby-identifier">c</span> = <span class="ruby-identifier">eval</span> <span class="ruby-node">&quot;Capcode::#{k}.__urls__&quot;</span>
493
- 434: <span class="ruby-identifier">u</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">_u</span><span class="ruby-operator">|</span>
494
- 435: <span class="ruby-identifier">raise</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">RouteError</span>, <span class="ruby-node">&quot;Route `#{_u}' already define !&quot;</span>, <span class="ruby-identifier">caller</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@@__ROUTES</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">_u</span>)
495
- 436: <span class="ruby-ivar">@@__ROUTES</span>[<span class="ruby-identifier">_u</span>] = <span class="ruby-identifier">c</span>.<span class="ruby-identifier">new</span>
496
- 437: <span class="ruby-keyword kw">end</span>
497
- 438: <span class="ruby-keyword kw">end</span>
498
- 439: <span class="ruby-keyword kw">rescue</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
499
- 440: <span class="ruby-identifier">raise</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">message</span>
500
- 441: <span class="ruby-keyword kw">end</span>
501
- 442: <span class="ruby-keyword kw">end</span>
502
- 443:
503
- 444: <span class="ruby-comment cmt"># Set Static directory</span>
504
- 445: <span class="ruby-ivar">@@__STATIC_DIR</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-value str">&quot;/&quot;</span>, <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:static</span>])) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:static</span>].<span class="ruby-identifier">nil?</span>
505
- 446:
506
- 447: <span class="ruby-comment cmt"># Initialize Rack App</span>
507
- 448: <span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot;** Map routes.&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">__VERBOSE</span>
508
- 449: <span class="ruby-identifier">app</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">URLMap</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@@__ROUTES</span>)
509
- 450: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;** Initialize static directory (#{conf[:static]})&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">__VERBOSE</span>
510
- 451: <span class="ruby-identifier">app</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Static</span>.<span class="ruby-identifier">new</span>(
511
- 452: <span class="ruby-identifier">app</span>,
512
- 453: <span class="ruby-identifier">:urls</span> =<span class="ruby-operator">&gt;</span> [<span class="ruby-ivar">@@__STATIC_DIR</span>],
513
- 454: <span class="ruby-identifier">:root</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:root</span>])
514
- 455: ) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:static</span>].<span class="ruby-identifier">nil?</span>
515
- 456: <span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot;** Initialize session&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">__VERBOSE</span>
516
- 457: <span class="ruby-identifier">app</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Session</span><span class="ruby-operator">::</span><span class="ruby-constant">Cookie</span>.<span class="ruby-identifier">new</span>( <span class="ruby-identifier">app</span>, <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:session</span>] )
517
- 458: <span class="ruby-identifier">app</span> = <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTPError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">app</span>)
518
- 459: <span class="ruby-identifier">app</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">ContentLength</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">app</span>)
519
- 460: <span class="ruby-identifier">app</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Lint</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">app</span>)
520
- 461: <span class="ruby-identifier">app</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">ShowExceptions</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">app</span>)
521
- 462: <span class="ruby-comment cmt"># app = Rack::Reloader.new(app) ## -- NE RELOAD QUE capcode.rb -- So !!!</span>
522
- 463: <span class="ruby-identifier">app</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">CommonLogger</span>.<span class="ruby-identifier">new</span>( <span class="ruby-identifier">app</span>, <span class="ruby-constant">Logger</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:log</span>]) )
523
- 464:
524
- 465: <span class="ruby-comment cmt"># From rackup !!!</span>
525
- 466: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:daemonize</span>]
526
- 467: <span class="ruby-keyword kw">if</span> <span class="ruby-regexp re">/java/</span>.<span class="ruby-identifier">match</span>(<span class="ruby-constant">RUBY_PLATFORM</span>).<span class="ruby-identifier">nil?</span>
527
- 468: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">RUBY_VERSION</span> <span class="ruby-operator">&lt;</span> <span class="ruby-value str">&quot;1.9&quot;</span>
528
- 469: <span class="ruby-identifier">exit</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">fork</span>
529
- 470: <span class="ruby-constant">Process</span>.<span class="ruby-identifier">setsid</span>
530
- 471: <span class="ruby-identifier">exit</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">fork</span>
531
- 472: <span class="ruby-comment cmt"># Dir.chdir &quot;/&quot;</span>
532
- 473: <span class="ruby-constant">File</span>.<span class="ruby-identifier">umask</span> <span class="ruby-value">0000</span>
533
- 474: <span class="ruby-constant">STDIN</span>.<span class="ruby-identifier">reopen</span> <span class="ruby-value str">&quot;/dev/null&quot;</span>
534
- 475: <span class="ruby-constant">STDOUT</span>.<span class="ruby-identifier">reopen</span> <span class="ruby-value str">&quot;/dev/null&quot;</span>, <span class="ruby-value str">&quot;a&quot;</span>
535
- 476: <span class="ruby-constant">STDERR</span>.<span class="ruby-identifier">reopen</span> <span class="ruby-value str">&quot;/dev/null&quot;</span>, <span class="ruby-value str">&quot;a&quot;</span>
536
- 477: <span class="ruby-keyword kw">else</span>
537
- 478: <span class="ruby-constant">Process</span>.<span class="ruby-identifier">daemon</span>
538
- 479: <span class="ruby-keyword kw">end</span>
539
- 480: <span class="ruby-keyword kw">else</span>
540
- 481: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;!! daemonize option unavailable on #{RUBY_PLATFORM} platform.&quot;</span>
541
- 482: <span class="ruby-keyword kw">end</span>
542
- 483:
543
- 484: <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:pid</span>], <span class="ruby-value str">'w'</span>){ <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span> <span class="ruby-identifier">f</span>.<span class="ruby-identifier">write</span>(<span class="ruby-node">&quot;#{Process.pid}&quot;</span>) }
544
- 485: <span class="ruby-identifier">at_exit</span> { <span class="ruby-constant">File</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:pid</span>]) <span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:pid</span>]) }
545
- 486: <span class="ruby-keyword kw">end</span>
546
- 487:
547
- 488: <span class="ruby-comment cmt"># Start database</span>
548
- 489: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">methods</span>.<span class="ruby-identifier">include?</span> <span class="ruby-value str">&quot;db_connect&quot;</span>
549
- 490: <span class="ruby-identifier">db_connect</span>( <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:db_config</span>], <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:log</span>] )
550
- 491: <span class="ruby-keyword kw">end</span>
551
- 492:
552
- 493: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
553
- 494: <span class="ruby-keyword kw">yield</span>( <span class="ruby-keyword kw">self</span> )
554
- 495: <span class="ruby-keyword kw">end</span>
555
- 496:
556
- 497: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:console</span>]
557
- 498: <span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot;Run console...&quot;</span>
558
- 499: <span class="ruby-constant">IRB</span>.<span class="ruby-identifier">start</span>
559
- 500: <span class="ruby-identifier">exit</span>
560
- 501: <span class="ruby-keyword kw">end</span>
561
- 502:
562
- 503: <span class="ruby-comment cmt"># Start server</span>
563
- 504: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:server</span>]
564
- 505: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">&quot;mongrel&quot;</span>
565
- 506: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;** Starting Mongrel on #{conf[:host]}:#{conf[:port]}&quot;</span>
566
- 507: <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Handler</span><span class="ruby-operator">::</span><span class="ruby-constant">Mongrel</span>.<span class="ruby-identifier">run</span>( <span class="ruby-identifier">app</span>, {<span class="ruby-identifier">:Port</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:port</span>], <span class="ruby-identifier">:Host</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:host</span>]} ) { <span class="ruby-operator">|</span><span class="ruby-identifier">server</span><span class="ruby-operator">|</span>
567
- 508: <span class="ruby-identifier">trap</span> <span class="ruby-value str">&quot;SIGINT&quot;</span>, <span class="ruby-identifier">proc</span> { <span class="ruby-identifier">server</span>.<span class="ruby-identifier">stop</span> }
568
- 509: }
569
- 510: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">&quot;webrick&quot;</span>
570
- 511: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;** Starting WEBrick on #{conf[:host]}:#{conf[:port]}&quot;</span>
571
- 512: <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Handler</span><span class="ruby-operator">::</span><span class="ruby-constant">WEBrick</span>.<span class="ruby-identifier">run</span>( <span class="ruby-identifier">app</span>, {<span class="ruby-identifier">:Port</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:port</span>], <span class="ruby-identifier">:BindAddress</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:host</span>]} ) { <span class="ruby-operator">|</span><span class="ruby-identifier">server</span><span class="ruby-operator">|</span>
572
- 513: <span class="ruby-identifier">trap</span> <span class="ruby-value str">&quot;SIGINT&quot;</span>, <span class="ruby-identifier">proc</span> { <span class="ruby-identifier">server</span>.<span class="ruby-identifier">shutdown</span> }
573
- 514: }
574
- 515: <span class="ruby-keyword kw">end</span>
575
- 516: <span class="ruby-keyword kw">end</span>
576
- 517: <span class="ruby-keyword kw">end</span>
466
+ 415: <span class="ruby-keyword kw">begin</span>
467
+ 416: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">parse!</span> <span class="ruby-constant">ARGV</span>
468
+ 417: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">OptionParser</span><span class="ruby-operator">::</span><span class="ruby-constant">ParseError</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">ex</span>
469
+ 418: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;!! #{ex.message}&quot;</span>
470
+ 419: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;** use `#{File.basename($0)} --help` for more details...&quot;</span>
471
+ 420: <span class="ruby-identifier">exit</span> <span class="ruby-value">1</span>
472
+ 421: <span class="ruby-keyword kw">end</span>
473
+ 422:
474
+ 423: <span class="ruby-comment cmt"># Run in the Working directory</span>
475
+ 424: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;** Go on root directory (#{File.expand_path(conf[:root])})&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">__VERBOSE</span>
476
+ 425: <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">chdir</span>( <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:root</span>] ) <span class="ruby-keyword kw">do</span>
477
+ 426:
478
+ 427: <span class="ruby-comment cmt"># Check that mongrel exists </span>
479
+ 428: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:server</span>].<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:server</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;mongrel&quot;</span>
480
+ 429: <span class="ruby-keyword kw">begin</span>
481
+ 430: <span class="ruby-identifier">require</span> <span class="ruby-value str">'mongrel'</span>
482
+ 431: <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:server</span>] = <span class="ruby-value str">&quot;mongrel&quot;</span>
483
+ 432: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">LoadError</span>
484
+ 433: <span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot;!! could not load mongrel. Falling back to webrick.&quot;</span>
485
+ 434: <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:server</span>] = <span class="ruby-value str">&quot;webrick&quot;</span>
486
+ 435: <span class="ruby-keyword kw">end</span>
487
+ 436: <span class="ruby-keyword kw">end</span>
488
+ 437:
489
+ 438: <span class="ruby-constant">Capcode</span>.<span class="ruby-identifier">constants</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span><span class="ruby-operator">|</span>
490
+ 439: <span class="ruby-keyword kw">begin</span>
491
+ 440: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">eval</span> <span class="ruby-node">&quot;Capcode::#{k}.public_methods(true).include?( '__urls__' )&quot;</span>
492
+ 441: <span class="ruby-identifier">u</span>, <span class="ruby-identifier">m</span>, <span class="ruby-identifier">c</span> = <span class="ruby-identifier">eval</span> <span class="ruby-node">&quot;Capcode::#{k}.__urls__&quot;</span>
493
+ 442: <span class="ruby-identifier">u</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">_u</span><span class="ruby-operator">|</span>
494
+ 443: <span class="ruby-identifier">raise</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">RouteError</span>, <span class="ruby-node">&quot;Route `#{_u}' already define !&quot;</span>, <span class="ruby-identifier">caller</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@@__ROUTES</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">_u</span>)
495
+ 444: <span class="ruby-ivar">@@__ROUTES</span>[<span class="ruby-identifier">_u</span>] = <span class="ruby-identifier">c</span>.<span class="ruby-identifier">new</span>
496
+ 445: <span class="ruby-keyword kw">end</span>
497
+ 446: <span class="ruby-keyword kw">end</span>
498
+ 447: <span class="ruby-keyword kw">rescue</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
499
+ 448: <span class="ruby-identifier">raise</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">message</span>
500
+ 449: <span class="ruby-keyword kw">end</span>
501
+ 450: <span class="ruby-keyword kw">end</span>
502
+ 451:
503
+ 452: <span class="ruby-comment cmt"># Set Static directory</span>
504
+ 453: <span class="ruby-ivar">@@__STATIC_DIR</span> = (<span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:static</span>][<span class="ruby-value">0</span>].<span class="ruby-identifier">chr</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;/&quot;</span>)<span class="ruby-operator">?</span><span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:static</span>]<span class="ruby-operator">:</span><span class="ruby-value str">&quot;/&quot;</span><span class="ruby-operator">+</span><span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:static</span>] <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:static</span>].<span class="ruby-identifier">nil?</span>
505
+ 454:
506
+ 455: <span class="ruby-comment cmt"># Initialize Rack App</span>
507
+ 456: <span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot;** Map routes.&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">__VERBOSE</span>
508
+ 457: <span class="ruby-identifier">app</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">URLMap</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@@__ROUTES</span>)
509
+ 458: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;** Initialize static directory (#{conf[:static]})&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">__VERBOSE</span>
510
+ 459: <span class="ruby-identifier">app</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Static</span>.<span class="ruby-identifier">new</span>(
511
+ 460: <span class="ruby-identifier">app</span>,
512
+ 461: <span class="ruby-identifier">:urls</span> =<span class="ruby-operator">&gt;</span> [<span class="ruby-ivar">@@__STATIC_DIR</span>],
513
+ 462: <span class="ruby-identifier">:root</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:root</span>])
514
+ 463: ) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:static</span>].<span class="ruby-identifier">nil?</span>
515
+ 464: <span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot;** Initialize session&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">__VERBOSE</span>
516
+ 465: <span class="ruby-identifier">app</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Session</span><span class="ruby-operator">::</span><span class="ruby-constant">Cookie</span>.<span class="ruby-identifier">new</span>( <span class="ruby-identifier">app</span>, <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:session</span>] )
517
+ 466: <span class="ruby-identifier">app</span> = <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTPError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">app</span>)
518
+ 467: <span class="ruby-identifier">app</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">ContentLength</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">app</span>)
519
+ 468: <span class="ruby-identifier">app</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Lint</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">app</span>)
520
+ 469: <span class="ruby-identifier">app</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">ShowExceptions</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">app</span>)
521
+ 470: <span class="ruby-comment cmt"># app = Rack::Reloader.new(app) ## -- NE RELOAD QUE capcode.rb -- So !!!</span>
522
+ 471: <span class="ruby-identifier">app</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">CommonLogger</span>.<span class="ruby-identifier">new</span>( <span class="ruby-identifier">app</span>, <span class="ruby-constant">Logger</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:log</span>]) )
523
+ 472:
524
+ 473: <span class="ruby-comment cmt"># From rackup !!!</span>
525
+ 474: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:daemonize</span>]
526
+ 475: <span class="ruby-keyword kw">if</span> <span class="ruby-regexp re">/java/</span>.<span class="ruby-identifier">match</span>(<span class="ruby-constant">RUBY_PLATFORM</span>).<span class="ruby-identifier">nil?</span>
527
+ 476: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">RUBY_VERSION</span> <span class="ruby-operator">&lt;</span> <span class="ruby-value str">&quot;1.9&quot;</span>
528
+ 477: <span class="ruby-identifier">exit</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">fork</span>
529
+ 478: <span class="ruby-constant">Process</span>.<span class="ruby-identifier">setsid</span>
530
+ 479: <span class="ruby-identifier">exit</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">fork</span>
531
+ 480: <span class="ruby-comment cmt"># Dir.chdir &quot;/&quot;</span>
532
+ 481: <span class="ruby-constant">File</span>.<span class="ruby-identifier">umask</span> <span class="ruby-value">0000</span>
533
+ 482: <span class="ruby-constant">STDIN</span>.<span class="ruby-identifier">reopen</span> <span class="ruby-value str">&quot;/dev/null&quot;</span>
534
+ 483: <span class="ruby-constant">STDOUT</span>.<span class="ruby-identifier">reopen</span> <span class="ruby-value str">&quot;/dev/null&quot;</span>, <span class="ruby-value str">&quot;a&quot;</span>
535
+ 484: <span class="ruby-constant">STDERR</span>.<span class="ruby-identifier">reopen</span> <span class="ruby-value str">&quot;/dev/null&quot;</span>, <span class="ruby-value str">&quot;a&quot;</span>
536
+ 485: <span class="ruby-keyword kw">else</span>
537
+ 486: <span class="ruby-constant">Process</span>.<span class="ruby-identifier">daemon</span>
538
+ 487: <span class="ruby-keyword kw">end</span>
539
+ 488: <span class="ruby-keyword kw">else</span>
540
+ 489: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;!! daemonize option unavailable on #{RUBY_PLATFORM} platform.&quot;</span>
541
+ 490: <span class="ruby-keyword kw">end</span>
542
+ 491:
543
+ 492: <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:pid</span>], <span class="ruby-value str">'w'</span>){ <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span> <span class="ruby-identifier">f</span>.<span class="ruby-identifier">write</span>(<span class="ruby-node">&quot;#{Process.pid}&quot;</span>) }
544
+ 493: <span class="ruby-identifier">at_exit</span> { <span class="ruby-constant">File</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:pid</span>]) <span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:pid</span>]) }
545
+ 494: <span class="ruby-keyword kw">end</span>
546
+ 495:
547
+ 496: <span class="ruby-comment cmt"># Start database</span>
548
+ 497: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">methods</span>.<span class="ruby-identifier">include?</span> <span class="ruby-value str">&quot;db_connect&quot;</span>
549
+ 498: <span class="ruby-identifier">db_connect</span>( <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:db_config</span>], <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:log</span>] )
550
+ 499: <span class="ruby-keyword kw">end</span>
551
+ 500:
552
+ 501: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
553
+ 502: <span class="ruby-keyword kw">yield</span>( <span class="ruby-keyword kw">self</span> )
554
+ 503: <span class="ruby-keyword kw">end</span>
555
+ 504:
556
+ 505: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:console</span>]
557
+ 506: <span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot;Run console...&quot;</span>
558
+ 507: <span class="ruby-constant">IRB</span>.<span class="ruby-identifier">start</span>
559
+ 508: <span class="ruby-identifier">exit</span>
560
+ 509: <span class="ruby-keyword kw">end</span>
561
+ 510:
562
+ 511: <span class="ruby-comment cmt"># Start server</span>
563
+ 512: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:server</span>]
564
+ 513: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">&quot;mongrel&quot;</span>
565
+ 514: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;** Starting Mongrel on #{conf[:host]}:#{conf[:port]}&quot;</span>
566
+ 515: <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Handler</span><span class="ruby-operator">::</span><span class="ruby-constant">Mongrel</span>.<span class="ruby-identifier">run</span>( <span class="ruby-identifier">app</span>, {<span class="ruby-identifier">:Port</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:port</span>], <span class="ruby-identifier">:Host</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:host</span>]} ) { <span class="ruby-operator">|</span><span class="ruby-identifier">server</span><span class="ruby-operator">|</span>
567
+ 516: <span class="ruby-identifier">trap</span> <span class="ruby-value str">&quot;SIGINT&quot;</span>, <span class="ruby-identifier">proc</span> { <span class="ruby-identifier">server</span>.<span class="ruby-identifier">stop</span> }
568
+ 517: }
569
+ 518: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">&quot;webrick&quot;</span>
570
+ 519: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;** Starting WEBrick on #{conf[:host]}:#{conf[:port]}&quot;</span>
571
+ 520: <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Handler</span><span class="ruby-operator">::</span><span class="ruby-constant">WEBrick</span>.<span class="ruby-identifier">run</span>( <span class="ruby-identifier">app</span>, {<span class="ruby-identifier">:Port</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:port</span>], <span class="ruby-identifier">:BindAddress</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:host</span>]} ) { <span class="ruby-operator">|</span><span class="ruby-identifier">server</span><span class="ruby-operator">|</span>
572
+ 521: <span class="ruby-identifier">trap</span> <span class="ruby-value str">&quot;SIGINT&quot;</span>, <span class="ruby-identifier">proc</span> { <span class="ruby-identifier">server</span>.<span class="ruby-identifier">shutdown</span> }
573
+ 522: }
574
+ 523: <span class="ruby-keyword kw">end</span>
575
+ 524: <span class="ruby-keyword kw">end</span>
576
+ 525: <span class="ruby-keyword kw">end</span>
577
577
  </pre>
578
578
  </div>
579
579
  </div>
@@ -588,10 +588,10 @@ Hash <a href="Capcode.html#M000004">session</a>
588
588
  <p class="source-link">[ <a href="javascript:toggleSource('M000004_source')" id="l_M000004_source">show source</a> ]</p>
589
589
  <div id="M000004_source" class="dyn-source">
590
590
  <pre>
591
- <span class="ruby-comment cmt"># File lib/capcode.rb, line 236</span>
592
- 236: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">session</span>
593
- 237: <span class="ruby-ivar">@env</span>[<span class="ruby-value str">'rack.session'</span>]
594
- 238: <span class="ruby-keyword kw">end</span>
591
+ <span class="ruby-comment cmt"># File lib/capcode.rb, line 244</span>
592
+ 244: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">session</span>
593
+ 245: <span class="ruby-ivar">@env</span>[<span class="ruby-value str">'rack.session'</span>]
594
+ 246: <span class="ruby-keyword kw">end</span>
595
595
  </pre>
596
596
  </div>
597
597
  </div>