GitHub Sale: sign up for any paid plan this week and pay nothing until January 1, 2009!  [ hide ]

public
Rubygem
Description: Resource-oriented open source Ruby framework for Web apps.
Homepage: http://rubywaves.com/
Clone URL: git://github.com/dyoder/waves.git
undo switch from pop to shift, 'cause something's fishy
automatthew (author)
Sun Sep 21 13:44:21 -0700 2008
commit  d15842d37317b3fa78024010894b7ffeac3124d8
tree    ef2959a61f7b438c272a5387f9db02d048c8c477
parent  11ca17d0f1c534779eba7102de74b0bf0e6f0b16
...
14
15
16
17
 
18
19
20
21
22
23
24
25
 
 
 
26
27
28
29
30
31
 
32
33
34
35
 
36
37
38
 
39
40
41
...
14
15
16
 
17
18
19
20
21
22
 
 
 
23
24
25
26
27
28
29
30
 
31
32
33
34
 
35
36
37
 
38
39
40
41
0
@@ -14,28 +14,28 @@ module Waves
0
       def call( request )
0
         # TODO: refactor terminating conditions - these work but don't make sense
0
         return {} if @pattern == true
0
- path = extract_path( request )
0
+ path = extract_path( request ).reverse
0
         return {} if ( @pattern.nil? or @pattern == false or ( path.empty? and @pattern.empty? ) )
0
         capture = {}
0
         match = @pattern.all? do | want |
0
           case want
0
           when true then path = []
0
- when String then want == path.shift
0
- when Symbol then capture[ want ] = path.shift
0
- when Regexp then want === path.shift
0
+ when String then want == path.pop
0
+ when Symbol then capture[ want ] = path.pop
0
+ when Regexp then want === path.pop
0
           when Hash
0
             key, value = want.to_a.first
0
             case value
0
             when true then
0
               unless path.empty?
0
- capture[ key ] = path
0
+ capture[ key ] = path.reverse
0
                 path = []
0
               end
0
             when String, Symbol
0
- got = path.shift
0
+ got = path.pop
0
               capture[ key ] = got ? got : value.to_s
0
             when Regexp then
0
- got = path.shift
0
+ got = path.pop
0
               capture[ key ] = got if value === got
0
             end
0
           end
...
1
2
3
4
5
6
7
8
 
 
 
 
9
10
11
12
 
 
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
44
45
...
1
2
3
 
 
 
 
 
4
5
6
7
8
9
 
 
10
11
12
13
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
0
@@ -1,45 +1,35 @@
0
 module Blog
0
   module Resources
0
     class Entry < Default
0
-
0
- raise "got to resource"
0
-
0
- on :get, :list => [ ] do
0
- raise "list"
0
+
0
+
0
+ on :get, :list => [ 'entry' ] do
0
+ view.list( plural => controller.all )
0
       end
0
       
0
- on :get, :show => [ :name ] do
0
- raise "show: #{captured.name}"
0
+ on :get, :show => [ 'entry', :name ] do
0
+ view.show( singular => controller.find( query.name ) )
0
       end
0
       
0
- #
0
- # on :get, :list => [ ] do
0
- # view.list( plural => controller.all )
0
- # end
0
- #
0
- # on :get, :show => [ :name ] do
0
- # view.show( singular => controller.find( query.name ) )
0
- # end
0
- #
0
- # on :get, :edit => [ :name, 'edit' ] do
0
- # view.edit( singular => controller.find( query.name ) )
0
- # end
0
- #
0
- # on :put, :update => [ :name ] do
0
- # controller.update( query.name )
0
- # redirect "/entry/#{query.name}"
0
- # end
0
- #
0
- # on :post, :create => [ ] do
0
- # redirect "/entry/#{controller.create.name}/edit"
0
- # end
0
- #
0
- # on :post, :comment => [ :name ] do
0
- # entry = controller.find( query.name )
0
- # comment = Models::Comment.create( query.comment.to_hash )
0
- # entry.add_comment( comment )
0
- # redirect request.path
0
- # end
0
+ on :get, :edit => [ 'entry', :name, 'edit' ] do
0
+ view.edit( singular => controller.find( query.name ) )
0
+ end
0
+
0
+ on :put, :update => [ 'entry', :name ] do
0
+ controller.update( query.name )
0
+ redirect "/entry/#{query.name}"
0
+ end
0
+
0
+ on :post, :create => [ 'entry' ] do
0
+ redirect "/entry/#{controller.create.name}/edit"
0
+ end
0
+
0
+ on :post, :comment => [ 'entry', :name ] do
0
+ entry = controller.find( query.name )
0
+ comment = Models::Comment.create( query.comment.to_hash )
0
+ entry.add_comment( comment )
0
+ redirect request.path
0
+ end
0
       
0
     end
0
   end

Comments

    No one has commented yet.