simple_show 0.0.9 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -1
- data/lib/simple_show/action_view_extensions/form_helper.rb +21 -0
- data/lib/simple_show/version.rb +1 -1
- data/lib/simple_show.rb +1 -4
- data/test/test_helper.rb +1 -2
- data/test/test_simple_show_for.rb +3 -3
- data/test/test_simple_show_label.rb +1 -1
- data/test/test_simple_show_show.rb +6 -6
- data/test/test_simple_show_value.rb +1 -1
- metadata +23 -43
- data/app/helpers/simple_show/application_helper.rb +0 -16
- data/lib/simple_show/railtie.rb +0 -9
data/Gemfile
CHANGED
@@ -0,0 +1,21 @@
|
|
1
|
+
module SimpleShow
|
2
|
+
module ActionViewExtensions
|
3
|
+
module FormHelper
|
4
|
+
def simple_show_for(record, options = {}, &block)
|
5
|
+
raise ArgumentError, "Missing block" unless block_given?
|
6
|
+
|
7
|
+
options[:html] ||= {}
|
8
|
+
options[:html][:id] ||= dom_id(record)
|
9
|
+
options[:html][:class] = "#{SimpleShow.show_class} #{dom_class(record)} #{options[:html][:class]}".strip
|
10
|
+
|
11
|
+
output = capture(SimpleShow::Base.new(self, record, options), &block)
|
12
|
+
output.concat content_tag(:div, '', :class => 'clear') if SimpleShow.clear_on_close
|
13
|
+
|
14
|
+
content_tag(:div, output, :id => options[:html][:id], :class => options[:html][:class])
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
ActionView::Base.send :include, SimpleShow::ActionViewExtensions::FormHelper
|
21
|
+
|
data/lib/simple_show/version.rb
CHANGED
data/lib/simple_show.rb
CHANGED
data/test/test_helper.rb
CHANGED
@@ -13,7 +13,6 @@ require 'action_view/base'
|
|
13
13
|
require 'action_view/template'
|
14
14
|
|
15
15
|
require 'simple_show'
|
16
|
-
require 'app/helpers/simple_show/application_helper'
|
17
16
|
|
18
17
|
################################################################################
|
19
18
|
|
@@ -57,7 +56,7 @@ end
|
|
57
56
|
|
58
57
|
|
59
58
|
class SimpleShowTestCase < ActiveSupport::TestCase
|
60
|
-
include SimpleShow::
|
59
|
+
include SimpleShow::ActionViewExtensions::FormHelper
|
61
60
|
include ActionController::RecordIdentifier
|
62
61
|
include ActionView::Helpers::CaptureHelper
|
63
62
|
include ActionView::Helpers::TagHelper
|
@@ -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
|
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
|
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 div/clear 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
|
33
|
+
doc = Nokogiri::HTML.fragment(simple_show_for(@philip) do |s|
|
34
34
|
''
|
35
35
|
end)
|
36
36
|
assert_not_equal 'clear', doc.at('div').elements.last.try(:attr, 'class')
|
@@ -4,7 +4,7 @@ class SimpleShowLabelTest < SimpleShowTestCase
|
|
4
4
|
|
5
5
|
test 'labels and label overrides' do
|
6
6
|
doc = Nokogiri::HTML.fragment(
|
7
|
-
simple_show_for
|
7
|
+
simple_show_for(@philip) do |s|
|
8
8
|
o = ActiveSupport::SafeBuffer.new
|
9
9
|
o += s.show :name
|
10
10
|
o += s.show :phone, :label => 'Cell Phone'
|
@@ -4,7 +4,7 @@ class SimpleShowShowTest < SimpleShowTestCase
|
|
4
4
|
|
5
5
|
test ':if => true/false' do
|
6
6
|
doc = Nokogiri::HTML.fragment(
|
7
|
-
simple_show_for
|
7
|
+
simple_show_for(@philip) do |s|
|
8
8
|
o = ActiveSupport::SafeBuffer.new
|
9
9
|
o += s.show :name, :if => true
|
10
10
|
o += s.show :phone, :if => false
|
@@ -18,7 +18,7 @@ class SimpleShowShowTest < SimpleShowTestCase
|
|
18
18
|
def @philip.method_returning_true; true; end
|
19
19
|
def @philip.method_returning_false; false; end
|
20
20
|
doc = Nokogiri::HTML.fragment(
|
21
|
-
simple_show_for
|
21
|
+
simple_show_for(@philip) do |s|
|
22
22
|
o = ActiveSupport::SafeBuffer.new
|
23
23
|
o += s.show :name, :if => :method_returning_true
|
24
24
|
o += s.show :phone, :if => :method_returning_false
|
@@ -30,7 +30,7 @@ class SimpleShowShowTest < SimpleShowTestCase
|
|
30
30
|
|
31
31
|
test ':if => {lambda}' do
|
32
32
|
doc = Nokogiri::HTML.fragment(
|
33
|
-
simple_show_for
|
33
|
+
simple_show_for(@philip) do |s|
|
34
34
|
o = ActiveSupport::SafeBuffer.new
|
35
35
|
o += s.show :name, :if => lambda { true }
|
36
36
|
o += s.show :phone, :if => lambda { false }
|
@@ -42,7 +42,7 @@ class SimpleShowShowTest < SimpleShowTestCase
|
|
42
42
|
|
43
43
|
test ':unless => true/false' do
|
44
44
|
doc = Nokogiri::HTML.fragment(
|
45
|
-
simple_show_for
|
45
|
+
simple_show_for(@philip) do |s|
|
46
46
|
o = ActiveSupport::SafeBuffer.new
|
47
47
|
o += s.show :name, :unless => true
|
48
48
|
o += s.show :phone, :unless => false
|
@@ -56,7 +56,7 @@ class SimpleShowShowTest < SimpleShowTestCase
|
|
56
56
|
def @philip.method_returning_true; true; end
|
57
57
|
def @philip.method_returning_false; false; end
|
58
58
|
doc = Nokogiri::HTML.fragment(
|
59
|
-
simple_show_for
|
59
|
+
simple_show_for(@philip) do |s|
|
60
60
|
o = ActiveSupport::SafeBuffer.new
|
61
61
|
o += s.show :name, :unless => :method_returning_true
|
62
62
|
o += s.show :phone, :unless => :method_returning_false
|
@@ -68,7 +68,7 @@ class SimpleShowShowTest < SimpleShowTestCase
|
|
68
68
|
|
69
69
|
test ':unless => {lambda}' do
|
70
70
|
doc = Nokogiri::HTML.fragment(
|
71
|
-
simple_show_for
|
71
|
+
simple_show_for(@philip) do |s|
|
72
72
|
o = ActiveSupport::SafeBuffer.new
|
73
73
|
o += s.show :name, :unless => lambda { true }
|
74
74
|
o += s.show :phone, :unless => lambda { false }
|
@@ -8,7 +8,7 @@ class SimpleShowValueTest < SimpleShowTestCase
|
|
8
8
|
config.helpers[:to_piglatin] = :piglatin
|
9
9
|
end
|
10
10
|
@doc = Nokogiri::HTML.fragment(
|
11
|
-
simple_show_for
|
11
|
+
simple_show_for(@philip) do |s|
|
12
12
|
o = ActiveSupport::SafeBuffer.new
|
13
13
|
o += s.show :name
|
14
14
|
o += s.show(:email) {|o| o.email.upcase }
|
metadata
CHANGED
@@ -1,44 +1,33 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_show
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 9
|
10
|
-
version: 0.0.9
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Philip Hallstrom
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
date: 2011-10-30 00:00:00 Z
|
12
|
+
date: 2012-02-21 00:00:00.000000000 Z
|
19
13
|
dependencies: []
|
20
|
-
|
21
|
-
|
22
|
-
email:
|
14
|
+
description: ! 'SimpleShow is to #show what SimpleForm is to #edit'
|
15
|
+
email:
|
23
16
|
- philip@pjkh.com
|
24
17
|
executables: []
|
25
|
-
|
26
18
|
extensions: []
|
27
|
-
|
28
19
|
extra_rdoc_files: []
|
29
|
-
|
30
|
-
files:
|
20
|
+
files:
|
31
21
|
- .gitignore
|
32
22
|
- Gemfile
|
33
23
|
- README.rdoc
|
34
24
|
- Rakefile
|
35
|
-
- app/helpers/simple_show/application_helper.rb
|
36
25
|
- lib/generators/simple_show/USAGE
|
37
26
|
- lib/generators/simple_show/install_generator.rb
|
38
27
|
- lib/generators/simple_show/templates/config/initializers/simple_show.rb
|
39
28
|
- lib/simple_show.rb
|
29
|
+
- lib/simple_show/action_view_extensions/form_helper.rb
|
40
30
|
- lib/simple_show/base.rb
|
41
|
-
- lib/simple_show/railtie.rb
|
42
31
|
- lib/simple_show/version.rb
|
43
32
|
- simple_show.gemspec
|
44
33
|
- test/test_helper.rb
|
@@ -47,40 +36,31 @@ files:
|
|
47
36
|
- test/test_simple_show_label.rb
|
48
37
|
- test/test_simple_show_show.rb
|
49
38
|
- test/test_simple_show_value.rb
|
50
|
-
homepage:
|
39
|
+
homepage: ''
|
51
40
|
licenses: []
|
52
|
-
|
53
41
|
post_install_message:
|
54
42
|
rdoc_options: []
|
55
|
-
|
56
|
-
require_paths:
|
43
|
+
require_paths:
|
57
44
|
- lib
|
58
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
45
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
59
46
|
none: false
|
60
|
-
requirements:
|
61
|
-
- -
|
62
|
-
- !ruby/object:Gem::Version
|
63
|
-
|
64
|
-
|
65
|
-
- 0
|
66
|
-
version: "0"
|
67
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - ! '>='
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '0'
|
51
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
52
|
none: false
|
69
|
-
requirements:
|
70
|
-
- -
|
71
|
-
- !ruby/object:Gem::Version
|
72
|
-
|
73
|
-
segments:
|
74
|
-
- 0
|
75
|
-
version: "0"
|
53
|
+
requirements:
|
54
|
+
- - ! '>='
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
76
57
|
requirements: []
|
77
|
-
|
78
58
|
rubyforge_project: simple_show
|
79
59
|
rubygems_version: 1.8.10
|
80
60
|
signing_key:
|
81
61
|
specification_version: 3
|
82
|
-
summary:
|
83
|
-
test_files:
|
62
|
+
summary: ! 'SimpleShow is to #show what SimpleForm is to #edit'
|
63
|
+
test_files:
|
84
64
|
- test/test_helper.rb
|
85
65
|
- test/test_simple_show.rb
|
86
66
|
- test/test_simple_show_for.rb
|
@@ -1,16 +0,0 @@
|
|
1
|
-
module SimpleShow
|
2
|
-
module ApplicationHelper
|
3
|
-
def simple_show_for(record, options = {}, &block)
|
4
|
-
raise ArgumentError, "Missing block" unless block_given?
|
5
|
-
|
6
|
-
options[:html] ||= {}
|
7
|
-
options[:html][:id] ||= dom_id(record)
|
8
|
-
options[:html][:class] = "#{SimpleShow.show_class} #{dom_class(record)} #{options[:html][:class]}".strip
|
9
|
-
|
10
|
-
output = capture(SimpleShow::Base.new(self, record, options), &block)
|
11
|
-
output.concat content_tag(:div, '', :class => 'clear') if SimpleShow.clear_on_close
|
12
|
-
|
13
|
-
content_tag(:div, output, :id => options[:html][:id], :class => options[:html][:class])
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|