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

public
Rubygem
Description: Merb Core: All you need. None you don't.
Homepage: http://www.merbivore.com
Clone URL: git://github.com/wycats/merb-core.git
Changes made to make tests fully pass
wycats (author)
Sun Jan 13 08:03:10 -0800 2008
commit  3a8c84befeacedba602125c5556bc3985be1a1d8
tree    499290c97eb6dcc1a3c8daddfd930ab6cc163359
parent  496a43b7d0b1efabc8324e88383a7cc188a5c5d5
...
1
2
 
3
4
5
...
15
16
17
18
 
 
 
 
 
19
...
1
2
3
4
5
6
...
16
17
18
 
19
20
21
22
23
24
0
@@ -1,5 +1,6 @@
0
 module Merb
0
   autoload :AbstractController, "merb_core/controller/abstract_controller"
0
+ autoload :BootLoader, "merb_core/boot/bootloader"
0
   autoload :Const, "merb_core/constants"
0
   autoload :Controller, "merb_core/controller/merb_controller"
0
   autoload :ControllerExceptions, "merb_core/controller/exceptions"
0
@@ -15,4 +16,8 @@ end
0
 
0
 # Require this rather than autoloading it so we can be sure the default templater
0
 # gets registered
0
-require "merb_core/controller/template"
0
+require "merb_core/controller/template"
0
+
0
+module Merb
0
+ module GlobalHelper; end
0
+end
0
\ No newline at end of file
...
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
...
68
69
70
 
71
72
73
...
114
115
116
117
 
118
119
120
121
122
123
 
124
125
126
127
128
 
129
130
131
...
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
...
68
69
70
71
72
73
74
...
115
116
117
 
118
119
120
121
122
123
 
124
125
126
127
128
 
129
130
131
132
0
@@ -14,25 +14,25 @@ module Merb
0
       
0
       def inherited(klass)
0
         if !klass._before && !klass._after
0
- subclasses << klass
0
+ subclasses << klass.to_s
0
         elsif klass._before
0
- subclasses.insert(subclasses.index(klass.before), klass)
0
+ subclasses.insert(subclasses.index(klass._before), klass.to_s)
0
         else
0
- subclasses.insert(subclasses.index(klass.before) + 1, klass)
0
+ subclasses.insert(subclasses.index(klass._before) + 1, klass.to_s)
0
         end
0
         super
0
       end
0
       
0
       def run
0
- subclasses.each {|klass| klass.new.run }
0
+ subclasses.each {|klass| Object.full_const_get(klass).new.run }
0
       end
0
       
0
       def after(klass)
0
- self.after = klass
0
+ self._after = klass.to_s
0
       end
0
       
0
       def before(klass)
0
- self.before = klass
0
+ self._before = klass.to_s
0
       end
0
       
0
     end
0
@@ -68,6 +68,7 @@ class Merb::BootLoader::LoadPaths < Merb::BootLoader
0
     $LOAD_PATH.unshift Merb.load_paths[:lib].first if Merb.load_paths[:lib]
0
     
0
     # Require all the files in the registered load paths
0
+ puts Merb.load_paths.inspect
0
     Merb.load_paths.each do |name, path|
0
       Dir[path.first / path.last].each do |file|
0
         klasses = ObjectSpace.classes.dup
0
@@ -114,18 +115,18 @@ class Merb::BootLoader::Templates < Merb::BootLoader
0
   
0
   def template_paths
0
     extension_glob = "{#{Merb::Template::EXTENSIONS.keys.join(',')}}"
0
-
0
+
0
     # This gets all templates set in the controllers template roots
0
     # We separate the two maps because most of controllers will have
0
     # the same _template_root, so it's silly to be globbing the same
0
     # path over and over.
0
     template_paths = Merb::AbstractController._abstract_subclasses.map do |klass|
0
- klass._template_root
0
+ Object.full_const_get(klass)._template_root
0
     end.uniq.map {|path| Dir["#{path}/**/*.#{extension_glob}"] }
0
     
0
     # This gets the templates that might be created outside controllers
0
     # template roots. eg app/views/shared/*
0
- template_paths << Dir["#{Merb.load_paths[:view]}/**/*.#{extension_glob}"]
0
+ template_paths << Dir["#{Merb.load_paths[:view]}/**/*.#{extension_glob}"] if Merb.load_paths[:view]
0
     
0
     template_paths.flatten.compact.uniq
0
   end
...
61
62
63
64
65
66
67
...
101
102
103
104
 
105
106
107
108
109
110
111
112
113
114
115
 
 
116
117
118
 
119
120
121
...
131
132
133
134
 
135
136
137
...
155
156
157
158
159
160
161
162
163
164
165
 
 
166
167
168
...
182
183
184
185
 
186
187
188
...
195
196
197
198
199
 
 
200
201
202
...
212
213
214
215
 
216
217
218
...
61
62
63
 
64
65
66
...
100
101
102
 
103
104
105
106
107
108
 
109
110
111
112
113
114
115
116
117
 
118
119
120
121
...
131
132
133
 
134
135
136
137
...
155
156
157
 
 
158
159
160
161
 
 
162
163
164
165
166
...
180
181
182
 
183
184
185
186
...
193
194
195
 
 
196
197
198
199
200
...
210
211
212
 
213
214
215
216
0
@@ -61,7 +61,6 @@
0
 # Filter:: <Array[Symbol, (Symbol, String, Proc)]>
0
 class Merb::AbstractController
0
   include Merb::RenderMixin
0
- include Merb::GeneralControllerMixin
0
   
0
   class_inheritable_accessor :_before_filters, :_after_filters, :_template_root
