Capcode 0.5.0 → 0.6.0

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.5.1
14
+ * Add :root option to Capcode.run. This option allow you to specify the root directory for static files
15
+ * Add :working_directory option to Capcode.run. This option allow you to specify the working directory
16
+ * Of '/' route is not defined but /index.html exist, display index
17
+ * add mime-types dependency
18
+ * Bug correction in erb and haml renderer
19
+
13
20
  === 0.5.0
14
21
  * Add Haml and Markaby renderer
15
22
  * json is deprecated and replaced by render( :json => ... )
@@ -154,47 +161,47 @@ See <tt>examples/blog-dm.rb</tt> and/or <tt>examples/blog-couchdb.rb</tt> for co
154
161
 
155
162
  === Render with Haml
156
163
 
157
- # file: sample.rb
158
- require 'rubygems'
159
- require 'capcode'
160
- require 'capcode/render/haml'
161
- Capcode::Helpers.haml_path = "./my_haml_views"
162
-
163
- module Capcode
164
- class Hello < Route '/hello'
165
- def get
166
- @t = Time.now
167
- render :haml => :time
168
- end
169
- end
170
- end
164
+ # file: sample.rb
165
+ require 'rubygems'
166
+ require 'capcode'
167
+ require 'capcode/render/haml'
168
+ Capcode::Helpers.haml_path = "./my_haml_views"
169
+
170
+ module Capcode
171
+ class Hello < Route '/hello'
172
+ def get
173
+ @t = Time.now
174
+ render :haml => :time
175
+ end
176
+ end
177
+ end
178
+
179
+ Capcode.run( )
171
180
 
172
- Capcode.run( )
173
-
174
- # ./my_haml_views/time.haml
175
- %html
176
- %body
177
- %p
178
- Hello World
179
- = @t
181
+ # ./my_haml_views/time.haml
182
+ %html
183
+ %body
184
+ %p
185
+ Hello World
186
+ = @t
180
187
 
181
188
  === Render with JSON
182
189
 
183
- # file: sample.rb
184
- require 'rubygems'
185
- require 'capcode'
186
- require 'capcode/render/json'
187
-
188
- module Capcode
189
- class Hello < Route '/hello'
190
- def get
191
- @t = Time.now
192
- render :json => { :time => @t }
193
- end
194
- end
195
- end
196
-
197
- Capcode.run( )
190
+ # file: sample.rb
191
+ require 'rubygems'
192
+ require 'capcode'
193
+ require 'capcode/render/json'
194
+
195
+ module Capcode
196
+ class Hello < Route '/hello'
197
+ def get
198
+ @t = Time.now
199
+ render :json => { :time => @t }
200
+ end
201
+ end
202
+ end
203
+
204
+ Capcode.run( )
198
205
 
199
206
  == REQUIREMENTS:
200
207
 
