Capcode 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -10,6 +10,10 @@ Capcode is a web microframework
10
10
 
11
11
  == FEATURES/PROBLEMS:
12
12
 
13
+ === 0.5.0
14
+ * Add Haml and Markaby renderer
15
+ * json is deprecated and replaced by render( :json => ... )
16
+
13
17
  === 0.4.0
14
18
  * Major bug correction !
15
19
  * Add views...
@@ -28,19 +32,19 @@ Capcode is a web microframework
28
32
 
29
33
  == SYNOPSIS:
30
34
 
31
- # file: sample.rb
32
- require 'rubygems'
33
- require 'capcode'
34
-
35
- module Capcode
36
- class Hello < Route '/hello'
37
- def get
38
- "Hello World #{Time.now} !"
39
- end
40
- end
41
- end
42
-
43
- Capcode.run( )
35
+ # file: sample.rb
36
+ require 'rubygems'
37
+ require 'capcode'
38
+
39
+ module Capcode
40
+ class Hello < Route '/hello'
41
+ def get
42
+ "Hello World #{Time.now} !"
43
+ end
44
+ end
45
+ end
46
+
47
+ Capcode.run( )
44
48
 
45
49
  === Running Capcode Apps
46
50
 
@@ -49,71 +53,147 @@ Capcode is a web microframework
49
53
 
50
54
  === Create model
51
55
 
52
- require 'rubygems'
53
- require 'capcode'
54
- require 'capcode/base/dm' # or require 'capcode/base/couchdb'
56
+ require 'rubygems'
57
+ require 'capcode'
58
+ require 'capcode/base/dm' # or require 'capcode/base/couchdb'
55
59
 
56
- class Story < Capcode::Base
57
- include Capcode::Resource
60
+ class Story < Capcode::Base
61
+ include Capcode::Resource
58
62
 
59
- property :id, Integer, :serial => true # only with DataMapper !
60
- property :title, String
61
- property :body, String
62
- property :date, String
63
- end
63
+ property :id, Integer, :serial => true # only with DataMapper !
64
+ property :title, String
65
+ property :body, String
66
+ property :date, String
67
+ end
64
68
 
65
69
  See <tt>examples/blog-dm.rb</tt> and/or <tt>examples/blog-couchdb.rb</tt> for complete examples.
66
70
 
67
71
  === Create View
68
72
 
73
+ # file: sample.rb
74
+ require 'rubygems'
75
+ require 'capcode'
76
+
77
+ module Capcode
78
+ class Hello < Route '/hello'
79
+ def get
80
+ @t = Time.now
81
+ render :time
82
+ end
83
+ end
84
+ end
85
+
86
+ module Capcode::Views
87
+ def time
88
+ "Hello world #{@t}"
89
+ end
90
+ end
91
+
92
+ Capcode.run( )
93
+
94
+ === Create Helper
95
+
96
+ # file: sample.rb
97
+ require 'rubygems'
98
+ require 'capcode'
99
+
100
+ module Capcode
101
+ class Hello < Route '/hello'
102
+ def get
103
+ @t = Time.now
104
+ render :time
105
+ end
106
+ end
107
+ end
108
+
109
+ module Capcode::Helpers
110
+ def bold( &b )
111
+ "<b>"+yield+"</b>"
112
+ end
113
+ end
114
+
115
+ module Capcode::Views
116
+ def time
117
+ "Hello world " + bold { @t }
118
+ end
119
+ end
120
+
121
+ Capcode.run( )
122
+
123
+ === Render with Markaby
124
+
125
+ # file: sample.rb
126
+ require 'rubygems'
127
+ require 'capcode'
128
+ require 'capcode/render/markaby'
129
+
130
+ module Capcode
131
+ class Hello < Route '/hello'
132
+ def get
133
+ @t = Time.now
134
+ render :markaby => :time
135
+ end
136
+ end
137
+ end
138
+
139
+ module Capcode::Views
140
+ def time
141
+ # We use Markaby in Capcode::Views.time
142
+ html do
143
+ body do
144
+ p {
145
+ text "Hello World "
146
+ b @t
147
+ }
148
+ end
149
+ end
150
+ end
151
+ end
152
+
153
+ Capcode.run( )
154
+
155
+ === Render with Haml
156
+
69
157
  # file: sample.rb
