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
Updated pretty_urls to match the new mappings.
dyoder (author)
Sun Jun 29 18:41:05 -0700 2008
commit  1fb8c50cd8dd7cef7d12002c14186a54169d0ef4
tree    dc845ad49b95c4b632fd10f0ad3004a9792a0a2d
parent  7868bc5964b677d0db04772eaca809995f965031
...
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
 
 
39
40
41
...
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
 
 
 
71
72
73
...
20
21
22
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
24
25
26
27
...
36
37
38
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
40
41
42
43
44
0
@@ -20,22 +20,8 @@ module Waves
0
       module GetRules
0
 
0
         def self.included(target)
0
-
0
- target.module_eval do
0
-
0
- extend Waves::Mapping
0
-
0
- path '/{resource}', :named => :all, :method => :get,
0
- :action => lambda { | resource | with( resource ).all and render( :list ) }
0
-
0
- path '/{resource}/{name}', :named => :get, :method => :get,
0
- :action => lambda { | resource, name | with( resource ).find( name ) and render( :show ) }
0
-
0
- path '/{resource}/{name}/editor', :named => :editor, :method => :get,
0
- :action => lambda { | resource, name | with( resource ).find( name ) and render( :editor ) }
0
-
0
- end
0
-
0
+ target.action( :list, :get => [ :resources ] ) { action( :all ) and render( :list ) }
0
+ target.action( :read, :get => [ :resource, :name, { :mode => 'show' } ] ) { action( :find, name ) and render( mode ) }
0
         end
0
 
0
       end
0
@@ -50,24 +36,9 @@ module Waves
0
       module RestRules
0
 
0
         def self.included(target)
0
-
0
- target.module_eval do
0
-
0
- extend Waves::Mapping
0
-
0
- path '/{resource}', :named => :create, :method => :post do | resource |
0
- with( resource ).create and redirect( :editor, :resource => resource, :name => instance.name )
0
- end
0
-
0
- path '/{resource}/{name}', :named => :update, :method => :put do | resource, name |
0
- with(resource).update( name ) and redirect( :show, :resource => resource, :name => name )
0
- end
0
-
0
- path '/{resource}/{name}', :named => :delete, :method => :delete,
0
- :action => lambda { | resource, name | with( resource ).delete( name ) }
0
-
0
- end
0
-
0
+ target.action( :create, :post => [ :resources ] ) { redirect( paths.read( action( :create ).name, 'edit' ) ) }
0
+ target.action( :update, :put => [ :resource, :name ] ) { action( :update, name ) and redirect( paths.read( name ) ) }
0
+ target.action( :delete, :delete => [ :resource, :name ] ) { action( :delete, name ) }
0
         end
0
 
0
       end
...
10
11
12
13
14
 
 
15
16
17
...
10
11
12
 
 
13
14
15
16
17
0
@@ -10,8 +10,8 @@ describe "The plural form of a resource" do
0
   end
0
   
0
   it "can be specified with a grabby-thingy in the Pattern" do
0
- mapping.with :accepts => 'text/<format>' do
0
- path :list, :get => '/<resources>'
0
+ mapping.with :accepts => [ /(\w+)/ ] do
0
+ path :list, :get => [ :resources ]
0
     end
0
   end
0
   
...
5
6
7
8
9
10
 
 
11
12
13
14
15
 
16
17
18
19
...
5
6
7
 
 
 
8
9
10
11
12
13
 
14
15
16
17
18
0
@@ -5,14 +5,13 @@ describe "A Mapping that specifies the resource in the with()" do
0
   
0
   before do
0
     mapping.with :resource => :smurf do
0
- path( :list, :get => '/smurves' ) { "smurfy" }
0
- path( :single, :get => '/smurf/<name>' ) { "not smurfy" }
0
- # path :multiple, :get => ['/smurf/<name>', '/smurf/<name>.<ext>']
0
+ action( :list, :get => [ 'smurves' ] ) { "smurfy" }
0
+ action( :single, :get => [ 'smurf', :name ] ) { "not smurfy" }
0
     end
0
   end
0
   
0
   it "works miracles" do
0
- request.get( '/smurves' )
0
+ request.get( '/smurves' ).should == "smurfy"
0
   end
0
   
0
 end
0
\ No newline at end of file

Comments

    No one has commented yet.