@@ -130,116 +130,116 @@ 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 152</span>
134
- 152: <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
- 153: <span class="ruby-constant">Class</span>.<span class="ruby-identifier">new</span> {
136
- 154: <span class="ruby-identifier">meta_def</span>(<span class="ruby-identifier">:__urls__</span>){
137
- 155: <span class="ruby-comment cmt"># &lt; Route '/hello/world/([^\/]*)/id(\d*)', '/hello/(.*)'</span>
138
- 156: <span class="ruby-comment cmt"># # =&gt; [ {'/hello/world' =&gt; '([^\/]*)/id(\d*)', '/hello' =&gt; '(.*)'}, 2, &lt;Capcode::Klass&gt; ]</span>
139
- 157: <span class="ruby-identifier">h</span> = {}
140
- 158: <span class="ruby-identifier">max</span> = <span class="ruby-value">0</span>
141
- 159: <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
- 160: <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
- 161: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">m</span>.<span class="ruby-identifier">nil?</span>
144
- 162: <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
- 163: <span class="ruby-identifier">h</span>[<span class="ruby-identifier">_u</span>] = <span class="ruby-value str">''</span>
146
- 164: <span class="ruby-keyword kw">else</span>
147
- 165: <span class="ruby-identifier">_pre</span> = <span class="ruby-identifier">m</span>.<span class="ruby-identifier">pre_match</span>
148
- 166: <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
- 167: <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
- 168: <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
- 169: <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
- 170: <span class="ruby-keyword kw">end</span>
153
- 171: <span class="ruby-keyword kw">end</span>
154
- 172: [<span class="ruby-identifier">h</span>, <span class="ruby-identifier">max</span>, <span class="ruby-keyword kw">self</span>]
155
- 173: }
156
- 174:
157
- 175: <span class="ruby-comment cmt"># Hash containing all the request parameters (GET or POST)</span>
158
- 176: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">params</span>
159
- 177: <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">params</span>
160
- 178: <span class="ruby-keyword kw">end</span>
161
- 179:
162
- 180: <span class="ruby-comment cmt"># Hash containing all the environment variables</span>
163
- 181: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">env</span>
164
- 182: <span class="ruby-ivar">@env</span>
165
- 183: <span class="ruby-keyword kw">end</span>
166
- 184:
167
- 185: <span class="ruby-comment cmt"># Hash session</span>
168
- 186: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">session</span>
169
- 187: <span class="ruby-ivar">@env</span>[<span class="ruby-value str">'rack.session'</span>]
170
- 188: <span class="ruby-keyword kw">end</span>
171
- 189:
172
- 190: <span class="ruby-comment cmt"># Return the Rack::Request object</span>
173
- 191: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">request</span>
174
- 192: <span class="ruby-ivar">@request</span>
175
- 193: <span class="ruby-keyword kw">end</span>
176
- 194:
177
- 195: <span class="ruby-comment cmt"># Return the Rack::Response object</span>
178
- 196: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">response</span>
179
- 197: <span class="ruby-ivar">@response</span>
180
- 198: <span class="ruby-keyword kw">end</span>
181
- 199:
182
- 200: <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
- 201: <span class="ruby-ivar">@env</span> = <span class="ruby-identifier">e</span>
184
- 202: <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
- 203: <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
- 204:
187
- 205: <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>]
188
- 206: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">&quot;GET&quot;</span>
189
- 207: <span class="ruby-identifier">finalPath</span> = <span class="ruby-keyword kw">nil</span>
190
- 208: <span class="ruby-identifier">finalArgs</span> = <span class="ruby-keyword kw">nil</span>
191
- 209: <span class="ruby-identifier">finalNArgs</span> = <span class="ruby-keyword kw">nil</span>
192
- 210:
193
- 211: <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> )
194
- 212: <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>
195
- 213: <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> )
196
- 214: <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>
197
- 215: <span class="ruby-identifier">diffArgs</span> = <span class="ruby-identifier">aPath</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">xPath</span>
198
- 216: <span class="ruby-identifier">diffNArgs</span> = <span class="ruby-identifier">diffArgs</span>.<span class="ruby-identifier">size</span>
199
- 217: <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>
200
- 218: <span class="ruby-identifier">finalPath</span> = <span class="ruby-identifier">p</span>
201
- 219: <span class="ruby-identifier">finalNArgs</span> = <span class="ruby-identifier">diffNArgs</span>
202
- 220: <span class="ruby-identifier">finalArgs</span> = <span class="ruby-identifier">diffArgs</span>
203
- 221: <span class="ruby-keyword kw">end</span>
204
- 222: <span class="ruby-keyword kw">end</span>
205
- 223:
206
- 224: <span class="ruby-keyword kw">end</span>
207
- 225:
208
- 226: <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>]
209
- 227: <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>] )
210
- 228:
211
- 229: <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> ) )
212
- 230: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">nil?</span>
213
- 231: <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>
214
- 232: <span class="ruby-keyword kw">else</span>
215
- 233: <span class="ruby-identifier">args</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">captures</span>
216
- 234: <span class="ruby-keyword kw">end</span>
217
- 235:
218
- 236: <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>
219
- 237: <span class="ruby-identifier">args</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-keyword kw">nil</span>
220
- 238: <span class="ruby-keyword kw">end</span>
221
- 239:
222
- 240: <span class="ruby-identifier">get</span>( <span class="ruby-operator">*</span><span class="ruby-identifier">args</span> )
223
- 241: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">&quot;POST&quot;</span>
224
- 242: <span class="ruby-identifier">post</span>
225
- 243: <span class="ruby-keyword kw">end</span>
226
- 244: <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>)
227
- 245: <span class="ruby-ivar">@response</span>.<span class="ruby-identifier">status</span> = <span class="ruby-identifier">r</span>[<span class="ruby-value">0</span>]
228
- 246: <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>
229
- 247: <span class="ruby-ivar">@response</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-identifier">v</span>
230
- 248: <span class="ruby-keyword kw">end</span>
231
- 249: <span class="ruby-ivar">@response</span>.<span class="ruby-identifier">body</span> = <span class="ruby-identifier">r</span>[<span class="ruby-value">2</span>]
232
- 250: <span class="ruby-keyword kw">else</span>
233
- 251: <span class="ruby-ivar">@response</span>.<span class="ruby-identifier">write</span> <span class="ruby-identifier">r</span>
234
- 252: <span class="ruby-keyword kw">end</span>
235
- 253:
236
- 254: <span class="ruby-ivar">@response</span>.<span class="ruby-identifier">finish</span>
237
- 255: <span class="ruby-keyword kw">end</span>
238
- 256:
239
- 257: <span class="ruby-identifier">include</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Helpers</span>
240
- 258: <span class="ruby-identifier">include</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Views</span>
241
- 259: }
242
- 260: <span class="ruby-keyword kw">end</span>
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-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>]
188
+ 256: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">&quot;GET&quot;</span>
189
+ 257: <span class="ruby-identifier">finalPath</span> = <span class="ruby-keyword kw">nil</span>
190
+ 258: <span class="ruby-identifier">finalArgs</span> = <span class="ruby-keyword kw">nil</span>
191
+ 259: <span class="ruby-identifier">finalNArgs</span> = <span class="ruby-keyword kw">nil</span>
192
+ 260:
193
+ 261: <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> )
194
+ 262: <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>
195
+ 263: <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> )
196
+ 264: <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>
197
+ 265: <span class="ruby-identifier">diffArgs</span> = <span class="ruby-identifier">aPath</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">xPath</span>
198
+ 266: <span class="ruby-identifier">diffNArgs</span> = <span class="ruby-identifier">diffArgs</span>.<span class="ruby-identifier">size</span>
199
+ 267: <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>
200
+ 268: <span class="ruby-identifier">finalPath</span> = <span class="ruby-identifier">p</span>
201
+ 269: <span class="ruby-identifier">finalNArgs</span> = <span class="ruby-identifier">diffNArgs</span>
202
+ 270: <span class="ruby-identifier">finalArgs</span> = <span class="ruby-identifier">diffArgs</span>
203
+ 271: <span class="ruby-keyword kw">end</span>
204
+ 272: <span class="ruby-keyword kw">end</span>
205
+ 273:
206
+ 274: <span class="ruby-keyword kw">end</span>
207
+ 275:
208
+ 276: <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>]
209
+ 277: <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>] )
210
+ 278:
211
+ 279: <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> ) )
212
+ 280: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">nil?</span>
213
+ 281: <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>
214
+ 282: <span class="ruby-keyword kw">else</span>
215
+ 283: <span class="ruby-identifier">args</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">captures</span>
216
+ 284: <span class="ruby-keyword kw">end</span>
217
+ 285:
218
+ 286: <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>
219
+ 287: <span class="ruby-identifier">args</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-keyword kw">nil</span>
220
+ 288: <span class="ruby-keyword kw">end</span>
221
+ 289:
222
+ 290: <span class="ruby-identifier">get</span>( <span class="ruby-operator">*</span><span class="ruby-identifier">args</span> )
223
+ 291: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">&quot;POST&quot;</span>
224
+ 292: <span class="ruby-identifier">post</span>
225
+ 293: <span class="ruby-keyword kw">end</span>
226
+ 294: <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>)
227
+ 295: <span class="ruby-ivar">@response</span>.<span class="ruby-identifier">status</span> = <span class="ruby-identifier">r</span>[<span class="ruby-value">0</span>]
228
+ 296: <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>
229
+ 297: <span class="ruby-ivar">@response</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-identifier">v</span>
230
+ 298: <span class="ruby-keyword kw">end</span>
231
+ 299: <span class="ruby-ivar">@response</span>.<span class="ruby-identifier">body</span> = <span class="ruby-identifier">r</span>[<span class="ruby-value">2</span>]
232
+ 300: <span class="ruby-keyword kw">else</span>
233
+ 301: <span class="ruby-ivar">@response</span>.<span class="ruby-identifier">write</span> <span class="ruby-identifier">r</span>
234
+ 302: <span class="ruby-keyword kw">end</span>
235
+ 303:
236
+ 304: <span class="ruby-ivar">@response</span>.<span class="ruby-identifier">finish</span>
237
+ 305: <span class="ruby-keyword kw">end</span>
238
+ 306:
239
+ 307: <span class="ruby-identifier">include</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Helpers</span>
240
+ 308: <span class="ruby-identifier">include</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Views</span>
241
+ 309: }
242
+ 310: <span class="ruby-keyword kw">end</span>
243
243
  </pre>