70
158
  require 'rubygems'
71
159
  require 'capcode'
72
-
160
+ require 'capcode/render/haml'
161
+ Capcode::Helpers.haml_path = "./my_haml_views"
162
+
73
163
  module Capcode
74
164
  class Hello < Route '/hello'
75
165
  def get
76
166
  @t = Time.now
77
- render :time
167
+ render :haml => :time
78
168
  end
79
169
  end
80
170
  end
81
-
82
- module Capcode::Views
83
- def time
84
- "Hello world #{@t}"
85
- end
86
- end
87
-
171
+
88
172
  Capcode.run( )
173
+
174
+ # ./my_haml_views/time.haml
175
+ %html
176
+ %body
177
+ %p
178
+ Hello World
179
+ = @t
89
180
 
90
- === Create Helper
181
+ === Render with JSON
91
182
 
92
183
  # file: sample.rb
93
184
  require 'rubygems'
94
185
  require 'capcode'
95
-
186
+ require 'capcode/render/json'
187
+
96
188
  module Capcode
97
189
  class Hello < Route '/hello'
98
190
  def get
99
191
  @t = Time.now
100
- render :time
192
+ render :json => { :time => @t }
101
193
  end
102
194
  end
103
195
  end
104
-
105
- module Capcode::Helpers
106
- def bold( &b )
107
- "<b>"+yield+"</b>"
108
- end
109
- end
110
-
111
- module Capcode::Views
112
- def time
113
- "Hello world " + bold { @t }
114
- end
115
- end
116
-
196
+
117
197
  Capcode.run( )
118
198
 
119
199
  == REQUIREMENTS:
@@ -69,6 +69,7 @@
69
69
  <a href="../classes/Capcode/Views.html" title="Module: Capcode::Views">Capcode::Views</a>.view_html<br />
70
70
  <a href="../classes/Capcode/Helpers.html" title="Module: Capcode::Helpers">Capcode::Helpers</a>.view_html<br />
71
71
  <a href="../classes/Capcode/HTTPError.html" title="Class: Capcode::HTTPError">Capcode::HTTPError</a>.view_html<br />
72
+ <a href="../classes/Capcode/RenderError.html" title="Class: Capcode::RenderError">Capcode::RenderError</a>.view_html<br />
72
73
  <a href="../classes/Capcode/RouteError.html" title="Class: Capcode::RouteError">Capcode::RouteError</a>.view_html<br />
73
74
  <a href="../classes/Capcode/ParameterError.html" title="Class: Capcode::ParameterError">Capcode::ParameterError</a>.view_html<br />
74
75
  end</strong>
@@ -129,116 +130,116 @@ If the regexp in the route does not match, all arguments will be
129
130
  <p class="source-link">[ <a href="javascript:toggleSource('M000001_source')" id="l_M000001_source">show source</a> ]</p>
130
131
  <div id="M000001_source" class="dyn-source">
131
132
  <pre>
