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
Moved Waves::Application to Waves::Runtime and refactored module accessors 
for use with multi-app.
dyoder (author)
Mon Jul 28 00:39:47 -0700 2008
commit  9fd2732e01366360a5a4866f20c1a2b921c1b77b
tree    ade5c9d4b20332cfa601b8c4fb40e618fb578034
parent  7d914001d5880a7d97e96c8d3a21a9544dcacce7
...
127
128
129
130
 
131
132
133
...
127
128
129
 
130
131
132
133
0
@@ -127,7 +127,7 @@ module Waves
0
       #
0
       # to find an instance of a given model. Again, the plurality of the controller and
0
       # model must be the same for this to work.
0
- def model; models[ model_name.intern ]; end
0
+ def model; app::Models[ model_name.intern ]; end
0
       
0
       def attributes; params[model_name.singular.intern]; end
0
       
...
33
34
35
36
 
37
38
39
...
43
44
45
46
 
47
48
49
...
33
34
35
 
36
37
38
39
...
43
44
45
 
46
47
48
49
0
@@ -33,7 +33,7 @@ module Waves
0
       # that takes an +env+ parameter.
0
       def call( env )
0
         if Waves.config.synchronize?
0
- Waves::Application.instance.synchronize { _call( env ) }
0
+ Waves::Runtime.instance.synchronize { _call( env ) }
0
         else
0
           _call( env )
0
         end
0
@@ -43,7 +43,7 @@ module Waves
0
       # the server should run the request in a separate thread, as determined by
0
       # Configurations::Mapping#threaded?
0
       def deferred?( env )
0
- Waves::Application.instance.mapping.threaded?( env )
0
+ Waves::Runtime.instance.mapping.threaded?( env )
0
       end
0
       
0
       private
...
30
31
32
33
34
 
 
35
36
37
...
30
31
32
 
 
33
34
35
36
37
0
@@ -30,8 +30,8 @@ module Waves
0
 
0
         response = request.response
0
 
0
- Waves::Application.instance.reload if Waves::Application.instance.debug?
0
- response.content_type = Waves::Application.instance.config.mime_types[ request.path ] || 'text/html'
0
+ Waves.reload if Waves.debug?
0
+ response.content_type = Waves.config.mime_types[ request.path ] || 'text/html'
0
 
0
         mapping = Waves.mapping[ request ]
0
 
...
60
61
62
 
 
 
63
64
65
...
60
61
62
63
64
65
66
67
68
0
@@ -60,6 +60,9 @@ module Waves
0
       # The doctype method simply generates a valid DOCTYPE declaration for your page.
0
       # Valid options are defined in the +DOCTYPES+ constant.
0
       def doctype(type) ; self << DOCTYPES[type||:html4_strict] ; end
0
+
0
+ # interesting hack ...
0
+ def app_name ; Dir.pwd.split('/').last ; end
0
 
0
     end
0
   end
...
15
16
17
18
 
19
20
21
...
15
16
17
 
18
19
20
21
0
@@ -15,7 +15,7 @@ module Waves
0
       
0
       # Invokes the view for the given model, passing the assigns as instance variables.
0
       def view( model, view, assigns = {} )
0
- self << views[ model ].process( request ) do
0
+ self << app::Views[ model ].process( request ) do
0
           send( view, assigns )
0
         end
0
       end
...
53
54
55
56
57
 
 
58
59
60
...
65
66
67
68
69
70
71
72
73
74
75
76
77
78
 
79
80
81
...
53
54
55
 
 
56
57
58
59
60
...
65
66
67
 
 
 
 
 
 
 
 
 
 
 
68
69
70
71
0
@@ -53,8 +53,8 @@ module Waves
0
           auto_create_class :Default, Waves::Resources::Base
0
           auto_load :Default, :directories => [ :resources ]
0
           auto_eval :Default do
0
- def controller ; @controller ||= controllers[ singular ].process( @request ) { self } ; end
0
- def view ; @view ||= views[ singular ].process( @request ) { self } ; end
0
+ def controller ; @controller ||= app::Controllers[ singular ].process( @request ) { self } ; end
0
+ def view ; @view ||= app::Views[ singular ].process( @request ) { self } ; end
0
             def action( method, *args ) ; @data = controller.send( method, *args ) ; end
0
             def render( method, assigns = nil )
0
               assigns ||= { ( @data.kind_of?( Enumerable ) ? plural : singular ) => @data }
0
@@ -65,17 +65,7 @@ module Waves
0
           auto_create_class true, app::Resources::Default
0
           auto_load true, :directories => [ :resources ]
0
         end