0
   self._before_filters, self._after_filters = [], []
0
@@ -101,21 +100,22 @@ class Merb::AbstractController
0
     end
0
   end
0
   
0
- attr_accessor :_benchmarks, :_thrown_content
0
+ attr_accessor :_benchmarks, :_thrown_content, :_body
0
   
0
   # ==== Parameters
0
   # *args<Object>:: The args are ignored
0
   def initialize(*args)
0
     @_benchmarks = {}
0
- @thrown_content = AbstractController._default_thrown_content
0
   end
0
   
0
   # ==== Parameters
0
   # action<~to_s>:: The action to dispatch to. This will be #send'ed in _call_action
0
   def _dispatch(action=:to_s)
0
+ @action = action
0
+
0
     caught = catch(:halt) do
0
       start = Time.now
0
- result = _call_filters(_before_filters)
0
+ result = _call_filters(_before_filters.reverse)
0
       @_benchmarks[:before_filters_time] = Time.now - start if _before_filters
0
       result
0
     end
0
@@ -131,7 +131,7 @@ class Merb::AbstractController
0
     end
0
     start = Time.now
0
     _call_filters(_after_filters)
0
- @_benchmarks[:after_filters_time] = Time.now - start if after_filters
0
+ @_benchmarks[:after_filters_time] = Time.now - start if _after_filters
0
   end
0
   
0
   # This method exists to provide an overridable hook for ActionArgs
0
@@ -155,14 +155,12 @@ class Merb::AbstractController
0
   # * execute the +Proc+, in the context of the controller (self will
0
   # be the controller)
0
   def _call_filters(filter_set)
0
- action = params[:action].intern
0
-
0
     (filter_set || []).each do |filter, rule|
0
       # Both:
0
       # * no :only or the current action is in the :only list
0
       # * no :exclude or the current action is not in the :exclude list
0
- if (!rule.key?(:only) || rule[:only].include?(action)) &&
0
- (!rule.key?(:exclude) || !rule[:exclude].include?(action))
0
+ if (!rule.key?(:only) || rule[:only].include?(@action)) &&
0
+ (!rule.key?(:exclude) || !rule[:exclude].include?(@action))
0
         case filter
0
         when Symbol, String then send(filter)
0
         when Proc then self.instance_eval(&filter)
0
@@ -182,7 +180,7 @@ class Merb::AbstractController
0
   # ==== Note
0
   # If the filter already exists, its options will be replaced
0
   # with opts
0
- def self.after(filter, opts = {})
0
+ def self.after(filter = nil, opts = {}, &block)
0
     add_filter(self._after_filters, filter, opts)
0
   end
0
 
0
@@ -195,8 +193,8 @@ class Merb::AbstractController
0
   #
0
   # ==== Note
0
   # If the filter already exists, its options will be replaced with opts
0
- def self.before(filter, opts = {})
0
- add_filter(self._before_filters, filter, opts)
0
+ def self.before(filter = nil, opts = {}, &block)
0
+ add_filter(self._before_filters, filter || block, opts)
0
   end
0
      
0
   # Skip an after filter that has been previously defined (perhaps in a superclass)
0
@@ -212,7 +210,7 @@ class Merb::AbstractController
0
   # ==== Parameters
0
   # filter<Symbol>:: A filter name to skip
0
   def self.skip_before(filter)
0
- skip_filter(self._before_filters, filter)
0
+ skip_filter(self._before_filters , filter)
0
   end
0
   
0
   #---
...
18
19
20
21
 
22
23
24
...
35
36
37
 
 
38
39
40
...
44
45
46
 
 
47
48
49
...
61
62
63
 
 
64
65
66
...
18
19
20
 
21
22
23
24
...
35
36
37
38
39
40
41
42
...
46
47
48
49
50
51
52
53
...
65
66
67
68
69
70
71
72
0
@@ -18,7 +18,7 @@ module Merb::Template
0
     # character replaced based on the non-alphanumeric character
0
     # to avoid edge-case collisions.
0
     def template_name(path)
0
- path.gsub(/[^\.a-zA-Z0-9]/, "__").gsub(/\./, "_")
0
+ path.gsub(/[^\.a-zA-Z0-9]/, "__").gsub(/\./, "_")
0
     end
0
     
0
     # Takes a template at a particular path and inlines it into
0
@@ -35,6 +35,8 @@ module Merb::Template
0
     # Even though this method supports inlining into any module,
0
     # the method must be available to instances of AbstractController
0
     # that will use it.
0
+ #---
0
+ # @public
0
     def inline_template(path, mod = Merb::GlobalHelper)
0
       METHOD_LIST[path.gsub(/\.[^\.]*$/, "")] =
0
         engine_for(path).compile_template(path, template_name(path), mod)
0
@@ -44,6 +46,8 @@ module Merb::Template
0
     #
0
     # ==== Parameters
0
     # path<String>:: The path of the file to find an engine for
0
+ #---
0
+ # @semipublic
0
     def engine_for(path)
0
       EXTENSIONS[path.match(/\.([^\.]*)$/)[1]]
0
     end
0
@@ -61,6 +65,8 @@ module Merb::Template
0
     # {{[
0
     # Merb::Template.register_extensions(Merb::Template::Erubis, ["erb"])
0
     # ]}}
0
+ #---
0
+ # @public
0
     def register_extensions(engine, extensions) enforce!(engine => Class, extensions => Array)
0
       raise ArgumentError, "The class you are registering does not have a compile_template method" unless
0
         engine.respond_to?(:compile_template)

Comments

    No one has commented yet.