132
- <span class="ruby-comment cmt"># File lib/capcode.rb, line 137</span>
133
- 137: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">Route</span> <span class="ruby-operator">*</span><span class="ruby-identifier">u</span>
134
- 138: <span class="ruby-constant">Class</span>.<span class="ruby-identifier">new</span> {
135
- 139: <span class="ruby-identifier">meta_def</span>(<span class="ruby-identifier">:__urls__</span>){
136
- 140: <span class="ruby-comment cmt"># &lt; Route '/hello/world/([^\/]*)/id(\d*)', '/hello/(.*)'</span>
137
- 141: <span class="ruby-comment cmt"># # =&gt; [ {'/hello/world' =&gt; '([^\/]*)/id(\d*)', '/hello' =&gt; '(.*)'}, 2, &lt;Capcode::Klass&gt; ]</span>
138
- 142: <span class="ruby-identifier">h</span> = {}
139
- 143: <span class="ruby-identifier">max</span> = <span class="ruby-value">0</span>
140
- 144: <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>
141
- 145: <span class="ruby-identifier">m</span> = <span class="ruby-regexp re">/\/([^\/]*\(.*)/</span>.<span class="ruby-identifier">match</span>( <span class="ruby-identifier">_u</span> )
142
- 146: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">m</span>.<span class="ruby-identifier">nil?</span>
143
- 147: <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>)
144
- 148: <span class="ruby-identifier">h</span>[<span class="ruby-identifier">_u</span>] = <span class="ruby-value str">''</span>
145
- 149: <span class="ruby-keyword kw">else</span>
146
- 150: <span class="ruby-identifier">_pre</span> = <span class="ruby-identifier">m</span>.<span class="ruby-identifier">pre_match</span>
147
- 151: <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>
148
- 152: <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>)
149
- 153: <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>]
150
- 154: <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>
151
- 155: <span class="ruby-keyword kw">end</span>
152
- 156: <span class="ruby-keyword kw">end</span>
153
- 157: [<span class="ruby-identifier">h</span>, <span class="ruby-identifier">max</span>, <span class="ruby-keyword kw">self</span>]
154
- 158: }
155
- 159:
156
- 160: <span class="ruby-comment cmt"># Hash containing all the request parameters (GET or POST)</span>
157
- 161: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">params</span>
158
- 162: <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">params</span>
159
- 163: <span class="ruby-keyword kw">end</span>
160
- 164:
161
- 165: <span class="ruby-comment cmt"># Hash containing all the environment variables</span>
162
- 166: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">env</span>
163
- 167: <span class="ruby-ivar">@env</span>
164
- 168: <span class="ruby-keyword kw">end</span>
165
- 169:
166
- 170: <span class="ruby-comment cmt"># Hash session</span>
167
- 171: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">session</span>
168
- 172: <span class="ruby-ivar">@env</span>[<span class="ruby-value str">'rack.session'</span>]
169
- 173: <span class="ruby-keyword kw">end</span>
170
- 174:
171
- 175: <span class="ruby-comment cmt"># Return the Rack::Request object</span>
172
- 176: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">request</span>
173
- 177: <span class="ruby-ivar">@request</span>
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>
174
160
  178: <span class="ruby-keyword kw">end</span>
175
161
  179:
176
- 180: <span class="ruby-comment cmt"># Return the Rack::Response object</span>
177
- 181: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">response</span>
178
- 182: <span class="ruby-ivar">@response</span>
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>
179
165
  183: <span class="ruby-keyword kw">end</span>
180
166
  184:
