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
A number of useful changes:
* the specs dump any errors that occur
* Bug with push vs. unshift fixed
* Handle partial locals with nil
* A number of doc improvements
* Merb.environment specs
* Basic plugin specs
* New specs for partials
wycats (author)
Wed Jan 30 19:37:17 -0800 2008
commit  1e62bdf358d1d49027ce421b558529308f916d74
tree    b4c0fce6ab4089da7414d0609cce84d6a87f8b1f
parent  523bf7ddba24fb0b93276665e123874d83b642a1
...
1
2
3
4
5
 
 
 
 
 
 
...
1
2
3
 
4
5
6
7
8
9
10
0
@@ -1,4 +1,9 @@
0
 test_log
0
 pkg
0
 pkg/*
0
-*.log
0
\ No newline at end of file
0
+*.log
0
+log
0
+!log*.rb
0
+*/log
0
+log/*
0
+*/log/*
...
144
145
146
 
147
148
149
...
144
145
146
147
148
149
150
0
@@ -144,6 +144,7 @@ task :specs do
0
           examples += e.to_i; failures += f.to_i; pending += p.to_i
0
         end
0
       end
0
+ STDOUT.puts e.read if e.is_a?(IO)
0
     end
0
   end
0
   puts
...
6
7
8
9
 
10
11
12
...
6
7
8
 
9
10
11
12
0
@@ -6,7 +6,7 @@ require 'set'
0
 require 'fileutils'
0
 require 'socket'
0
 
0
-$LOAD_PATH.push File.dirname(__FILE__) unless
0
+$LOAD_PATH.unshift File.dirname(__FILE__) unless
0
   $LOAD_PATH.include?(File.dirname(__FILE__)) ||
0
   $LOAD_PATH.include?(File.expand_path(File.dirname(__FILE__)))
0
 
...
341
342
343
344
 
 
345
346
347
...
341
342
343
 
344
345
346
347
348
0
@@ -341,6 +341,7 @@ class Merb::AbstractController
0
   end
0
   
0
   def method_missing(sym, *args, &blk)
0
- (@_merb_partial_locals || {})[sym] || super
0
+ return @_merb_partial_locals[sym] if @_merb_partial_locals && @_merb_partial_locals.key?(sym)
0
+ super
0
   end
0
 end
0
\ No newline at end of file
...
28
29
30
31
 
32
33
34
...
36
37
38
39
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
41
42
43
 
 
 
 
 
44
45
46
47
48
 
 
 
 
 
 
 
49
50
51
52
53
 
 
 
 
 
 
 
54
55
56
...
65
66
67
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
69
70
...
127
128
129
 
 
 
130
 
 
 
 
 
 
 
 
 
131
 
 
 
132
 
 
 
133
134
135
...
28
29
30
 
31
32
33
34
...
36
37
38
 
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
 
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
...
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
...
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
0
@@ -28,7 +28,7 @@ class Merb::Controller < Merb::AbstractController
0
     # *names<~to-s>:: Actions that should be added to the list
0
     #
0
     # ==== Returns
0
- # Array<String::
0
+ # Array[String]::
0
     # An array of actions that should not be possible to dispatch to
0
     #
0
     #---
0
@@ -36,21 +36,70 @@ class Merb::Controller < Merb::AbstractController
0
     def hide_action(*names)
0
       self._hidden_actions = self._hidden_actions | names.map { |n| n.to_s }
0
     end
0
-
0
+
0
+ # Makes each of the given methods being callable as actions.
0
+ # You can use this to make methods included from modules callable
0
+ # as actions.
0
+ #
0
+ # ==== Example
0
+ # {{[
0
+ # module Foo
0
+ # def self.included(base)
0
+ # base.show_action(:foo)
0
+ # end
0
+ #
0
+ # def foo
0
+ # # some actiony stuff
0
+ # end
0
+ #
0
+ # def foo_helper
0
+ # # this should not be an action
0
+ # end
0
+ # end
0
+ # ]}}
0
+ #
0
+ # ==== Parameters
0
+ # *names<~to-s>:: Actions that should be added to the list
0
+ #
0
+ # ==== Returns
0
+ # Array[String]::
0
+ # An array of actions that should be dispatched to even if they
0
+ # would not otherwise be.
0
+ #
0
+ #---
0
+ # @public
0
     def show_action(*names)
0
       self._shown_actions = self._shown_actions | names.map {|n| n.to_s}
0
     end
0
 
0
+ # This list of actions that should not be callable
0
+ #
0
+ # ==== Returns
0
+ # Array[String]::
0
+ # An array of actions that should not be dispatchable
0
     def _hidden_actions
0
       actions = read_inheritable_attribute(:_hidden_actions)
0
       actions ? actions : write_inheritable_attribute(:_hidden_actions, [])
0
     end
0
-
0
+
0
+ # This list of actions that should be callable
0
+ #
0
+ # ==== Returns
0
+ # Array[String]::
0
+ # An array of actions that should be dispatched to even if they
0
+ # would not otherwise be.
0
     def _shown_actions
0
       actions = read_inheritable_attribute(:_shown_actions)
0
       actions ? actions : write_inheritable_attribute(:_shown_actions, [])
0
     end
0
 
0
+ # The list of actions that are callable, after taking defaults, _hidden_actions
0
+ # and _shown_actions into consideration. It is calculated once, the first time
0
+ # an action is dispatched for this controller.
0
+ #
0
+ # ==== Returns
0
+ # Array[String]::
0
+ # A list of actions that should be callable.
0
     def callable_actions
0
       @callable_actions ||= Merb::SimpleSet.new(begin
0
         callables = []
0
@@ -65,6 +114,21 @@ class Merb::Controller < Merb::AbstractController
0
     
0
   end
0
   
0
+ # The location to look for a template for a particular controller, action, and
0
+ # mime-type. This is overridden from AbstractController, which defines a version
0
+ # of this that does not involve mime-types.
0
+ #
0
+ # ==== Parameters
0
+ # action<~to_s>:: The name of the action that will be rendered
0
+ # type<~to_s>:: The mime-type of the template that will be rendered
0
+ # controller<~to_s>:: The name of the controller that will be rendered
0
+ #
0
+ # ==== Note
0
+ # By default, this renders ":controller/:action.:type". To change this, override
0
+ # it in your application class or in individual controllers.
0
+ #
0
+ #---
0
+ # @public
0
   def _template_location(action, type = nil, controller = controller_name)
0
     "#{controller}/#{action}.#{type}"
0
   end
0
@@ -127,8 +191,26 @@ class Merb::Controller < Merb::AbstractController
0
   
0
   attr_reader :request, :response, :headers
0
   attr_accessor :status
0
+
0
+ # ==== Returns
0
+ # Hash:: The parameters from the request object
0
   def params() request.params end
0
+
0
+ # ==== Returns
0
+ # Merb::Cookies::
0
+ # A new Merb::Cookies instance representing the cookies that came in
0
+ # from the request object
0
+ #
0
+ # ==== Note
0
+ # headers are passed into the cookie object so that you can do:
0
+ # cookies[:foo] = "bar"
0
   def cookies() @_cookies ||= ::Merb::Cookies.new(request.cookies, @_headers) end
0
+
0
+ # ==== Returns
0
+ # Hash:: The session that was extracted from the request object
0
   def session() request.session end
0
+
0
+ # ==== Returns
0
+ # Hash:: The route that was extracted from the request object
0
   def route() request.route end
0
 end
0
\ No newline at end of file
...
197
198
199
200
 
 
201
202
203
...
197
198
199
 
200
201
202
203
204
0
@@ -197,7 +197,8 @@ module Merb::RenderMixin
0
     # Get the method name from the previously inlined list
0
     template_method = Merb::Template.template_for(template_location)
0
 
0
- if with = opts.delete(:with)
0
+ if opts.key?(:with)
0
+ with = opts.delete(:with)
0
       as = opts.delete(:as) || template_location.match(%r[.*/_([^\.]*)])[1]