244
244
  </div>
245
245
  </div>
@@ -254,10 +254,10 @@ Hash containing all the environment variables
254
254
  <p class="source-link">[ <a href="javascript:toggleSource('M000003_source')" id="l_M000003_source">show source</a> ]</p>
255
255
  <div id="M000003_source" class="dyn-source">
256
256
  <pre>
257
- <span class="ruby-comment cmt"># File lib/capcode.rb, line 181</span>
258
- 181: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">env</span>
259
- 182: <span class="ruby-ivar">@env</span>
260
- 183: <span class="ruby-keyword kw">end</span>
257
+ <span class="ruby-comment cmt"># File lib/capcode.rb, line 231</span>
258
+ 231: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">env</span>
259
+ 232: <span class="ruby-ivar">@env</span>
260
+ 233: <span class="ruby-keyword kw">end</span>
261
261
  </pre>
262
262
  </div>
263
263
  </div>
@@ -278,10 +278,10 @@ Rack or What you want Helper
278
278
  <p class="source-link">[ <a href="javascript:toggleSource('M000007_source')" id="l_M000007_source">show source</a> ]</p>
279
279
  <div id="M000007_source" class="dyn-source">
280
280
  <pre>
281
- <span class="ruby-comment cmt"># File lib/capcode.rb, line 267</span>
282
- 267: <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> )
283
- 268: <span class="ruby-ivar">@@__ROUTES</span>[<span class="ruby-identifier">r</span>] = <span class="ruby-keyword kw">yield</span>
284
- 269: <span class="ruby-keyword kw">end</span>
281
+ <span class="ruby-comment cmt"># File lib/capcode.rb, line 317</span>
282
+ 317: <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> )
283
+ 318: <span class="ruby-ivar">@@__ROUTES</span>[<span class="ruby-identifier">r</span>] = <span class="ruby-keyword kw">yield</span>
284
+ 319: <span class="ruby-keyword kw">end</span>
285
285
  </pre>
