table_cloth 0.4.0 → 0.4.1
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.
- checksums.yaml +7 -0
- data/README.md +3 -0
- data/Rakefile +1 -0
- data/lib/generators/templates/table.rb +0 -3
- data/lib/table_cloth/base.rb +3 -1
- data/lib/table_cloth/presenter.rb +3 -8
- data/lib/table_cloth/presenters/default.rb +4 -2
- data/lib/table_cloth/version.rb +1 -1
- data/spec/lib/base_spec.rb +7 -1
- data/spec/lib/extensions/actions_spec.rb +22 -30
- data/spec/lib/presenter_spec.rb +0 -13
- data/spec/lib/presenters/default_spec.rb +6 -7
- data/spec/support/dummy_table.rb +1 -1
- data/table_cloth.gemspec +3 -3
- metadata +40 -65
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 749bf677a3ffe591ab0f3a1a61ca5f016d7f91bd
|
4
|
+
data.tar.gz: d103710bf95ca76c6ea6eaadbf6b99a438aa5a0d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2c17f9cc988b73d71b911caa21c33f9a77397c5020c4150b3453ce00a887af9456bfa74d05c1617cebe3ced9311156e5eb189df17ed5116e759df48f982abce7
|
7
|
+
data.tar.gz: 91c0569d11104abef8adc608d7e6cbc0ce654ddddc6cd9938178c640cf1ba36ea8242028cfffe0c1b7ea21a570d55a458b164f4db417df06a546a37fe5ace362
|
data/README.md
CHANGED
@@ -25,6 +25,7 @@ And then execute:
|
|
25
25
|
|
26
26
|
Table Cloth can use defined tables in app/tables or you can build them on the fly.
|
27
27
|
|
28
|
+
|
28
29
|
Table models can be generated using rails generators.
|
29
30
|
|
30
31
|
```
|
@@ -177,6 +178,8 @@ class UserTable < TableCloth::Base
|
|
177
178
|
end
|
178
179
|
```
|
179
180
|
|
181
|
+
Table header (```th```) elements can be configured in a similar fashion with the ```th_options``` key.
|
182
|
+
|
180
183
|
Not good enough? Fine... you can do row / column specific config as well for a TD.
|
181
184
|
|
182
185
|
```ruby
|
data/Rakefile
CHANGED
data/lib/table_cloth/base.rb
CHANGED
@@ -27,12 +27,6 @@ module TableCloth
|
|
27
27
|
end.compact
|
28
28
|
end
|
29
29
|
|
30
|
-
def column_names
|
31
|
-
@column_names ||= columns.each_with_object([]) do |column, names|
|
32
|
-
names << column.human_name(view_context)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
30
|
def row_values(object)
|
37
31
|
columns.each_with_object([]) do |column, values|
|
38
32
|
values << column.value(object, view_context, table)
|
@@ -49,9 +43,10 @@ module TableCloth
|
|
49
43
|
|
50
44
|
def tag_options(type, options={})
|
51
45
|
options = options.dup
|
46
|
+
|
52
47
|
if TableCloth.config.respond_to?(type)
|
53
|
-
options
|
54
|
-
options
|
48
|
+
options = table.config.config_for(type).merge(options)
|
49
|
+
options = TableCloth.config.config_for(type).merge(options)
|
55
50
|
end
|
56
51
|
|
57
52
|
options
|
@@ -24,8 +24,10 @@ module TableCloth
|
|
24
24
|
|
25
25
|
def thead_row
|
26
26
|
@thead_row ||= ElementFactory::Element.new(:tr, tag_options(:tr)).tap do |row|
|
27
|
-
|
28
|
-
|
27
|
+
columns.each do |column|
|
28
|
+
th_options = column.options[:th_options] || {}
|
29
|
+
name = column.human_name(view_context)
|
30
|
+
row << ElementFactory::Element.new(:th, tag_options(:th, th_options).merge(text: name))
|
29
31
|
end
|
30
32
|
end
|
31
33
|
end
|
data/lib/table_cloth/version.rb
CHANGED
data/spec/lib/base_spec.rb
CHANGED
@@ -90,4 +90,10 @@ describe TableCloth::Base do
|
|
90
90
|
expect { sibling1_class.config.table.cellpadding = '0' }.not_to change { sibling2_class.config.table.cellpadding }
|
91
91
|
end
|
92
92
|
end
|
93
|
-
|
93
|
+
|
94
|
+
describe '.actions' do
|
95
|
+
it 'exists in class' do
|
96
|
+
expect(subject).to respond_to(:actions)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
@@ -3,40 +3,32 @@ require "spec_helper"
|
|
3
3
|
describe TableCloth::Extensions::Actions do
|
4
4
|
let(:dummy_table) { FactoryGirl.build(:dummy_table) }
|
5
5
|
|
6
|
-
|
7
|
-
it "
|
8
|
-
|
6
|
+
describe '.actions' do
|
7
|
+
it "yields an ActionCollection block" do
|
8
|
+
block_type = nil
|
9
|
+
dummy_table.actions { block_type = self }
|
10
|
+
expect(block_type).to be_kind_of TableCloth::Extensions::Actions::ActionCollection
|
9
11
|
end
|
10
12
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
block_type = nil
|
16
|
-
dummy_table.actions { block_type = self }
|
17
|
-
expect(block_type).to be_kind_of TableCloth::Extensions::Actions::ActionCollection
|
18
|
-
end
|
19
|
-
|
20
|
-
it "creates an actions column on the table" do
|
21
|
-
dummy_table.actions { }
|
22
|
-
expect(dummy_table.columns).to have_key :actions
|
23
|
-
end
|
13
|
+
it "creates an actions column on the table" do
|
14
|
+
dummy_table.actions { }
|
15
|
+
expect(dummy_table.columns).to have_key :actions
|
16
|
+
end
|
24
17
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
18
|
+
it "accepts options" do
|
19
|
+
dummy_table.actions(if: :admin?) { }
|
20
|
+
expect(dummy_table.columns[:actions][:options]).to have_key :if
|
21
|
+
end
|
29
22
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
23
|
+
it "sets a collection key for the column pointing to the collection object" do
|
24
|
+
dummy_table.actions { }
|
25
|
+
expect(dummy_table.columns[:actions][:options][:collection]).to be_kind_of TableCloth::Extensions::Actions::ActionCollection
|
26
|
+
end
|
34
27
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
end
|
28
|
+
it "sets the column class to an action column" do
|
29
|
+
dummy_table.actions { }
|
30
|
+
column = dummy_table.columns[:actions]
|
31
|
+
expect(column[:class]).to eq(TableCloth::Extensions::Actions::Column)
|
40
32
|
end
|
41
33
|
end
|
42
|
-
end
|
34
|
+
end
|
data/spec/lib/presenter_spec.rb
CHANGED
@@ -29,19 +29,6 @@ describe TableCloth::Presenter do
|
|
29
29
|
specify "are not returned" do
|
30
30
|
expect(subject).to have(0).columns
|
31
31
|
end
|
32
|
-
|
33
|
-
specify "name is not returned" do
|
34
|
-
expect(subject.column_names).not_to include "email"
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
context ".column_names" do
|
40
|
-
let(:table_instance) { dummy_table.new(objects, view_context) }
|
41
|
-
before(:each) { table_instance.stub admin?: false, awesome?: true }
|
42
|
-
|
43
|
-
it 'returns all names' do
|
44
|
-
expect(subject.column_names).to eq ["Id", "Name", "Email"]
|
45
32
|
end
|
46
33
|
end
|
47
34
|
|
@@ -12,26 +12,25 @@ describe TableCloth::Presenters::Default do
|
|
12
12
|
subject { TableCloth::Presenters::Default.new(objects, dummy_table, view_context) }
|
13
13
|
|
14
14
|
describe "#thead" do
|
15
|
-
let(:column_names) { ["Col1", "Col2"] }
|
16
15
|
let(:thead) { Nokogiri::HTML(subject.thead.to_s) }
|
17
16
|
|
18
|
-
before(:each) do
|
19
|
-
subject.stub column_names: column_names
|
20
|
-
end
|
21
|
-
|
22
17
|
it "creates a thead" do
|
23
18
|
expect(thead).to have_tag "thead"
|
24
19
|
end
|
25
20
|
|
26
21
|
it "creates th's" do
|
27
|
-
expect(thead.css("th").size).to be
|
22
|
+
expect(thead.css("th").size).to be subject.columns.size
|
28
23
|
end
|
29
24
|
|
30
25
|
it "creates th's with the correct text" do
|
31
26
|
thead.css("th").each_with_index do |th, i|
|
32
|
-
expect(th.text).to eq(
|
27
|
+
expect(th.text).to eq(subject.columns[i].human_name(view_context))
|
33
28
|
end
|
34
29
|
end
|
30
|
+
|
31
|
+
it "creates th's with the correct options" do
|
32
|
+
thead.at_css("th").attr(:class).should == "th_options_class"
|
33
|
+
end
|
35
34
|
end
|
36
35
|
|
37
36
|
describe "#render_table" do
|
data/spec/support/dummy_table.rb
CHANGED
data/table_cloth.gemspec
CHANGED
@@ -25,8 +25,8 @@ Gem::Specification.new do |gem|
|
|
25
25
|
gem.add_development_dependency('factory_girl')
|
26
26
|
gem.add_development_dependency('guard-rspec')
|
27
27
|
gem.add_development_dependency('rake')
|
28
|
-
gem.add_development_dependency('rb-fsevent', '~> 0.9.
|
28
|
+
gem.add_development_dependency('rb-fsevent', '~> 0.9.4')
|
29
29
|
|
30
|
-
gem.add_dependency('actionpack', '>= 3.1', '< 4.
|
31
|
-
gem.add_dependency('element_factory', '~> 0.1.
|
30
|
+
gem.add_dependency('actionpack', '>= 3.1', '< 4.2')
|
31
|
+
gem.add_dependency('element_factory', '~> 0.1.2')
|
32
32
|
end
|
metadata
CHANGED
@@ -1,198 +1,175 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: table_cloth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
5
|
-
prerelease:
|
4
|
+
version: 0.4.1
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Robert Ross
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-04-16 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rspec
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- - ~>
|
17
|
+
- - "~>"
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '2.11'
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- - ~>
|
24
|
+
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '2.11'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: simplecov
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - ">="
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - ">="
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: awesome_print
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - ">="
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: '0'
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - ">="
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: '0'
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: nokogiri
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
|
-
- -
|
59
|
+
- - ">="
|
68
60
|
- !ruby/object:Gem::Version
|
69
61
|
version: '0'
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
|
-
- -
|
66
|
+
- - ">="
|
76
67
|
- !ruby/object:Gem::Version
|
77
68
|
version: '0'
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
70
|
name: pry
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
72
|
requirements:
|
83
|
-
- -
|
73
|
+
- - ">="
|
84
74
|
- !ruby/object:Gem::Version
|
85
75
|
version: '0'
|
86
76
|
type: :development
|
87
77
|
prerelease: false
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
79
|
requirements:
|
91
|
-
- -
|
80
|
+
- - ">="
|
92
81
|
- !ruby/object:Gem::Version
|
93
82
|
version: '0'
|
94
83
|
- !ruby/object:Gem::Dependency
|
95
84
|
name: factory_girl
|
96
85
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
86
|
requirements:
|
99
|
-
- -
|
87
|
+
- - ">="
|
100
88
|
- !ruby/object:Gem::Version
|
101
89
|
version: '0'
|
102
90
|
type: :development
|
103
91
|
prerelease: false
|
104
92
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
93
|
requirements:
|
107
|
-
- -
|
94
|
+
- - ">="
|
108
95
|
- !ruby/object:Gem::Version
|
109
96
|
version: '0'
|
110
97
|
- !ruby/object:Gem::Dependency
|
111
98
|
name: guard-rspec
|
112
99
|
requirement: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
100
|
requirements:
|
115
|
-
- -
|
101
|
+
- - ">="
|
116
102
|
- !ruby/object:Gem::Version
|
117
103
|
version: '0'
|
118
104
|
type: :development
|
119
105
|
prerelease: false
|
120
106
|
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
107
|
requirements:
|
123
|
-
- -
|
108
|
+
- - ">="
|
124
109
|
- !ruby/object:Gem::Version
|
125
110
|
version: '0'
|
126
111
|
- !ruby/object:Gem::Dependency
|
127
112
|
name: rake
|
128
113
|
requirement: !ruby/object:Gem::Requirement
|
129
|
-
none: false
|
130
114
|
requirements:
|
131
|
-
- -
|
115
|
+
- - ">="
|
132
116
|
- !ruby/object:Gem::Version
|
133
117
|
version: '0'
|
134
118
|
type: :development
|
135
119
|
prerelease: false
|
136
120
|
version_requirements: !ruby/object:Gem::Requirement
|
137
|
-
none: false
|
138
121
|
requirements:
|
139
|
-
- -
|
122
|
+
- - ">="
|
140
123
|
- !ruby/object:Gem::Version
|
141
124
|
version: '0'
|
142
125
|
- !ruby/object:Gem::Dependency
|
143
126
|
name: rb-fsevent
|
144
127
|
requirement: !ruby/object:Gem::Requirement
|
145
|
-
none: false
|
146
128
|
requirements:
|
147
|
-
- - ~>
|
129
|
+
- - "~>"
|
148
130
|
- !ruby/object:Gem::Version
|
149
|
-
version: 0.9.
|
131
|
+
version: 0.9.4
|
150
132
|
type: :development
|
151
133
|
prerelease: false
|
152
134
|
version_requirements: !ruby/object:Gem::Requirement
|
153
|
-
none: false
|
154
135
|
requirements:
|
155
|
-
- - ~>
|
136
|
+
- - "~>"
|
156
137
|
- !ruby/object:Gem::Version
|
157
|
-
version: 0.9.
|
138
|
+
version: 0.9.4
|
158
139
|
- !ruby/object:Gem::Dependency
|
159
140
|
name: actionpack
|
160
141
|
requirement: !ruby/object:Gem::Requirement
|
161
|
-
none: false
|
162
142
|
requirements:
|
163
|
-
- -
|
143
|
+
- - ">="
|
164
144
|
- !ruby/object:Gem::Version
|
165
145
|
version: '3.1'
|
166
|
-
- - <
|
146
|
+
- - "<"
|
167
147
|
- !ruby/object:Gem::Version
|
168
|
-
version: '4.
|
148
|
+
version: '4.2'
|
169
149
|
type: :runtime
|
170
150
|
prerelease: false
|
171
151
|
version_requirements: !ruby/object:Gem::Requirement
|
172
|
-
none: false
|
173
152
|
requirements:
|
174
|
-
- -
|
153
|
+
- - ">="
|
175
154
|
- !ruby/object:Gem::Version
|
176
155
|
version: '3.1'
|
177
|
-
- - <
|
156
|
+
- - "<"
|
178
157
|
- !ruby/object:Gem::Version
|
179
|
-
version: '4.
|
158
|
+
version: '4.2'
|
180
159
|
- !ruby/object:Gem::Dependency
|
181
160
|
name: element_factory
|
182
161
|
requirement: !ruby/object:Gem::Requirement
|
183
|
-
none: false
|
184
162
|
requirements:
|
185
|
-
- - ~>
|
163
|
+
- - "~>"
|
186
164
|
- !ruby/object:Gem::Version
|
187
|
-
version: 0.1.
|
165
|
+
version: 0.1.2
|
188
166
|
type: :runtime
|
189
167
|
prerelease: false
|
190
168
|
version_requirements: !ruby/object:Gem::Requirement
|
191
|
-
none: false
|
192
169
|
requirements:
|
193
|
-
- - ~>
|
170
|
+
- - "~>"
|
194
171
|
- !ruby/object:Gem::Version
|
195
|
-
version: 0.1.
|
172
|
+
version: 0.1.2
|
196
173
|
description: Table Cloth helps you create tables easily.
|
197
174
|
email:
|
198
175
|
- robert@creativequeries.com
|
@@ -200,9 +177,9 @@ executables: []
|
|
200
177
|
extensions: []
|
201
178
|
extra_rdoc_files: []
|
202
179
|
files:
|
203
|
-
- .gitignore
|
204
|
-
- .rspec
|
205
|
-
- .travis.yml
|
180
|
+
- ".gitignore"
|
181
|
+
- ".rspec"
|
182
|
+
- ".travis.yml"
|
206
183
|
- CHANGELOG
|
207
184
|
- Gemfile
|
208
185
|
- Guardfile
|
@@ -254,27 +231,26 @@ files:
|
|
254
231
|
- table_cloth.gemspec
|
255
232
|
homepage: http://www.github.com/bobbytables/table_cloth
|
256
233
|
licenses: []
|
234
|
+
metadata: {}
|
257
235
|
post_install_message:
|
258
236
|
rdoc_options: []
|
259
237
|
require_paths:
|
260
238
|
- lib
|
261
239
|
required_ruby_version: !ruby/object:Gem::Requirement
|
262
|
-
none: false
|
263
240
|
requirements:
|
264
|
-
- -
|
241
|
+
- - ">="
|
265
242
|
- !ruby/object:Gem::Version
|
266
243
|
version: '0'
|
267
244
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
268
|
-
none: false
|
269
245
|
requirements:
|
270
|
-
- -
|
246
|
+
- - ">="
|
271
247
|
- !ruby/object:Gem::Version
|
272
248
|
version: '0'
|
273
249
|
requirements: []
|
274
250
|
rubyforge_project:
|
275
|
-
rubygems_version:
|
251
|
+
rubygems_version: 2.2.2
|
276
252
|
signing_key:
|
277
|
-
specification_version:
|
253
|
+
specification_version: 4
|
278
254
|
summary: Table Cloth provides an easy and intuitive DSL for creating tables for Rails
|
279
255
|
views.
|
280
256
|
test_files:
|
@@ -303,4 +279,3 @@ test_files:
|
|
303
279
|
- spec/support/matchers/element_matchers.rb
|
304
280
|
- spec/support/shared_config_examples.rb
|
305
281
|
- spec/support/view_mocks.rb
|
306
|
-
has_rdoc:
|