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 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 |f| %>
33
- <%= f.show :name %>
34
- <%= f.show :phone, :label => 'Telephone' %>
35
- <%= f.show(:email) {|o| o.email.downcase} %>
36
- <%= f.show :born_on, :value => '**censored**' %>
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:
@@ -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
- @binding.output_buffer += output
13
+ output
14
14
  else
15
- @binding.output_buffer += @binding.content_tag(SimpleShow.wrapper_tag, output, :class => SimpleShow.wrapper_class)
15
+ @binding.content_tag(SimpleShow.wrapper_tag, output, :class => SimpleShow.wrapper_class)
16
16
  end
17
17
  end
18
18
 
@@ -1,3 +1,3 @@
1
1
  module SimpleShow
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -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 |f|
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 |f|
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 |f|
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(simple_show_for @philip do |f|
7
- f.show :name
8
- f.show :phone, :label => 'Cell Phone'
9
- end)
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(simple_show_for @philip do |f|
7
- f.show :name
8
- f.show(:email) {|o| o.email.upcase }
9
- f.show :phone, :value => '867-5309'
10
- end)
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: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Philip Hallstrom