286
286
  </div>
287
287
  </div>
@@ -297,10 +297,10 @@ parameters (GET or POST)
297
297
  <p class="source-link">[ <a href="javascript:toggleSource('M000002_source')" id="l_M000002_source">show source</a> ]</p>
298
298
  <div id="M000002_source" class="dyn-source">
299
299
  <pre>
300
- <span class="ruby-comment cmt"># File lib/capcode.rb, line 176</span>
301
- 176: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">params</span>
302
- 177: <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">params</span>
303
- 178: <span class="ruby-keyword kw">end</span>
300
+ <span class="ruby-comment cmt"># File lib/capcode.rb, line 226</span>
301
+ 226: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">params</span>
302
+ 227: <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">params</span>
303
+ 228: <span class="ruby-keyword kw">end</span>
304
304
  </pre>
305
305
  </div>
306
306
  </div>
@@ -315,10 +315,10 @@ Return the Rack::Request object
315
315
  <p class="source-link">[ <a href="javascript:toggleSource('M000005_source')" id="l_M000005_source">show source</a> ]</p>
316
316
  <div id="M000005_source" class="dyn-source">
317
317
  <pre>
318
- <span class="ruby-comment cmt"># File lib/capcode.rb, line 191</span>
319
- 191: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">request</span>
320
- 192: <span class="ruby-ivar">@request</span>
321
- 193: <span class="ruby-keyword kw">end</span>
318
+ <span class="ruby-comment cmt"># File lib/capcode.rb, line 241</span>
319
+ 241: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">request</span>
320
+ 242: <span class="ruby-ivar">@request</span>
321
+ 243: <span class="ruby-keyword kw">end</span>
322
322
  </pre>
323
323
  </div>
324
324
  </div>