181
- 185: <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>
182
- 186: <span class="ruby-ivar">@env</span> = <span class="ruby-identifier">e</span>
183
- 187: <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>
184
- 188: <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>)
185
- 189:
186
- 190: <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>]
187
- 191: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">&quot;GET&quot;</span>
188
- 192: <span class="ruby-identifier">finalPath</span> = <span class="ruby-keyword kw">nil</span>
189
- 193: <span class="ruby-identifier">finalArgs</span> = <span class="ruby-keyword kw">nil</span>
190
- 194: <span class="ruby-identifier">finalNArgs</span> = <span class="ruby-keyword kw">nil</span>
191
- 195:
192
- 196: <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> )
193
- 197: <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>
194
- 198: <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> )
195
- 199: <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>
196
- 200: <span class="ruby-identifier">diffArgs</span> = <span class="ruby-identifier">aPath</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">xPath</span>
197
- 201: <span class="ruby-identifier">diffNArgs</span> = <span class="ruby-identifier">diffArgs</span>.<span class="ruby-identifier">size</span>
198
- 202: <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>
199
- 203: <span class="ruby-identifier">finalPath</span> = <span class="ruby-identifier">p</span>
200
- 204: <span class="ruby-identifier">finalNArgs</span> = <span class="ruby-identifier">diffNArgs</span>
201
- 205: <span class="ruby-identifier">finalArgs</span> = <span class="ruby-identifier">diffArgs</span>
202
- 206: <span class="ruby-keyword kw">end</span>
203
- 207: <span class="ruby-keyword kw">end</span>
204
- 208:
205
- 209: <span class="ruby-keyword kw">end</span>
206
- 210:
207
- 211: <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>]
208
- 212: <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>] )
209
- 213:
210
- 214: <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> ) )
211
- 215: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">nil?</span>
212
- 216: <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>
213
- 217: <span class="ruby-keyword kw">else</span>
214
- 218: <span class="ruby-identifier">args</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">captures</span>
215
- 219: <span class="ruby-keyword kw">end</span>
216
- 220:
217
- 221: <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>
218
- 222: <span class="ruby-identifier">args</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-keyword kw">nil</span>
219
- 223: <span class="ruby-keyword kw">end</span>
220
- 224:
221
- 225: <span class="ruby-identifier">get</span>( <span class="ruby-operator">*</span><span class="ruby-identifier">args</span> )
222
- 226: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">&quot;POST&quot;</span>
223
- 227: <span class="ruby-identifier">post</span>
224
- 228: <span class="ruby-keyword kw">end</span>
225
- 229: <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>)
226
- 230: <span class="ruby-ivar">@response</span>.<span class="ruby-identifier">status</span> = <span class="ruby-identifier">r</span>[<span class="ruby-value">0</span>]
227
- 231: <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>
228
- 232: <span class="ruby-ivar">@response</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-identifier">v</span>
229
- 233: <span class="ruby-keyword kw">end</span>
230
- 234: <span class="ruby-ivar">@response</span>.<span class="ruby-identifier">body</span> = <span class="ruby-identifier">r</span>[<span class="ruby-value">2</span>]
231
- 235: <span class="ruby-keyword kw">else</span>
232
- 236: <span class="ruby-ivar">@response</span>.<span class="ruby-identifier">write</span> <span class="ruby-identifier">r</span>
233
- 237: <span class="ruby-keyword kw">end</span>
234
- 238:
235
- 239: <span class="ruby-ivar">@response</span>.<span class="ruby-identifier">finish</span>
236
- 240: <span class="ruby-keyword kw">end</span>
237
- 241:
238
- 242: <span class="ruby-identifier">include</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Helpers</span>
239
- 243: <span class="ruby-identifier">include</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Views</span>
240
- 244: }
241
- 245: <span class="ruby-keyword kw">end</span>
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>
242
243
  </pre>
243
244
  </div>
244
245
  </div>
@@ -253,10 +254,10 @@ Hash containing all the environment variables
253
254
  <p class="source-link">[ <a href="javascript:toggleSource('M000003_source')" id="l_M000003_source">show source</a> ]</p>
254
255
  <div id="M000003_source" class="dyn-source">
255
256
  <pre>
256
- <span class="ruby-comment cmt"># File lib/capcode.rb, line 166</span>
257
- 166: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">env</span>
258
- 167: <span class="ruby-ivar">@env</span>
259
- 168: <span class="ruby-keyword kw">end</span>
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>
260
261
  </pre>
261
262
  </div>
262
263
  </div>
@@ -277,10 +278,10 @@ Rack or What you want Helper
277
278
  <p class="source-link">[ <a href="javascript:toggleSource('M000007_source')" id="l_M000007_source">show source</a> ]</p>
278
279
  <div id="M000007_source" class="dyn-source">
279
280
  <pre>