0
-
0
- lambda {
0
- string_or_symbol = lambda { |arg| arg.kind_of?(String) || arg.kind_of?(Symbol) }
0
- Waves::ResponseMixin.module_eval do
0
- [ :models, :controllers, :views, :helpers ].each do |k|
0
- functor( k ) { app[ k ] }
0
- functor( k, string_or_symbol ) { |name| app( name )[ k ] }
0
- end
0
- end
0
- }.call
0
-
0
+
0
       end
0
     end
0
   end
...
14
15
16
17
18
19
 
20
21
22
...
14
15
16
 
 
 
17
18
19
20
0
@@ -14,9 +14,7 @@ module Waves
0
     module Simple
0
       def self.included( app )
0
 
0
- def app.config ; Waves.config ; end
0
- def app.configurations ; self::Configurations ; end
0
- def app.resources ; self::Resources ; end
0
+ def app.paths( r ) ; self::Resources[ r ]::Paths ; end
0
         
0
         app.instance_eval { include AutoCode }
0
         
...
7
8
9
10
11
12
13
...
25
26
27
28
29
 
30
31
32
...
7
8
9
 
10
11
12
...
24
25
26
 
 
27
28
29
30
0
@@ -7,7 +7,6 @@ module Waves
0
       attr_reader :request
0
 
0
       include ResponseMixin
0
- include Functor::Method
0
       
0
       def self.included( target )
0
         parent = target.superclass
0
@@ -25,8 +24,7 @@ module Waves
0
       def plural ; self.class.plural ; end
0
       def redirect( path ) ; request.redirect( path ) ; end
0
       
0
- functor( :paths ) { self.class.paths }
0
-
0
+ def paths ; self.class.paths ; end
0
     end
0
       
0
     # :)
...
1
2
3
 
4
5
6
...
1
2
 
3
4
5
6
0
@@ -1,6 +1,6 @@
0
 module Waves
0
 
0
- class Console < Application
0
+ class Console < Runtime
0
 
0
     class << self
0
 
...
6
7
8
9
10
11
12
...
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
 
 
43
44
45
...
6
7
8
 
9
10
11
...
27
28
29
 
 
 
 
 
 
 
 
 
 
 
 
30
31
32
33
34
0
@@ -6,7 +6,6 @@ module Waves
0
   #
0
   # This mixin assumes that a @request@ accessor already exists.
0
   module ResponseMixin
0
- include Functor::Method
0
     # Access the response.
0
     def response; request.response; end
0
     # Access the request parameters.
0
@@ -28,18 +27,8 @@ module Waves
0
     # Access the Blackboard
0
     def blackboard; request.blackboard; end
0
     # access stuff from an app
0
- def app_name ; self.name.split('::').first.snake_case.to_sym ; end
0
-
0
- lambda {
0
- string_or_symbol = lambda { |arg| arg.kind_of?(String) || arg.kind_of?(Symbol) }
0
- functor( :app ) { app( app_name ) }
0
- functor( :app, string_or_symbol ) { |name| Waves.applications[ name ] }
0
- functor( :resources ) { app[ :resources ] }
0
- functor( :resources, string_or_symbol ) { |name| app( name )[ :resources ] }
0
- functor( :paths, string_or_symbol ) { |rname| resources[ rname ].paths }
0
- functor( :paths, string_or_symbol, string_or_symbol ) { |aname, rname| resources( aname )[ rname ].paths }
0
- }.call
0
-
0
+ def app_name ; self.class.name.split('::').first.snake_case.to_sym ; end
0
+ def app ; eval( "::#{app_name.to_s.camel_case}" ) ; end
0
   end
0
 
0
 end
...
19
20
21
22
 
23
24
25
...
19
20
21
 
22
23
24
25
0
@@ -19,7 +19,7 @@ module Waves
0
   #
0
   # The +cluster:stop+ task stops all of the instances.
0
   #
0
- class Server < Application
0
+ class Server < Runtime
0
 
0
     # Access the server thread.
0
     attr_reader :thread
...
27
28
29
30
 
31
32
33
...
27
28
29
 
30
31
32
33
0
@@ -27,7 +27,7 @@ module Waves
0
     end
0
     
0
     def self.base_path
0
- Waves.application.config.session[:path]
0
+ Waves.config.session[:path]
0
     end
0
 
0
     # Save the session data. You shouldn't typically have to call this directly, since it
...
42
43
44
45
 
46
47
48
...
42
43
44
 
45
46
47
48
0
@@ -42,7 +42,7 @@ require 'dispatchers/base'
0
 require 'dispatchers/default'
0
 require 'runtime/logger'
0
 require 'runtime/mime_types'
0
-require 'runtime/application'
0
+require 'runtime/runtime'
0
 require 'runtime/console'
0
 require 'runtime/debugger'
0
 require 'runtime/server'

Comments

    No one has commented yet.