table_helper 0.2.1 → 0.2.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/CHANGELOG.rdoc +6 -0
- data/LICENSE +1 -1
- data/README.rdoc +1 -1
- data/Rakefile +18 -16
- data/lib/table_helper.rb +1 -1
- data/lib/table_helper/footer.rb +1 -1
- data/lib/table_helper/row.rb +1 -1
- data/test/unit/body_test.rb +10 -10
- data/test/unit/collection_table_test.rb +3 -3
- data/test/unit/footer_test.rb +17 -0
- metadata +25 -31
data/CHANGELOG.rdoc
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
== master
|
2
2
|
|
3
|
+
== 0.2.2 / 2010-03-07
|
4
|
+
|
5
|
+
* Fix footer failing to render when there are multiple cells [Richard Luther]
|
6
|
+
* Fix TableHelper::RowBuilder failing on Ruby 1.9.1
|
7
|
+
* Release gems via rake-gemcutter instead of rubyforge
|
8
|
+
|
3
9
|
== 0.2.1 / 2009-04-25
|
4
10
|
|
5
11
|
* Automatically determine the colspan for the last footer to match the number of headers
|
data/LICENSE
CHANGED
data/README.rdoc
CHANGED
@@ -144,7 +144,7 @@ these types of tables by DRYing much of the html being generated.
|
|
144
144
|
<tfoot>
|
145
145
|
<tr>
|
146
146
|
<td class="post-num_comments">0</td>
|
147
|
-
<td class="post-num_trackbacks">0</td>
|
147
|
+
<td class="post-num_trackbacks" colspan="5">0</td>
|
148
148
|
</tr>
|
149
149
|
</tfoot>
|
150
150
|
</table>
|
data/Rakefile
CHANGED
@@ -1,13 +1,15 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
1
3
|
require 'rake/testtask'
|
2
4
|
require 'rake/rdoctask'
|
3
5
|
require 'rake/gempackagetask'
|
4
|
-
require 'rake/contrib/sshpublisher'
|
5
6
|
|
6
7
|
spec = Gem::Specification.new do |s|
|
7
8
|
s.name = 'table_helper'
|
8
|
-
s.version = '0.2.
|
9
|
+
s.version = '0.2.2'
|
9
10
|
s.platform = Gem::Platform::RUBY
|
10
|
-
s.summary = 'Adds a helper method for generating HTML tables from collections'
|
11
|
+
s.summary = 'Adds a helper method for generating HTML tables from collections in Rails'
|
12
|
+
s.description = s.summary
|
11
13
|
|
12
14
|
s.files = FileList['{lib,test}/**/*'] + %w(CHANGELOG.rdoc init.rb LICENSE Rakefile README.rdoc) - FileList['test/app_root/{log,log/*,script,script/*}']
|
13
15
|
s.require_path = 'lib'
|
@@ -52,20 +54,27 @@ Rake::RDocTask.new(:rdoc) do |rdoc|
|
|
52
54
|
rdoc.options << '--line-numbers' << '--inline-source'
|
53
55
|
rdoc.rdoc_files.include('README.rdoc', 'CHANGELOG.rdoc', 'LICENSE', 'lib/**/*.rb')
|
54
56
|
end
|
55
|
-
|
57
|
+
|
58
|
+
desc 'Generate a gemspec file.'
|
59
|
+
task :gemspec do
|
60
|
+
File.open("#{spec.name}.gemspec", 'w') do |f|
|
61
|
+
f.write spec.to_ruby
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
56
65
|
Rake::GemPackageTask.new(spec) do |p|
|
57
66
|
p.gem_spec = spec
|
58
|
-
p.need_tar = true
|
59
|
-
p.need_zip = true
|
60
67
|
end
|
61
68
|
|
62
69
|
desc 'Publish the beta gem.'
|
63
70
|
task :pgem => [:package] do
|
71
|
+
require 'rake/contrib/sshpublisher'
|
64
72
|
Rake::SshFilePublisher.new('aaron@pluginaweek.org', '/home/aaron/gems.pluginaweek.org/public/gems', 'pkg', "#{spec.name}-#{spec.version}.gem").upload
|
65
73
|
end
|
66
74
|
|
67
75
|
desc 'Publish the API documentation.'
|
68
76
|
task :pdoc => [:rdoc] do
|
77
|
+
require 'rake/contrib/sshpublisher'
|
69
78
|
Rake::SshDirPublisher.new('aaron@pluginaweek.org', "/home/aaron/api.pluginaweek.org/public/#{spec.name}", 'rdoc').upload
|
70
79
|
end
|
71
80
|
|
@@ -74,15 +83,8 @@ task :publish => [:pgem, :pdoc, :release]
|
|
74
83
|
|
75
84
|
desc 'Publish the release files to RubyForge.'
|
76
85
|
task :release => [:gem, :package] do
|
77
|
-
require '
|
78
|
-
|
79
|
-
ruby_forge = RubyForge.new.configure
|
80
|
-
ruby_forge.login
|
86
|
+
require 'rake/gemcutter'
|
81
87
|
|
82
|
-
|
83
|
-
|
84
|
-
puts "Releasing #{File.basename(file)}..."
|
85
|
-
|
86
|
-
ruby_forge.add_release(spec.rubyforge_project, spec.name, spec.version, file)
|
87
|
-
end
|
88
|
+
Rake::Gemcutter::Tasks.new(spec)
|
89
|
+
Rake::Task['gem:push'].invoke
|
88
90
|
end
|
data/lib/table_helper.rb
CHANGED
data/lib/table_helper/footer.rb
CHANGED
@@ -27,7 +27,7 @@ module TableHelper
|
|
27
27
|
def html #:nodoc:
|
28
28
|
# Force the last cell to span the remaining columns
|
29
29
|
cells = row.cells.values
|
30
|
-
colspan = table.header.columns.length - cells[0..-2].inject(0) {|count,
|
30
|
+
colspan = table.header.columns.length - cells[0..-2].inject(0) {|count, cell| count += (cell[:colspan] || 1).to_i}
|
31
31
|
cells.last[:colspan] ||= colspan if colspan > 1
|
32
32
|
|
33
33
|
html_options = @html_options.dup
|
data/lib/table_helper/row.rb
CHANGED
@@ -3,7 +3,7 @@ require 'table_helper/cell'
|
|
3
3
|
module TableHelper
|
4
4
|
# Provides a blank class that can be used to build the cells for a row
|
5
5
|
class RowBuilder < BlankSlate #:nodoc:
|
6
|
-
reveal :respond_to?
|
6
|
+
reveal :respond_to? if find_hidden_method(:respond_to?)
|
7
7
|
|
8
8
|
# Creates a builder for the given row
|
9
9
|
def initialize(row)
|
data/test/unit/body_test.rb
CHANGED
@@ -110,14 +110,14 @@ class BodyWithCollectionTest < Test::Unit::TestCase
|
|
110
110
|
end
|
111
111
|
|
112
112
|
def test_should_build_row_using_object_location_for_default_index
|
113
|
-
build_post = nil
|
114
|
-
index = nil
|
115
|
-
@body.each {|row, build_post, index|}
|
113
|
+
@build_post = nil
|
114
|
+
@index = nil
|
115
|
+
@body.each {|row, build_post, index| @build_post, @index = build_post, index}
|
116
116
|
|
117
117
|
@collection.each do |post|
|
118
118
|
html = @body.build_row(post)
|
119
|
-
assert_equal post, build_post
|
120
|
-
assert_equal @collection.index(post), index
|
119
|
+
assert_equal post, @build_post
|
120
|
+
assert_equal @collection.index(post), @index
|
121
121
|
|
122
122
|
expected = <<-end_str
|
123
123
|
<tr class="post ui-collection-result">
|
@@ -129,13 +129,13 @@ class BodyWithCollectionTest < Test::Unit::TestCase
|
|
129
129
|
end
|
130
130
|
|
131
131
|
def test_should_build_row_using_custom_value_for_index
|
132
|
-
post = nil
|
133
|
-
index = nil
|
134
|
-
@body.each {|row, post, index|}
|
132
|
+
@post = nil
|
133
|
+
@index = nil
|
134
|
+
@body.each {|row, post, index| @post, @index = post, index}
|
135
135
|
|
136
136
|
html = @body.build_row(@collection.first, 1)
|
137
|
-
assert_equal @collection.first, post
|
138
|
-
assert_equal 1, index
|
137
|
+
assert_equal @collection.first, @post
|
138
|
+
assert_equal 1, @index
|
139
139
|
|
140
140
|
expected = <<-end_str
|
141
141
|
<tr class="post ui-collection-result">
|
@@ -62,10 +62,10 @@ end
|
|
62
62
|
|
63
63
|
class CollectionTableTest < Test::Unit::TestCase
|
64
64
|
def test_should_accept_block_with_self_as_argument
|
65
|
-
args = nil
|
66
|
-
table = TableHelper::CollectionTable.new([]) {|*args|}
|
65
|
+
@args = nil
|
66
|
+
table = TableHelper::CollectionTable.new([]) {|*args| @args = args}
|
67
67
|
|
68
|
-
assert_equal [table], args
|
68
|
+
assert_equal [table], @args
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
data/test/unit/footer_test.rb
CHANGED
@@ -76,6 +76,23 @@ class FooterWithCellsTest < Test::Unit::TestCase
|
|
76
76
|
end_str
|
77
77
|
assert_html_equal expected, @footer.html
|
78
78
|
end
|
79
|
+
|
80
|
+
def test_should_include_colspan_on_last_cell_if_more_headers_than_footers
|
81
|
+
@table.header :title, :name, :description, :value, :created_at, :updated_at
|
82
|
+
@footer.cell :average, 5, :colspan => 2
|
83
|
+
@footer.cell :stdev, 1
|
84
|
+
|
85
|
+
expected = <<-end_str
|
86
|
+
<tfoot>
|
87
|
+
<tr>
|
88
|
+
<td class="object-total">20</td>
|
89
|
+
<td class="object-average" colspan="2">5</td>
|
90
|
+
<td class="object-stdev" colspan="3">1</td>
|
91
|
+
</tr>
|
92
|
+
</tfoot>
|
93
|
+
end_str
|
94
|
+
assert_html_equal expected, @footer.html
|
95
|
+
end
|
79
96
|
end
|
80
97
|
|
81
98
|
class FooterWithEmptyCollectionTest < Test::Unit::TestCase
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: table_helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Pfeifer
|
@@ -9,11 +9,11 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2010-03-07 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
16
|
-
description:
|
16
|
+
description: Adds a helper method for generating HTML tables from collections in Rails
|
17
17
|
email: aaron@pluginaweek.org
|
18
18
|
executables: []
|
19
19
|
|
@@ -22,36 +22,28 @@ extensions: []
|
|
22
22
|
extra_rdoc_files: []
|
23
23
|
|
24
24
|
files:
|
25
|
-
- lib/table_helper.rb
|
26
|
-
- lib/table_helper
|
27
|
-
- lib/table_helper/footer.rb
|
28
|
-
- lib/table_helper/cell.rb
|
29
25
|
- lib/table_helper/row.rb
|
30
|
-
- lib/table_helper/
|
31
|
-
- lib/table_helper/body.rb
|
26
|
+
- lib/table_helper/cell.rb
|
32
27
|
- lib/table_helper/collection_table.rb
|
28
|
+
- lib/table_helper/footer.rb
|
33
29
|
- lib/table_helper/body_row.rb
|
30
|
+
- lib/table_helper/html_element.rb
|
31
|
+
- lib/table_helper/body.rb
|
34
32
|
- lib/table_helper/header.rb
|
35
|
-
-
|
36
|
-
- test/unit
|
33
|
+
- lib/table_helper.rb
|
37
34
|
- test/unit/row_test.rb
|
38
|
-
- test/unit/
|
39
|
-
- test/unit/
|
35
|
+
- test/unit/html_element_test.rb
|
36
|
+
- test/unit/row_builder_test.rb
|
40
37
|
- test/unit/header_test.rb
|
41
38
|
- test/unit/collection_table_test.rb
|
42
|
-
- test/unit/
|
43
|
-
- test/unit/html_element_test.rb
|
39
|
+
- test/unit/cell_test.rb
|
44
40
|
- test/unit/footer_test.rb
|
45
|
-
- test/unit/
|
46
|
-
- test/
|
47
|
-
- test/helpers/table_helper_test.rb
|
48
|
-
- test/app_root
|
49
|
-
- test/app_root/db
|
50
|
-
- test/app_root/db/migrate
|
41
|
+
- test/unit/body_test.rb
|
42
|
+
- test/unit/body_row_test.rb
|
51
43
|
- test/app_root/db/migrate/001_create_people.rb
|
52
|
-
- test/app_root/app
|
53
|
-
- test/app_root/app/models
|
54
44
|
- test/app_root/app/models/person.rb
|
45
|
+
- test/test_helper.rb
|
46
|
+
- test/helpers/table_helper_test.rb
|
55
47
|
- CHANGELOG.rdoc
|
56
48
|
- init.rb
|
57
49
|
- LICENSE
|
@@ -59,6 +51,8 @@ files:
|
|
59
51
|
- README.rdoc
|
60
52
|
has_rdoc: true
|
61
53
|
homepage: http://www.pluginaweek.org
|
54
|
+
licenses: []
|
55
|
+
|
62
56
|
post_install_message:
|
63
57
|
rdoc_options: []
|
64
58
|
|
@@ -79,18 +73,18 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
79
73
|
requirements: []
|
80
74
|
|
81
75
|
rubyforge_project: pluginaweek
|
82
|
-
rubygems_version: 1.3.
|
76
|
+
rubygems_version: 1.3.5
|
83
77
|
signing_key:
|
84
|
-
specification_version:
|
85
|
-
summary: Adds a helper method for generating HTML tables from collections
|
78
|
+
specification_version: 3
|
79
|
+
summary: Adds a helper method for generating HTML tables from collections in Rails
|
86
80
|
test_files:
|
87
81
|
- test/unit/row_test.rb
|
88
|
-
- test/unit/
|
89
|
-
- test/unit/
|
82
|
+
- test/unit/html_element_test.rb
|
83
|
+
- test/unit/row_builder_test.rb
|
90
84
|
- test/unit/header_test.rb
|
91
85
|
- test/unit/collection_table_test.rb
|
92
|
-
- test/unit/
|
93
|
-
- test/unit/html_element_test.rb
|
86
|
+
- test/unit/cell_test.rb
|
94
87
|
- test/unit/footer_test.rb
|
95
|
-
- test/unit/
|
88
|
+
- test/unit/body_test.rb
|
89
|
+
- test/unit/body_row_test.rb
|
96
90
|
- test/helpers/table_helper_test.rb
|