Capcode 0.9.6 → 0.9.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -223,39 +223,37 @@ then
223
223
  204: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">URL</span>( <span class="ruby-identifier">klass</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">a</span> )
224
224
  205: <span class="ruby-identifier">path</span> = <span class="ruby-keyword kw">nil</span>
225
225
  206: <span class="ruby-identifier">result</span> = {}
226
- 207:
226
+ 207:
227
227
  208: <span class="ruby-identifier">a</span> = <span class="ruby-identifier">a</span>.<span class="ruby-identifier">delete_if</span>{ <span class="ruby-operator">|</span><span class="ruby-identifier">x</span><span class="ruby-operator">|</span> <span class="ruby-identifier">x</span>.<span class="ruby-identifier">nil?</span> }
228
228
  209:
229
229
  210: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Class</span>
230
- 211: <span class="ruby-identifier">last_size</span> = <span class="ruby-value">0</span>
231
- 212:
232
- 213: <span class="ruby-identifier">klass</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">cpath</span>, <span class="ruby-identifier">regexp</span><span class="ruby-operator">|</span>
233
- 214: <span class="ruby-identifier">data</span> = <span class="ruby-identifier">a</span>.<span class="ruby-identifier">clone</span>
234
- 215:
235
- 216: <span class="ruby-identifier">n</span> = <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">new</span>( <span class="ruby-identifier">regexp</span> ).<span class="ruby-identifier">number_of_captures</span>
236
- 217: <span class="ruby-identifier">equart</span> = (<span class="ruby-identifier">a</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">n</span>).<span class="ruby-identifier">abs</span>
237
- 218:
238
- 219: <span class="ruby-identifier">rtable</span> = <span class="ruby-identifier">regexp</span>.<span class="ruby-identifier">dup</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">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-regexp re">/\([^\)]*\)/</span> )
239
- 220:
240
- 221: <span class="ruby-identifier">rtable</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">r</span><span class="ruby-operator">|</span>
241
- 222: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">r</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;&quot;</span>
242
- 223: <span class="ruby-identifier">cpath</span> = <span class="ruby-identifier">cpath</span> <span class="ruby-operator">+</span> <span class="ruby-node">&quot;/#{data.shift}&quot;</span>
243
- 224: <span class="ruby-keyword kw">else</span>
244
- 225: <span class="ruby-identifier">cpath</span> = <span class="ruby-identifier">cpath</span> <span class="ruby-operator">+</span> <span class="ruby-node">&quot;/#{r}&quot;</span>
245
- 226: <span class="ruby-keyword kw">end</span>
246
- 227: <span class="ruby-keyword kw">end</span>
247
- 228:
248
- 229: <span class="ruby-identifier">cpath</span> = (<span class="ruby-identifier">cpath</span> <span class="ruby-operator">+</span> <span class="ruby-value str">&quot;/&quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">data</span>.<span class="ruby-identifier">join</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> ).<span class="ruby-identifier">gsub</span>( <span class="ruby-regexp re">/\/$/</span>, <span class="ruby-value str">&quot;&quot;</span> )
249
- 230: <span class="ruby-identifier">result</span>[<span class="ruby-identifier">equart</span>] = <span class="ruby-identifier">cpath</span>
250
- 231: <span class="ruby-keyword kw">end</span>
251
- 232:
252
- 233: <span class="ruby-identifier">path</span> = <span class="ruby-identifier">result</span>[<span class="ruby-identifier">result</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">min</span>]
253
- 234: <span class="ruby-keyword kw">else</span>
254
- 235: <span class="ruby-identifier">path</span> = <span class="ruby-identifier">klass</span>
255
- 236: <span class="ruby-keyword kw">end</span>
256
- 237:
257
- 238: (<span class="ruby-constant">ENV</span>[<span class="ruby-value str">'RACK_BASE_URI'</span>]<span class="ruby-operator">||</span><span class="ruby-value str">''</span>)<span class="ruby-operator">+</span><span class="ruby-identifier">path</span>
258
- 239: <span class="ruby-keyword kw">end</span>
230
+ 211: <span class="ruby-identifier">klass</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">cpath</span>, <span class="ruby-identifier">regexp</span><span class="ruby-operator">|</span>
231
+ 212: <span class="ruby-identifier">data</span> = <span class="ruby-identifier">a</span>.<span class="ruby-identifier">clone</span>
232
+ 213:
233
+ 214: <span class="ruby-identifier">n</span> = <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">new</span>( <span class="ruby-identifier">regexp</span> ).<span class="ruby-identifier">number_of_captures</span>
234
+ 215: <span class="ruby-identifier">equart</span> = (<span class="ruby-identifier">a</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">n</span>).<span class="ruby-identifier">abs</span>
235
+ 216:
236
+ 217: <span class="ruby-identifier">rtable</span> = <span class="ruby-identifier">regexp</span>.<span class="ruby-identifier">dup</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">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-regexp re">/\([^\)]*\)/</span> )
237
+ 218: <span class="ruby-identifier">rtable</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">r</span><span class="ruby-operator">|</span>
238
+ 219: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">r</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;&quot;</span>
239
+ 220: <span class="ruby-identifier">cpath</span> = <span class="ruby-identifier">cpath</span> <span class="ruby-operator">+</span> <span class="ruby-node">&quot;/#{data.shift}&quot;</span>
240
+ 221: <span class="ruby-keyword kw">else</span>
241
+ 222: <span class="ruby-identifier">cpath</span> = <span class="ruby-identifier">cpath</span> <span class="ruby-operator">+</span> <span class="ruby-node">&quot;/#{r}&quot;</span>
242
+ 223: <span class="ruby-keyword kw">end</span>
243
+ 224: <span class="ruby-keyword kw">end</span>
244
+ 225:
245
+ 226: <span class="ruby-identifier">cpath</span> = (<span class="ruby-identifier">cpath</span> <span class="ruby-operator">+</span> <span class="ruby-value str">&quot;/&quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">data</span>.<span class="ruby-identifier">join</span>( <span class="ruby-value str">&quot;/&quot;</span> )) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">data</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>
246
+ 227: <span class="ruby-identifier">cpath</span> = <span class="ruby-identifier">cpath</span>.<span class="ruby-identifier">gsub</span>( <span class="ruby-regexp re">/(\/){2,}/</span>, <span class="ruby-value str">&quot;/&quot;</span> )
247
+ 228: <span class="ruby-identifier">result</span>[<span class="ruby-identifier">equart</span>] = <span class="ruby-identifier">cpath</span>
248
+ 229: <span class="ruby-keyword kw">end</span>
249
+ 230:
250
+ 231: <span class="ruby-identifier">path</span> = <span class="ruby-identifier">result</span>[<span class="ruby-identifier">result</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">min</span>]
251
+ 232: <span class="ruby-keyword kw">else</span>
252
+ 233: <span class="ruby-identifier">path</span> = <span class="ruby-identifier">klass</span>
253
+ 234: <span class="ruby-keyword kw">end</span>
254
+ 235:
255
+ 236: (<span class="ruby-constant">ENV</span>[<span class="ruby-value str">'RACK_BASE_URI'</span>]<span class="ruby-operator">||</span><span class="ruby-value str">''</span>)<span class="ruby-operator">+</span><span class="ruby-identifier">path</span>
256
+ 237: <span class="ruby-keyword kw">end</span>
259
257
  </pre>
260
258
  </div>
261
259
  </div>
@@ -311,12 +309,12 @@ markup in an identifier.
311
309
  onclick="toggleCode('M000020-source');return false;">[Source]</a></p>
312
310
  <div class="method-source-code" id="M000020-source">
313
311
  <pre>
314
- <span class="ruby-comment cmt"># File lib/capcode.rb, line 273</span>
315
- 273: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">content_for</span>( <span class="ruby-identifier">x</span> )
316
- 274: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Helpers</span>.<span class="ruby-identifier">args</span>.<span class="ruby-identifier">map</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">_</span><span class="ruby-operator">|</span> <span class="ruby-identifier">_</span>.<span class="ruby-identifier">to_s</span> }.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">x</span>.<span class="ruby-identifier">to_s</span>)
317
- 275: <span class="ruby-keyword kw">yield</span>
318
- 276: <span class="ruby-keyword kw">end</span>
319
- 277: <span class="ruby-keyword kw">end</span>
312
+ <span class="ruby-comment cmt"># File lib/capcode.rb, line 271</span>
313
+ 271: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">content_for</span>( <span class="ruby-identifier">x</span> )
314
+ 272: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Helpers</span>.<span class="ruby-identifier">args</span>.<span class="ruby-identifier">map</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">_</span><span class="ruby-operator">|</span> <span class="ruby-identifier">_</span>.<span class="ruby-identifier">to_s</span> }.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">x</span>.<span class="ruby-identifier">to_s</span>)
315
+ 273: <span class="ruby-keyword kw">yield</span>
316
+ 274: <span class="ruby-keyword kw">end</span>
317
+ 275: <span class="ruby-keyword kw">end</span>
320
318
  </pre>
321
319
  </div>
322
320
  </div>
@@ -619,13 +617,13 @@ the <a href="Helpers.html#M000021">static</a> directory on the server
619
617
  onclick="toggleCode('M000021-source');return false;">[Source]</a></p>
620
618
  <div class="method-source-code" id="M000021-source">
621
619
  <pre>
622
- <span class="ruby-comment cmt"># File lib/capcode.rb, line 283</span>
623
- 283: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">static</span>
624
- 284: {
625
- 285: <span class="ruby-identifier">:uri</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">Capcode</span>.<span class="ruby-identifier">static</span>,
626
- 286: <span class="ruby-identifier">:path</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>( <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:root</span>), <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:static</span>) ) )
627
- 287: }
628
- 288: <span class="ruby-keyword kw">end</span>
620
+ <span class="ruby-comment cmt"># File lib/capcode.rb, line 281</span>
621
+ 281: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">static</span>
622
+ 282: {
623
+ 283: <span class="ruby-identifier">:uri</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">Capcode</span>.<span class="ruby-identifier">static</span>,
624
+ 284: <span class="ruby-identifier">:path</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>( <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:root</span>), <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:static</span>) ) )
625
+ 285: }
626
+ 286: <span class="ruby-keyword kw">end</span>
629
627
  </pre>