280
- <span class="ruby-comment cmt"># File lib/capcode.rb, line 252</span>
281
- 252: <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> )
282
- 253: <span class="ruby-ivar">@@__ROUTES</span>[<span class="ruby-identifier">r</span>] = <span class="ruby-keyword kw">yield</span>
283
- 254: <span class="ruby-keyword kw">end</span>
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>
284
285
  </pre>
285
286
  </div>
286
287
  </div>
@@ -296,10 +297,10 @@ parameters (GET or POST)
296
297
  <p class="source-link">[ <a href="javascript:toggleSource('M000002_source')" id="l_M000002_source">show source</a> ]</p>
297
298
  <div id="M000002_source" class="dyn-source">
298
299
  <pre>
299
- <span class="ruby-comment cmt"># File lib/capcode.rb, line 161</span>
300
- 161: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">params</span>
301
- 162: <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">params</span>
302
- 163: <span class="ruby-keyword kw">end</span>
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>
303
304
  </pre>
304
305
  </div>
305
306
  </div>
@@ -314,10 +315,10 @@ Return the Rack::Request object
314
315
  <p class="source-link">[ <a href="javascript:toggleSource('M000005_source')" id="l_M000005_source">show source</a> ]</p>
315
316
  <div id="M000005_source" class="dyn-source">
316
317
  <pre>
317
- <span class="ruby-comment cmt"># File lib/capcode.rb, line 176</span>
318
- 176: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">request</span>
319
- 177: <span class="ruby-ivar">@request</span>
320
- 178: <span class="ruby-keyword kw">end</span>
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>
321
322
  </pre>
322
323
  </div>
323
324
  </div>
@@ -332,10 +333,10 @@ Return the Rack::Response object
332
333
  <p class="source-link">[ <a href="javascript:toggleSource('M000006_source')" id="l_M000006_source">show source</a> ]</p>
333
334
  <div id="M000006_source" class="dyn-source">
334
335
  <pre>
335
- <span class="ruby-comment cmt"># File lib/capcode.rb, line 181</span>
336
- 181: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">response</span>
337
- 182: <span class="ruby-ivar">@response</span>
338
- 183: <span class="ruby-keyword kw">end</span>
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>
339
340
  </pre>
340
341
  </div>
341
342
  </div>
@@ -380,91 +381,91 @@ See Rack::Session for more informations
380
381
  <p class="source-link">[ <a href="javascript:toggleSource('M000008_source')" id="l_M000008_source">show source</a> ]</p>
381
382
  <div id="M000008_source" class="dyn-source">
382
383
  <pre>