0
       @_merb_partial_locals = opts
0
       sent_template = [with].flatten.map do |temp|
...
21
22
23
 
 
 
 
 
 
24
25
26
...
35
36
37
 
 
 
 
 
 
 
38
39
40
41
42
43
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
45
46
...
21
22
23
24
25
26
27
28
29
30
31
32
...
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
 
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
0
@@ -21,6 +21,12 @@ module Merb::Test::Fixtures
0
       end
0
     end
0
 
0
+ class WithNilPartial < RenderIt
0
+ def index
0
+ render
0
+ end
0
+ end
0
+
0
     class WithAsPartial < RenderIt
0
       def index
0
         @foo = "With and As"
0
@@ -35,12 +41,34 @@ module Merb::Test::Fixtures
0
       end
0
     end
0
     
0
+ class PartialWithCollectionsAndAs < RenderIt
0
+ def index
0
+ @foo = %w{ c o l l e c t i o n }
0
+ render
0
+ end
0
+ end
0
+
0
     class PartialWithLocals < RenderIt
0
       def index
0
         @foo, @bar = %w{ local variables }
0
         render
0
       end
0
- end
0
+ end
0
+
0
+ class PartialWithBoth < RenderIt
0
+ def index
0
+ @foo = %w{ c o l l e c t i o n }
0
+ @delimiter = "-"
0
+ render
0
+ end
0
+ end
0
+
0
+ class PartialWithWithAndLocals < RenderIt
0
+ def index
0
+ @foo, @bar = "with", "and locals"
0
+ render
0
+ end
0
+ end
0
     
