markevans-block_helpers 0.2.8 → 0.2.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/block_helpers.gemspec +2 -2
- data/lib/block_helpers.rb +5 -3
- data/spec/helpers/block_helpers_spec.rb +29 -7
- metadata +3 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.10
|
data/block_helpers.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{block_helpers}
|
5
|
-
s.version = "0.2.
|
5
|
+
s.version = "0.2.10"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Mark Evans"]
|
9
|
-
s.date = %q{2009-08-
|
9
|
+
s.date = %q{2009-08-26}
|
10
10
|
s.email = %q{mark@new-bamboo.co.uk}
|
11
11
|
s.extra_rdoc_files = [
|
12
12
|
"LICENSE",
|
data/lib/block_helpers.rb
CHANGED
@@ -19,14 +19,16 @@ module BlockHelpers
|
|
19
19
|
renderer = #{klass.name}.new(*args)
|
20
20
|
renderer.send(:helper=, self)
|
21
21
|
if renderer.public_methods(false).include? 'display'
|
22
|
+
body = block ? capture(renderer, &block) : nil
|
22
23
|
if method(:concat).arity == 1
|
23
|
-
concat renderer.display(
|
24
|
+
concat renderer.display(body)
|
24
25
|
else
|
25
|
-
concat renderer.display(
|
26
|
+
concat renderer.display(body), binding
|
26
27
|
end
|
27
28
|
else
|
28
|
-
block.call(renderer)
|
29
|
+
block.call(renderer) if block
|
29
30
|
end
|
31
|
+
renderer
|
30
32
|
end
|
31
33
|
)
|
32
34
|
end
|
@@ -32,6 +32,19 @@ describe TestHelperModule do
|
|
32
32
|
)).should match_html("<p>Before</p> Hi there <p>After</p>")
|
33
33
|
end
|
34
34
|
|
35
|
+
it "should do nothing if no block given" do
|
36
|
+
eval_erb(%(
|
37
|
+
<% test_helper %>
|
38
|
+
)).should match_html("")
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should return itself (the renderer object)" do
|
42
|
+
eval_erb(%(
|
43
|
+
<% e = test_helper %>
|
44
|
+
<%= e.hello %>
|
45
|
+
)).should match_html('Hi there')
|
46
|
+
end
|
47
|
+
|
35
48
|
end
|
36
49
|
|
37
50
|
describe "access to other methods" do
|
@@ -131,7 +144,7 @@ describe TestHelperModule do
|
|
131
144
|
it "should work when concat has two args" do
|
132
145
|
module TestHelperModule
|
133
146
|
def concat(html, binding); super(html); end
|
134
|
-
remove_const(:CompatHelper) if defined?(
|
147
|
+
remove_const(:CompatHelper) if defined?(CompatHelper)
|
135
148
|
class CompatHelper < BlockHelpers::Base
|
136
149
|
def display(body)
|
137
150
|
"Before...#{body}...after"
|
@@ -143,7 +156,7 @@ describe TestHelperModule do
|
|
143
156
|
it "should work when concat has one optional arg" do
|
144
157
|
module TestHelperModule
|
145
158
|
def concat(html, binding=nil); super(html); end
|
146
|
-
remove_const(:CompatHelper) if defined?(
|
159
|
+
remove_const(:CompatHelper) if defined?(CompatHelper)
|
147
160
|
class CompatHelper < BlockHelpers::Base
|
148
161
|
def display(body)
|
149
162
|
"Before...#{body}...after"
|
@@ -161,11 +174,15 @@ describe TestHelperModule do
|
|
161
174
|
remove_const(:TestHelperSurround) if defined?(TestHelperSurround)
|
162
175
|
class TestHelperSurround < BlockHelpers::Base
|
163
176
|
def display(body)
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
177
|
+
if body.nil?
|
178
|
+
"This is nil!"
|
179
|
+
else
|
180
|
+
%(
|
181
|
+
<p>Before</p>
|
182
|
+
#{body}
|
183
|
+
<p>After</p>
|
184
|
+
)
|
185
|
+
end
|
169
186
|
end
|
170
187
|
end
|
171
188
|
end
|
@@ -178,6 +195,11 @@ describe TestHelperModule do
|
|
178
195
|
<% end %>
|
179
196
|
)).should match_html("<p>Before</p> Body here!!! <p>After</p>")
|
180
197
|
end
|
198
|
+
it "should pass in the body as nil if no block given" do
|
199
|
+
eval_erb(%(
|
200
|
+
<% test_helper_surround %>
|
201
|
+
)).should match_html("This is nil!")
|
202
|
+
end
|
181
203
|
end
|
182
204
|
|
183
205
|
describe "block helpers with arguments" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: markevans-block_helpers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Evans
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-08-
|
12
|
+
date: 2009-08-26 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -45,7 +45,6 @@ files:
|
|
45
45
|
- spec/spec_helper.rb
|
46
46
|
has_rdoc: true
|
47
47
|
homepage: http://github.com/markevans/block_helpers
|
48
|
-
licenses:
|
49
48
|
post_install_message:
|
50
49
|
rdoc_options:
|
51
50
|
- --charset=UTF-8
|
@@ -66,7 +65,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
66
65
|
requirements: []
|
67
66
|
|
68
67
|
rubyforge_project:
|
69
|
-
rubygems_version: 1.
|
68
|
+
rubygems_version: 1.2.0
|
70
69
|
signing_key:
|
71
70
|
specification_version: 2
|
72
71
|
summary: An extension to ActionView for adding block helpers to views
|