@@ -333,10 +333,10 @@ Return the Rack::Response object
333
333
  <p class="source-link">[ <a href="javascript:toggleSource('M000006_source')" id="l_M000006_source">show source</a> ]</p>
334
334
  <div id="M000006_source" class="dyn-source">
335
335
  <pre>
336
- <span class="ruby-comment cmt"># File lib/capcode.rb, line 196</span>
337
- 196: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">response</span>
338
- 197: <span class="ruby-ivar">@response</span>
339
- 198: <span class="ruby-keyword kw">end</span>
336
+ <span class="ruby-comment cmt"># File lib/capcode.rb, line 246</span>
337
+ 246: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">response</span>
338
+ 247: <span class="ruby-ivar">@response</span>
339
+ 248: <span class="ruby-keyword kw">end</span>
340
340
  </pre>
341
341
  </div>
342
342
  </div>
@@ -374,6 +374,14 @@ See Rack::Session for more informations
374
374
  </li>
375
375
  <li><tt>:db_config</tt> = database configuration file (default: database.yml)
376
376
 
377
+ </li>
378
+ <li><tt>:root</tt> = root directory (default: &quot;.&quot; &#8212; relative to
379
+ the working directory)
380
+
381
+ </li>
382
+ <li><tt>:working_directory</tt> = Working directory (default: directory of the
383
+ main.rb)
384
+
377
385
  </li>
378
386
  </ul>
379
387
 
@@ -381,91 +389,99 @@ See Rack::Session for more informations
381
389
  <p class="source-link">[ <a href="javascript:toggleSource('M000008_source')" id="l_M000008_source">show source</a> ]</p>
382
390
  <div id="M000008_source" class="dyn-source">
383
391
  <pre>
