show_for 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -10,9 +10,9 @@ ShowFor allows you to quickly show a model information with I18n features.
10
10
  <%= u.attribute :last_sign_in_at, :if_blank => "User did not access yet"
11
11
  :wrapper_html => { :id => "sign_in_timestamp" } %>
12
12
 
13
- <% u.attribute :photo do
14
- <%= image_url(@user.photo_url) %>
15
- end %>
13
+ <% u.attribute :photo do %>
14
+ <%= image_tag(@user.photo_url) %>
15
+ <% end %>
16
16
 
17
17
  <%= u.association :company %>
18
18
  <%= u.association :tags, :to_sentence => true %>
@@ -22,7 +22,7 @@ ShowFor allows you to quickly show a model information with I18n features.
22
22
 
23
23
  Install the gem:
24
24
 
25
- sudo gem install show_for
25
+ sudo gem install show_for --version=0.1.3
26
26
 
27
27
  Configure simple_form gem inside your app:
28
28
 
@@ -46,7 +46,7 @@ ShowFor allows you to quickly show a model information with I18n features.
46
46
  :wrapper_html => { :id => "sign_in_timestamp" } %>
47
47
 
48
48
  <% a.attribute :photo do %>
49
- <%= image_url(@admin.photo_url) %>
49
+ <%= image_tag(@admin.photo_url) %>
50
50
  <% end %>
51
51
  <% end %>
52
52
 
@@ -101,8 +101,8 @@ options. Containers can have their tags configured on demand as well through
101
101
  show_for also exposes the label method. In case you want to use the default
102
102
  human_attribute_name lookup and the default wrapping:
103
103
 
104
- a.label :name #=> <b class="label">Name</b>
105
- a.label "Name", :id => "my_name" #=> <b class="label" id="my_name">Name</b>
104
+ a.label :name #=> <strong class="label">Name</strong>
105
+ a.label "Name", :id => "my_name" #=> <strong class="label" id="my_name">Name</strong>
106
106
 
107
107
  == Associations
108
108
 
@@ -153,4 +153,4 @@ If you discover any bugs or want to drop a line, feel free to create an issue on
153
153
 
154
154
  http://github.com/plataformatec/show_for/issues
155
155
 
156
- MIT License. Copyright 2009 Plataforma Tecnologia. http://blog.plataformatec.com.br
156
+ MIT License. Copyright 2010 Plataforma Tecnologia. http://blog.plataformatec.com.br
data/lib/show_for.rb CHANGED
@@ -18,9 +18,6 @@ module ShowFor
18
18
  mattr_accessor :blank_content_class
19
19
  @@blank_content_class = "blank"
20
20
 
21
- mattr_accessor :blank_content
22
- @@blank_content = ""
23
-
24
21
  mattr_accessor :wrapper_tag
25
22
  @@wrapper_tag = :p
26
23
 
@@ -24,7 +24,7 @@ module ShowFor
24
24
 
25
25
  def wrap_label_and_content(name, value, options, &block) #:nodoc:
26
26
  wrap_with(:wrapper, label(name, options, false) + ShowFor.separator.to_s +
27
- content(value, options, false, &block), options, true, value.is_a?(Proc))
27
+ content(value, options, false, &block), options, true, (value.is_a?(Proc) or collection_block?(block)))
28
28
  end
29
29
 
30
30
  # Set "#{object_name}_#{attribute_name}" as in the wrapper tag.
@@ -58,4 +58,4 @@ module ShowFor
58
58
  block && block.arity == 1
59
59
  end
60
60
  end
61
- end
61
+ end
@@ -5,6 +5,8 @@ module ShowFor
5
5
  value = options.delete(:if_blank) || I18n.t(:'show_for.blank', :default => "Not specified")
6
6
  options[:class] = [options[:class], ShowFor.blank_content_class].join(' ')
7
7
  end
8
+
9
+ value = value.to_a if value.is_a?(Array)
8
10
 
9
11
  content = case value
10
12
  when Date, Time, DateTime
@@ -43,4 +45,4 @@ module ShowFor
43
45
  wrap_with(:collection, response, options)
44
46
  end
45
47
  end
46
- end
48
+ end
@@ -1,3 +1,3 @@
1
1
  module ShowFor
2
- VERSION = "0.1.3".freeze
2
+ VERSION = "0.1.4".freeze
3
3
  end
data/test/builder_test.rb CHANGED
@@ -226,13 +226,6 @@ class BuilderTest < ActionView::TestCase
226
226
  end
227
227
  end
228
228
 
229
- test "show_for#content with blank value fallbacks on a default value" do
230
- swap ShowFor, :blank_content => "Not specified" do
231
- with_content_for @user, nil, :content_tag => :b
232
- assert_select "div.show_for b", "Not specified"
233
- end
234
- end
235
-
236
229
  # COLLECTIONS
237
230
  test "show_for accepts an attribute as a collection" do
238
231
  with_attribute_for @user, :scopes
data/test/test_helper.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  require 'rubygems'
2
2
  require 'test/unit'
3
3
 
4
+ gem 'actionpack', '2.3.5'
5
+
4
6
  require 'action_controller'
5
7
  require 'action_view/test_case'
6
8
 
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: show_for
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 4
9
+ version: 0.1.4
5
10
  platform: ruby
6
11
  authors:
7
12
  - "Jos\xC3\xA9 Valim"
@@ -9,7 +14,7 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2010-01-18 00:00:00 +01:00
17
+ date: 2010-05-20 00:00:00 +02:00
13
18
  default_executable:
14
19
  dependencies: []
15
20
 
@@ -49,18 +54,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
49
54
  requirements:
50
55
  - - ">="
51
56
  - !ruby/object:Gem::Version
57
+ segments:
58
+ - 0
52
59
  version: "0"
53
- version:
54
60
  required_rubygems_version: !ruby/object:Gem::Requirement
55
61
  requirements:
56
62
  - - ">="
57
63
  - !ruby/object:Gem::Version
64
+ segments:
65
+ - 0
58
66
  version: "0"
59
- version:
60
67
  requirements: []
61
68
 
62
69
  rubyforge_project:
63
- rubygems_version: 1.3.5
70
+ rubygems_version: 1.3.6
64
71
  signing_key:
65
72
  specification_version: 3
66
73
  summary: Wrap your objects with a helper to easily show them