markevans-block_helpers 0.2.0 → 0.2.1
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/README.markdown +3 -3
- data/VERSION +1 -1
- data/block_helpers.gemspec +2 -2
- data/lib/block_helpers.rb +20 -4
- data/spec/helpers/block_helpers_spec.rb +6 -6
- metadata +4 -3
data/README.markdown
CHANGED
@@ -22,7 +22,7 @@ In the helper file:
|
|
22
22
|
|
23
23
|
module MyHelper
|
24
24
|
|
25
|
-
class MyBlockHelper <
|
25
|
+
class MyBlockHelper < ActionView::BlockHelper
|
26
26
|
|
27
27
|
def hello(name)
|
28
28
|
"<p>Hi there #{name}!</p>"
|
@@ -55,7 +55,7 @@ In the helper:
|
|
55
55
|
|
56
56
|
module MyHelper
|
57
57
|
|
58
|
-
class MyBlockHelper <
|
58
|
+
class MyBlockHelper < ActionView::BlockHelper
|
59
59
|
|
60
60
|
def initialize(tag_type)
|
61
61
|
@tag_type = tag_type
|
@@ -89,7 +89,7 @@ In the helper:
|
|
89
89
|
|
90
90
|
module MyHelper
|
91
91
|
|
92
|
-
class RoundedBox <
|
92
|
+
class RoundedBox < ActionView::BlockHelper
|
93
93
|
|
94
94
|
def to_s(body)
|
95
95
|
%(
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.1
|
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.1"
|
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-
|
9
|
+
s.date = %q{2009-08-12}
|
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
@@ -1,14 +1,14 @@
|
|
1
1
|
require 'activesupport'
|
2
2
|
require 'action_view'
|
3
3
|
|
4
|
-
module
|
4
|
+
module ActionView
|
5
5
|
|
6
6
|
class BlockHelper
|
7
7
|
|
8
8
|
def self.inherited(klass)
|
9
9
|
# Define the helper method
|
10
10
|
# e.g. for a class:
|
11
|
-
# class HelloHelper <
|
11
|
+
# class HelloHelper < ActionView::BlockHelper
|
12
12
|
# #.....
|
13
13
|
# end
|
14
14
|
#
|
@@ -25,9 +25,25 @@ module BlockHelpers
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
)
|
28
|
+
|
29
|
+
# Make a 'helper' object available, for calling
|
30
|
+
# other helper methods / action view helpers
|
28
31
|
klass.class_eval do
|
29
|
-
|
30
|
-
|
32
|
+
|
33
|
+
protected
|
34
|
+
define_method :helper do
|
35
|
+
if @helper.nil?
|
36
|
+
@helper = Object.new
|
37
|
+
# Open the singleton class of @helper, while
|
38
|
+
# keeping 'klass' visible
|
39
|
+
class << @helper; self; end.class_eval do
|
40
|
+
include klass.parent
|
41
|
+
include ActionView::Helpers
|
42
|
+
end
|
43
|
+
end
|
44
|
+
@helper
|
45
|
+
end
|
46
|
+
|
31
47
|
end
|
32
48
|
end
|
33
49
|
|
@@ -8,7 +8,7 @@ describe TestHelperModule do
|
|
8
8
|
describe "simple block_helper" do
|
9
9
|
|
10
10
|
before(:each) do
|
11
|
-
class TestHelperModule::TestHelper <
|
11
|
+
class TestHelperModule::TestHelper < ActionView::BlockHelper
|
12
12
|
def hello
|
13
13
|
'Hi there'
|
14
14
|
end
|
@@ -31,16 +31,16 @@ describe TestHelperModule do
|
|
31
31
|
|
32
32
|
end
|
33
33
|
|
34
|
-
describe "access to other methods" do
|
34
|
+
describe "access to other methods via 'helper'" do
|
35
35
|
before(:each) do
|
36
36
|
module TestHelperModule
|
37
37
|
def yoghurt; 'Yoghurt'; end
|
38
38
|
class TestHelper
|
39
39
|
def yog
|
40
|
-
yoghurt[0..2]
|
40
|
+
helper.yoghurt[0..2]
|
41
41
|
end
|
42
42
|
def jelly_in_div
|
43
|
-
content_tag :div, 'jelly'
|
43
|
+
helper.content_tag :div, 'jelly'
|
44
44
|
end
|
45
45
|
end
|
46
46
|
end
|
@@ -64,7 +64,7 @@ describe TestHelperModule do
|
|
64
64
|
describe "surrounding the block" do
|
65
65
|
|
66
66
|
before(:each) do
|
67
|
-
class TestHelperModule::TestHelperSurround <
|
67
|
+
class TestHelperModule::TestHelperSurround < ActionView::BlockHelper
|
68
68
|
def to_s(body)
|
69
69
|
%(
|
70
70
|
<p>Before</p>
|
@@ -86,7 +86,7 @@ describe TestHelperModule do
|
|
86
86
|
|
87
87
|
describe "block helpers with arguments" do
|
88
88
|
before(:each) do
|
89
|
-
class TestHelperModule::TestHelperWithArgs <
|
89
|
+
class TestHelperModule::TestHelperWithArgs < ActionView::BlockHelper
|
90
90
|
def initialize(id, klass)
|
91
91
|
@id, @klass = id, klass
|
92
92
|
end
|
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.1
|
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-
|
12
|
+
date: 2009-08-12 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -55,6 +55,7 @@ files:
|
|
55
55
|
- spec/spec_helper.rb
|
56
56
|
has_rdoc: true
|
57
57
|
homepage: http://github.com/markevans/block_helpers
|
58
|
+
licenses:
|
58
59
|
post_install_message:
|
59
60
|
rdoc_options:
|
60
61
|
- --charset=UTF-8
|
@@ -75,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
75
76
|
requirements: []
|
76
77
|
|
77
78
|
rubyforge_project:
|
78
|
-
rubygems_version: 1.
|
79
|
+
rubygems_version: 1.3.5
|
79
80
|
signing_key:
|
80
81
|
specification_version: 2
|
81
82
|
summary: TODO
|