simple_show 0.0.1 → 0.0.2
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.rdoc +5 -5
- data/lib/simple_show/base.rb +2 -2
- data/lib/simple_show/version.rb +1 -1
- data/test/test_simple_show_for.rb +3 -3
- data/test/test_simple_show_label.rb +8 -4
- data/test/test_simple_show_value.rb +9 -5
- metadata +3 -3
data/README.rdoc
CHANGED
@@ -29,11 +29,11 @@ Run the generator:
|
|
29
29
|
Assume we have a Person object with name, phone, email, born_on, etc.
|
30
30
|
In our show action we can then do this:
|
31
31
|
|
32
|
-
<%= simple_show_for @johndoe do |
|
33
|
-
<%=
|
34
|
-
<%=
|
35
|
-
<%=
|
36
|
-
<%=
|
32
|
+
<%= simple_show_for @johndoe do |s| %>
|
33
|
+
<%= s.show :name %>
|
34
|
+
<%= s.show :phone, :label => 'Telephone' %>
|
35
|
+
<%= s.show(:email) {|o| o.email.downcase} %>
|
36
|
+
<%= s.show :born_on, :value => '**censored**' %>
|
37
37
|
<% end %>
|
38
38
|
|
39
39
|
Which would generate (using the defaults) output like this:
|
data/lib/simple_show/base.rb
CHANGED
@@ -10,9 +10,9 @@ module SimpleShow
|
|
10
10
|
output = label(attr, options, &block)
|
11
11
|
output += value(attr, options, &block)
|
12
12
|
if SimpleShow.wrapper_tag.nil?
|
13
|
-
|
13
|
+
output
|
14
14
|
else
|
15
|
-
@binding.
|
15
|
+
@binding.content_tag(SimpleShow.wrapper_tag, output, :class => SimpleShow.wrapper_class)
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
data/lib/simple_show/version.rb
CHANGED
@@ -9,7 +9,7 @@ class SimpleShowForTest < SimpleShowTestCase
|
|
9
9
|
end
|
10
10
|
|
11
11
|
test 'html wrapper includes the correct id and class' do
|
12
|
-
doc = Nokogiri::HTML.fragment(simple_show_for @philip do |
|
12
|
+
doc = Nokogiri::HTML.fragment(simple_show_for @philip do |s|
|
13
13
|
''
|
14
14
|
end)
|
15
15
|
assert_equal %w[simple_show golfer], doc.at('div').attr('class').split(/\s+/)
|
@@ -19,7 +19,7 @@ class SimpleShowForTest < SimpleShowTestCase
|
|
19
19
|
test 'last tag is a BR that clears all when enabled' do
|
20
20
|
clear_on_close = SimpleShow::clear_on_close
|
21
21
|
SimpleShow::clear_on_close = true
|
22
|
-
doc = Nokogiri::HTML.fragment(simple_show_for @philip do |
|
22
|
+
doc = Nokogiri::HTML.fragment(simple_show_for @philip do |s|
|
23
23
|
''
|
24
24
|
end)
|
25
25
|
SimpleShow::clear_on_close = clear_on_close
|
@@ -30,7 +30,7 @@ class SimpleShowForTest < SimpleShowTestCase
|
|
30
30
|
test 'last tag is not a BR when disabled' do
|
31
31
|
clear_on_close = SimpleShow::clear_on_close
|
32
32
|
SimpleShow::clear_on_close = false
|
33
|
-
doc = Nokogiri::HTML.fragment(simple_show_for @philip do |
|
33
|
+
doc = Nokogiri::HTML.fragment(simple_show_for @philip do |s|
|
34
34
|
''
|
35
35
|
end)
|
36
36
|
assert_not_equal 'br', doc.at('div').elements.last.try(:name)
|
@@ -3,10 +3,14 @@ require 'test_helper'
|
|
3
3
|
class SimpleShowLabelTest < SimpleShowTestCase
|
4
4
|
|
5
5
|
test 'labels and label overrides' do
|
6
|
-
doc = Nokogiri::HTML.fragment(
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
doc = Nokogiri::HTML.fragment(
|
7
|
+
simple_show_for @philip do |s|
|
8
|
+
o = ActiveSupport::SafeBuffer.new
|
9
|
+
o += s.show :name
|
10
|
+
o += s.show :phone, :label => 'Cell Phone'
|
11
|
+
o
|
12
|
+
end
|
13
|
+
)
|
10
14
|
assert_equal 'Name:', doc.css('label').first.text
|
11
15
|
assert_equal 'Cell Phone:', doc.css('label').last.text
|
12
16
|
end
|
@@ -3,11 +3,15 @@ require 'test_helper'
|
|
3
3
|
class SimpleShowValueTest < SimpleShowTestCase
|
4
4
|
|
5
5
|
test 'values and value overrides' do
|
6
|
-
doc = Nokogiri::HTML.fragment(
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
doc = Nokogiri::HTML.fragment(
|
7
|
+
simple_show_for @philip do |s|
|
8
|
+
o = ActiveSupport::SafeBuffer.new
|
9
|
+
o += s.show :name
|
10
|
+
o += s.show(:email) {|o| o.email.upcase }
|
11
|
+
o += s.show :phone, :value => '867-5309'
|
12
|
+
o
|
13
|
+
end
|
14
|
+
)
|
11
15
|
assert_equal 'Philip Hallstrom', doc.css('span.value')[0].text
|
12
16
|
assert_equal 'PHILIP@PJKH.COM', doc.css('span.value')[1].text
|
13
17
|
assert_equal '867-5309', doc.css('span.value')[2].text
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_show
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Philip Hallstrom
|