384
- <span class="ruby-comment cmt"># File lib/capcode.rb, line 282</span>
385
- 282: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">run</span>( <span class="ruby-identifier">args</span> = {} )
386
- 283: <span class="ruby-identifier">conf</span> = {
387
- 284: <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>,
388
- 285: <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>,
389
- 286: <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>,
390
- 287: <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>,
391
- 288: <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>{},
392
- 289: <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>,
393
- 290: <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>,
394
- 291: <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>
395
- 292: }
396
- 293:
397
- 294: <span class="ruby-comment cmt"># Check that mongrel exists </span>
398
- 295: <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>
399
- 296: <span class="ruby-keyword kw">begin</span>
400
- 297: <span class="ruby-identifier">require</span> <span class="ruby-value str">'mongrel'</span>
401
- 298: <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:server</span>] = <span class="ruby-value str">&quot;mongrel&quot;</span>
402
- 299: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">LoadError</span>
403
- 300: <span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot;!! could not load mongrel. Falling back to webrick.&quot;</span>
404
- 301: <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:server</span>] = <span class="ruby-value str">&quot;webrick&quot;</span>
405
- 302: <span class="ruby-keyword kw">end</span>
406
- 303: <span class="ruby-keyword kw">end</span>
407
- 304:
408
- 305: <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>
409
- 306: <span class="ruby-keyword kw">begin</span>
410
- 307: <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>
411
- 308: <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>
412
- 309: <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>
413
- 310: <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>)
414
- 311: <span class="ruby-ivar">@@__ROUTES</span>[<span class="ruby-identifier">_u</span>] = <span class="ruby-identifier">c</span>.<span class="ruby-identifier">new</span>
415
- 312: <span class="ruby-keyword kw">end</span>
416
- 313: <span class="ruby-keyword kw">end</span>
417
- 314: <span class="ruby-keyword kw">rescue</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
418
- 315: <span class="ruby-identifier">raise</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">message</span>
419
- 316: <span class="ruby-keyword kw">end</span>
420
- 317: <span class="ruby-keyword kw">end</span>
421
- 318:
422
- 319: <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>)
423
- 320: <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>] )
424
- 321: <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>)
425
- 322: <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>)
426
- 323: <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>)
427
- 324: <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>)
428
- 325: <span class="ruby-comment cmt"># app = Rack::Reloader.new(app) ## -- NE RELOAD QUE capcode.rb -- So !!!</span>
429
- 326: <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>]) )
430
- 327:
431
- 328: <span class="ruby-comment cmt"># From rackup !!!</span>
432
- 329: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:daemonize</span>]
433
- 330: <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>
434
- 331: <span class="ruby-identifier">exit</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">fork</span>
435
- 332: <span class="ruby-constant">Process</span>.<span class="ruby-identifier">setsid</span>
436
- 333: <span class="ruby-identifier">exit</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">fork</span>
437
- 334: <span class="ruby-comment cmt"># Dir.chdir &quot;/&quot;</span>
438
- 335: <span class="ruby-constant">File</span>.<span class="ruby-identifier">umask</span> <span class="ruby-value">0000</span>
439
- 336: <span class="ruby-constant">STDIN</span>.<span class="ruby-identifier">reopen</span> <span class="ruby-value str">&quot;/dev/null&quot;</span>
440
- 337: <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>
441
- 338: <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>
442
- 339: <span class="ruby-keyword kw">else</span>
443
- 340: <span class="ruby-constant">Process</span>.<span class="ruby-identifier">daemon</span>
444
- 341: <span class="ruby-keyword kw">end</span>
445
- 342:
446
- 343: <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>) }
447
- 344: <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>]) }
448
- 345: <span class="ruby-keyword kw">end</span>
449
- 346:
450
- 347: <span class="ruby-comment cmt"># Start database</span>
451
- 348: <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>
452
- 349: <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>] )
453
- 350: <span class="ruby-keyword kw">end</span>
454
- 351:
455
- 352: <span class="ruby-comment cmt"># Start server</span>
456
- 353: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:server</span>]
457
- 354: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">&quot;mongrel&quot;</span>
458
- 355: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;** Starting Mongrel on #{conf[:host]}:#{conf[:port]}&quot;</span>
459
- 356: <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>
460
- 357: <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> }
461
- 358: }
462
- 359: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">&quot;webrick&quot;</span>
463
- 360: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;** Starting WEBrick on #{conf[:host]}:#{conf[:port]}&quot;</span>
464
- 361: <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>
465
- 362: <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> }
466
- 363: }
467
- 364: <span class="ruby-keyword kw">end</span>
468
- 365: <span class="ruby-keyword kw">end</span>
392
+ <span class="ruby-comment cmt"># File lib/capcode.rb, line 334</span>
393
+ 334: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">run</span>( <span class="ruby-identifier">args</span> = {} )
394
+ 335: <span class="ruby-identifier">conf</span> = {
395
+ 336: <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>,
396
+ 337: <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>,
397
+ 338: <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>,
398
+ 339: <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>,
399
+ 340: <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>{},
400
+ 341: <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>,
401
+ 342: <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>,
402
+ 343: <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>,
403
+ 344: <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-value str">&quot;.&quot;</span>,
404
+ 345: <span class="ruby-identifier">:working_directory</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:working_directory</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>))
405
+ 346: }
406
+ 347:
407
+ 348: <span class="ruby-comment cmt"># Run in the Working directory</span>
408
+ 349: <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">chdir</span>( <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:working_directory</span>] ) <span class="ruby-keyword kw">do</span>
409
+ 350: <span class="ruby-comment cmt"># Set root directory for helpers</span>
410
+ 351: <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Helpers</span>.<span class="ruby-identifier">root</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>] )
411
+ 352:
412
+ 353: <span class="ruby-comment cmt"># Check that mongrel exists </span>
413
+ 354: <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>
414
+ 355: <span class="ruby-keyword kw">begin</span>
415
+ 356: <span class="ruby-identifier">require</span> <span class="ruby-value str">'mongrel'</span>
416
+ 357: <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:server</span>] = <span class="ruby-value str">&quot;mongrel&quot;</span>
417
+ 358: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">LoadError</span>
418
+ 359: <span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot;!! could not load mongrel. Falling back to webrick.&quot;</span>
419
+ 360: <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:server</span>] = <span class="ruby-value str">&quot;webrick&quot;</span>
420
+ 361: <span class="ruby-keyword kw">end</span>
421
+ 362: <span class="ruby-keyword kw">end</span>
422
+ 363:
423
+ 364: <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>
424
+ 365: <span class="ruby-keyword kw">begin</span>
425
+ 366: <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>
426
+ 367: <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>
427
+ 368: <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>
428
+ 369: <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>)
429
+ 370: <span class="ruby-ivar">@@__ROUTES</span>[<span class="ruby-identifier">_u</span>] = <span class="ruby-identifier">c</span>.<span class="ruby-identifier">new</span>
430
+ 371: <span class="ruby-keyword kw">end</span>
431
+ 372: <span class="ruby-keyword kw">end</span>
432
+ 373: <span class="ruby-keyword kw">rescue</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
433
+ 374: <span class="ruby-identifier">raise</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">message</span>
434
+ 375: <span class="ruby-keyword kw">end</span>
435
+ 376: <span class="ruby-keyword kw">end</span>
436
+ 377:
437
+ 378: <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>)
438
+ 379: <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>] )
439
+ 380: <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>, <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:root</span>])
440
+ 381: <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>)
441
+ 382: <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>)
442
+ 383: <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>)
443
+ 384: <span class="ruby-comment cmt"># app = Rack::Reloader.new(app) ## -- NE RELOAD QUE capcode.rb -- So !!!</span>
444
+ 385: <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>]) )
445
+ 386:
446
+ 387: <span class="ruby-comment cmt"># From rackup !!!</span>
447
+ 388: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:daemonize</span>]
448
+ 389: <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>
449
+ 390: <span class="ruby-identifier">exit</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">fork</span>
450
+ 391: <span class="ruby-constant">Process</span>.<span class="ruby-identifier">setsid</span>
451
+ 392: <span class="ruby-identifier">exit</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">fork</span>
452
+ 393: <span class="ruby-comment cmt"># Dir.chdir &quot;/&quot;</span>
453
+ 394: <span class="ruby-constant">File</span>.<span class="ruby-identifier">umask</span> <span class="ruby-value">0000</span>
454
+ 395: <span class="ruby-constant">STDIN</span>.<span class="ruby-identifier">reopen</span> <span class="ruby-value str">&quot;/dev/null&quot;</span>
455
+ 396: <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>
456
+ 397: <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>
457
+ 398: <span class="ruby-keyword kw">else</span>
458
+ 399: <span class="ruby-constant">Process</span>.<span class="ruby-identifier">daemon</span>
459
+ 400: <span class="ruby-keyword kw">end</span>
460
+ 401:
461
+ 402: <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>) }
462
+ 403: <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>]) }
463
+ 404: <span class="ruby-keyword kw">end</span>
464
+ 405:
465
+ 406: <span class="ruby-comment cmt"># Start database</span>
466
+ 407: <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>
467
+ 408: <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>] )
468
+ 409: <span class="ruby-keyword kw">end</span>
469
+ 410:
470
+ 411: <span class="ruby-comment cmt"># Start server</span>
471
+ 412: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:server</span>]
472
+ 413: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">&quot;mongrel&quot;</span>
473
+ 414: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;** Starting Mongrel on #{conf[:host]}:#{conf[:port]}&quot;</span>
474
+ 415: <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>
475
+ 416: <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> }
476
+ 417: }
477
+ 418: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">&quot;webrick&quot;</span>
478
+ 419: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;** Starting WEBrick on #{conf[:host]}:#{conf[:port]}&quot;</span>
479
+ 420: <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>
480
+ 421: <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> }
481
+ 422: }
482
+ 423: <span class="ruby-keyword kw">end</span>
483
+ 424: <span class="ruby-keyword kw">end</span>
484
+ 425: <span class="ruby-keyword kw">end</span>
469
485
  </pre>
470
486
  </div>
471
487
  </div>
@@ -480,10 +496,10 @@ Hash <a href="Capcode.html#M000004">session</a>
480
496
  <p class="source-link">[ <a href="javascript:toggleSource('M000004_source')" id="l_M000004_source">show source</a> ]</p>
481
497
  <div id="M000004_source" class="dyn-source">
482
498
  <pre>
483
- <span class="ruby-comment cmt"># File lib/capcode.rb, line 186</span>
484
- 186: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">session</span>
485
- 187: <span class="ruby-ivar">@env</span>[<span class="ruby-value str">'rack.session'</span>]
486
- 188: <span class="ruby-keyword kw">end</span>
499
+ <span class="ruby-comment cmt"># File lib/capcode.rb, line 236</span>
500
+ 236: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">session</span>
501
+ 237: <span class="ruby-ivar">@env</span>[<span class="ruby-value str">'rack.session'</span>]
502
+ 238: <span class="ruby-keyword kw">end</span>
487
503
  </pre>
488
504
  </div>
489
505
  </div>