0
   end
0
 end
...
1
2
 
3
...
 
1
2
3
0
@@ -1 +1 @@
0
-<%= letter %>
0
\ No newline at end of file
0
+<%= collection %>
0
\ No newline at end of file
...
1
2
 
3
...
 
1
2
3
0
@@ -1 +1 @@
0
-Partial with <%= partial :collection, :with => @foo, :as => :letter %>
0
\ No newline at end of file
0
+Partial with <%= partial :collection, :with => @foo %>
0
\ No newline at end of file
...
1
2
 
3
...
 
1
2
3
0
@@ -1 +1 @@
0
-<%= with_partial %>
0
\ No newline at end of file
0
+<%= with_partial || "nil local" %>
0
\ No newline at end of file
...
9
10
11
 
 
 
 
12
13
14
...
18
19
20
 
 
 
 
21
22
23
24
 
 
 
 
 
 
 
 
25
26
...
9
10
11
12
13
14
15
16
17
18
...
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
0
@@ -9,6 +9,10 @@ describe Merb::AbstractController, " Partials" do
0
   it "should work with :with" do
0
     dispatch_should_make_body("WithPartial", "Partial with With")
0
   end
0
+
0
+ it "should work with nil :with" do
0
+ dispatch_should_make_body("WithNilPartial", "Partial with nil local")
0
+ end
0
   
0
   it "should work with :with and :as" do
0
     dispatch_should_make_body("WithAsPartial", "Partial with With and As")
0
@@ -18,8 +22,20 @@ describe Merb::AbstractController, " Partials" do
0
     dispatch_should_make_body("PartialWithCollections", "Partial with collection")
0
   end
0
   
0
+ it "should work with collections and :as" do
0
+ dispatch_should_make_body("PartialWithCollectionsAndAs", "Partial with collection")
0
+ end
0
+
0
   it "should work with key/value pairs of locals" do
0
     dispatch_should_make_body("PartialWithLocals", "Partial with local variables")
0
   end
0
   
0
+ it "should work with both collections and locals" do
0
+ dispatch_should_make_body("PartialWithBoth", "Partial with c-o-l-l-e-c-t-i-o-n-")
0
+ end
0
+
0
+ it "should work with both :with/:as and regular locals" do
0
+ dispatch_should_make_body("PartialWithWithAndLocals", "Partial with with and locals")
0
+ end
0
+
0
 end
0
\ No newline at end of file

Comments

    No one has commented yet.