table_for_collection 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -38,7 +38,7 @@ This ruby code will produce following HTML:
38
38
  :class => "simple-row"
39
39
  }
40
40
  } do -%>
41
- <% column :name, :html => { :width => "25%" } %>
41
+ <% column :name, :html => { :th => { :width => "25%" }, :td => { :class => "user-name" }} %>
42
42
  <% column :email %>
43
43
  <% column :address, :title => "Home" %>
44
44
  <% end %>
@@ -50,14 +50,14 @@ will be used as column's title. It will produce HTML similar to:
50
50
  <table class="simple-table" id="users" width="100%">
51
51
  <thead>
52
52
  <tr>
53
- <th>Name</th>
53
+ <th width="25%">Name</th>
54
54
  <th>Email</th>
55
55
  <th>Home</th>
56
56
  </tr>
57
57
  </thead>
58
58
  <tbody>
59
59
  <tr class="simple-row">
60
- <td width="25%">...</td>
60
+ <td class="user-name">...</td>
61
61
  <td>...</td>
62
62
  <td>...</td>
63
63
  </tr>
@@ -1,9 +1,9 @@
1
1
  module TableHelper
2
2
  class Column # :nodoc:
3
- attr_reader :title, :html
3
+ attr_reader :title, :html, :html
4
4
  def initialize(template, obj, ops)
5
5
  @template, @options, @attr, @title = template, ops, obj, ""
6
- @html = @options.delete(:html)
6
+ @html = @options.delete(:html) || {}
7
7
  end
8
8
 
9
9
  def content_for
@@ -57,7 +57,7 @@ module TableHelper
57
57
  content_tag :thead do
58
58
  content_tag :tr do
59
59
  @columns.map do |col|
60
- content_tag :th do
60
+ content_tag :th, col.html[:th] do
61
61
  col.title
62
62
  end
63
63
  end.join
@@ -70,7 +70,7 @@ module TableHelper
70
70
  @records.map do |rec|
71
71
  content_tag(:tr, tr_options) do
72
72
  @columns.map do |col|
73
- content_tag :td, col.html do
73
+ content_tag :td, col.html[:td] do
74
74
  col.content_for(rec).to_s
75
75
  end
76
76
  end.join
@@ -1,4 +1,4 @@
1
1
  module TableHelper
2
2
  GEM_NAME = "table_for_collection"
3
- VERSION = "1.0.1"
3
+ VERSION = "1.0.2"
4
4
  end
@@ -77,14 +77,17 @@ describe ActionView::Base do
77
77
  describe "with column :html options" do
78
78
  before(:each) do
79
79
  @html = template.table_for(users) do
80
- column :id, :html => { :class => "user-id", :width => "50%" }
80
+ column :id, :html => { :td => { :class => "user-id" }, :th => { :width => "50%" }}
81
81
  end
82
82
  end
83
83
  it "should render valid HTML" do
84
84
  @html.should have_selector("table") do |table|
85
+ table.should have_selector("thead/tr") do |tr|
86
+ tr.should have_selector("th[@width='50%']")
87
+ end
85
88
  table.should have_selector("tbody/tr") do |tr|
86
89
  users.each do |user|
87
- tr.should have_selector("td.user-id[@width='50%']")
90
+ tr.should have_selector("td.user-id")
88
91
  end
89
92
  end
90
93
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: table_for_collection
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 1
10
- version: 1.0.1
9
+ - 2
10
+ version: 1.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Dima Lunich
@@ -111,7 +111,7 @@ rubyforge_project: ""
111
111
  rubygems_version: 1.3.7
112
112
  signing_key:
113
113
  specification_version: 3
114
- summary: table_for_collection-1.0.1
114
+ summary: table_for_collection-1.0.2
115
115
  test_files:
116
116
  - spec/core_ex/array_spec.rb
117
117
  - spec/spec_helper.rb