630
628
  </div>
631
629
  </div>
data/doc/rdoc/created.rid CHANGED
@@ -1 +1 @@
1
- Tue, 01 Jun 2010 20:13:22 +0200
1
+ Wed, 02 Jun 2010 21:48:10 +0200
@@ -56,7 +56,7 @@
56
56
  </tr>
57
57
  <tr class="top-aligned-row">
58
58
  <td><strong>Last Update:</strong></td>
59
- <td>Tue Jun 01 18:08:07 +0200 2010</td>
59
+ <td>Wed Jun 02 21:45:10 +0200 2010</td>
60
60
  </tr>
61
61
  </table>
62
62
  </div>
@@ -91,6 +91,12 @@ href="http://www.algorithmique.net/capcode">www.algorithmique.net/capcode</a>/
91
91
  <a href="../classes/Capcode.html">Capcode</a> is a web microframework
92
92
  </p>
93
93
  <h2>FEATURES/PROBLEMS:</h2>
94
+ <h3>0.9.7</h3>
95
+ <ul>
96
+ <li>Major bug correction in Capcode.URL
97
+
98
+ </li>
99
+ </ul>
94
100
  <h3>0.9.6</h3>
95
101
  <ul>
96
102
  <li>More debug trace
@@ -56,7 +56,7 @@
56
56
  </tr>