383
- <span class="ruby-comment cmt"># File lib/capcode.rb, line 267</span>
384
- 267: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">run</span>( <span class="ruby-identifier">args</span> = {} )
385
- 268: <span class="ruby-identifier">conf</span> = {
386
- 269: <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>,
387
- 270: <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>,
388
- 271: <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>,
389
- 272: <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>,
390
- 273: <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>{},
391
- 274: <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>,
392
- 275: <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>,
393
- 276: <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>
394
- 277: }
395
- 278:
396
- 279: <span class="ruby-comment cmt"># Check that mongrel exists </span>
397
- 280: <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>
398
- 281: <span class="ruby-keyword kw">begin</span>
399
- 282: <span class="ruby-identifier">require</span> <span class="ruby-value str">'mongrel'</span>
400
- 283: <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:server</span>] = <span class="ruby-value str">&quot;mongrel&quot;</span>
401
- 284: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">LoadError</span>
402
- 285: <span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot;!! could not load mongrel. Falling back to webrick.&quot;</span>
403
- 286: <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:server</span>] = <span class="ruby-value str">&quot;webrick&quot;</span>
404
- 287: <span class="ruby-keyword kw">end</span>
405
- 288: <span class="ruby-keyword kw">end</span>
406
- 289:
407
- 290: <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>
408
- 291: <span class="ruby-keyword kw">begin</span>
409
- 292: <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>
410
- 293: <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>
411
- 294: <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>
412
- 295: <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>)
413
- 296: <span class="ruby-ivar">@@__ROUTES</span>[<span class="ruby-identifier">_u</span>] = <span class="ruby-identifier">c</span>.<span class="ruby-identifier">new</span>
414
- 297: <span class="ruby-keyword kw">end</span>
415
- 298: <span class="ruby-keyword kw">end</span>
416
- 299: <span class="ruby-keyword kw">rescue</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
417
- 300: <span class="ruby-identifier">raise</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">message</span>
418
- 301: <span class="ruby-keyword kw">end</span>
419
- 302: <span class="ruby-keyword kw">end</span>
420
- 303:
421
- 304: <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>)
422
- 305: <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>] )
423
- 306: <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>)
424
- 307: <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>)
425
- 308: <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>)
426
- 309: <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>)
427
- 310: <span class="ruby-comment cmt"># app = Rack::Reloader.new(app) ## -- NE RELOAD QUE capcode.rb -- So !!!</span>
428
- 311: <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>]) )
429
- 312:
430
- 313: <span class="ruby-comment cmt"># From rackup !!!</span>
431
- 314: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:daemonize</span>]
432
- 315: <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>
433
- 316: <span class="ruby-identifier">exit</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">fork</span>
434
- 317: <span class="ruby-constant">Process</span>.<span class="ruby-identifier">setsid</span>
435
- 318: <span class="ruby-identifier">exit</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">fork</span>
436
- 319: <span class="ruby-comment cmt"># Dir.chdir &quot;/&quot;</span>
437
- 320: <span class="ruby-constant">File</span>.<span class="ruby-identifier">umask</span> <span class="ruby-value">0000</span>
438
- 321: <span class="ruby-constant">STDIN</span>.<span class="ruby-identifier">reopen</span> <span class="ruby-value str">&quot;/dev/null&quot;</span>
439
- 322: <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>
440
- 323: <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>
441
- 324: <span class="ruby-keyword kw">else</span>
442
- 325: <span class="ruby-constant">Process</span>.<span class="ruby-identifier">daemon</span>
443
- 326: <span class="ruby-keyword kw">end</span>
444
- 327:
445
- 328: <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>) }
446
- 329: <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>]) }
447
- 330: <span class="ruby-keyword kw">end</span>
448
- 331:
449
- 332: <span class="ruby-comment cmt"># Start database</span>
450
- 333: <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>
451
- 334: <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>] )
452
- 335: <span class="ruby-keyword kw">end</span>
453
- 336:
454
- 337: <span class="ruby-comment cmt"># Start server</span>
455
- 338: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:server</span>]
456
- 339: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">&quot;mongrel&quot;</span>
457
- 340: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;** Starting Mongrel on #{conf[:host]}:#{conf[:port]}&quot;</span>
458
- 341: <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>
459
- 342: <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> }
460
- 343: }
461
- 344: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">&quot;webrick&quot;</span>
462
- 345: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;** Starting WEBrick on #{conf[:host]}:#{conf[:port]}&quot;</span>
463
- 346: <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>
464
- 347: <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> }
465
- 348: }
466
- 349: <span class="ruby-keyword kw">end</span>
467
- 350: <span class="ruby-keyword kw">end</span>
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>
468
469
  </pre>
469
470
  </div>
470
471
  </div>
@@ -479,10 +480,10 @@ Hash <a href="Capcode.html#M000004">session</a>
479
480
  <p class="source-link">[ <a href="javascript:toggleSource('M000004_source')" id="l_M000004_source">show source</a> ]</p>
480
481
  <div id="M000004_source" class="dyn-source">
481
482
  <pre>
482
- <span class="ruby-comment cmt"># File lib/capcode.rb, line 171</span>
483
- 171: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">session</span>
484
- 172: <span class="ruby-ivar">@env</span>[<span class="ruby-value str">'rack.session'</span>]
485
- 173: <span class="ruby-keyword kw">end</span>
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>
486
487
  </pre>
487
488
  </div>
488
489
  </div>