57
57
  <tr class="top-aligned-row">
58
58
  <td><strong>Last Update:</strong></td>
59
- <td>Tue Jun 01 18:02:24 +0200 2010</td>
59
+ <td>Wed Jun 02 21:43:29 +0200 2010</td>
60
60
  </tr>
61
61
  </table>
62
62
  </div>
data/examples/route.rb CHANGED
@@ -9,8 +9,14 @@ module Capcode
9
9
  end
10
10
  end
11
11
 
12
+ class Home < Route '/'
13
+ def get
14
+ render :markaby => :home
15
+ end
16
+ end
17
+
12
18
  # Access via GET /index
13
- class Index < Route
19
+ class Index < Route
14
20
  def get
15
21
  render :markaby => :index
16
22
  end
@@ -51,6 +57,14 @@ module Capcode
51
57
  end
52
58
 
53
59
  module Capcode::Views
60
+ def home
61
+ html do
62
+ body do
63
+ a "Index", :href => URL(Capcode::Index); br;
64
+ a "Home", :href => URL(Capcode::Home); br;
65
+ end
66
+ end
67
+ end
54
68
  def index
55
69
  html do
56
70
  body do
data/lib/capcode.rb CHANGED
@@ -204,12 +204,10 @@ module Capcode
204
204
  def URL( klass, *a )
205
205
  path = nil
206
206
  result = {}
207
-
207
+
208
208
  a = a.delete_if{ |x| x.nil? }
209
209
 
210
210
  if klass.class == Class
211
- last_size = 0
212
-
213
211
  klass.__urls__[0].each do |cpath, regexp|
214
212
  data = a.clone
215
213
 
@@ -217,7 +215,6 @@ module Capcode
217
215
  equart = (a.size - n).abs
218
216
 
219
217
  rtable = regexp.dup.gsub( /\\\(/, "" ).gsub( /\\\)/, "" ).split( /\([^\)]*\)/ )
220
-
221
218
  rtable.each do |r|
222
219
  if r == ""
223
220
  cpath = cpath + "/#{data.shift}"
@@ -225,11 +222,12 @@ module Capcode
225
222
  cpath = cpath + "/#{r}"
226
223
  end
227
224
  end
228
-
229
- cpath = (cpath + "/" + data.join( "/" )).gsub( /\/\//, "/" ).gsub( /\/$/, "" )
225
+
226
+ cpath = (cpath + "/" + data.join( "/" )) if data.size > 0
227
+ cpath = cpath.gsub( /(\/){2,}/, "/" )
230
228
  result[equart] = cpath
231
229
  end
232
-
230
+
233
231
  path = result[result.keys.min]
234
232
  else
235
233
  path = klass
@@ -1,3 +1,3 @@
1
1
  module Capcode
2
- CAPCOD_VERION="0.9.6"
2
+ CAPCOD_VERION="0.9.7"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Capcode
3
3
  version: !ruby/object:Gem::Version
4
- hash: 55
4
+ hash: 53
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 9
9
- - 6
10
- version: 0.9.6
9
+ - 7
10
+ version: 0.9.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - "Gr\xC3\xA9goire Lejeune"
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-06-01 00:00:00 +02:00
18
+ date: 2010-06-02 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency