table_for_collection 1.0.5 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/Changelog +10 -0
- data/Gemfile +4 -2
- data/README.rdoc +5 -0
- data/lib/table_for/column.rb +3 -3
- data/lib/table_for/table.rb +1 -1
- data/lib/table_for/version.rb +1 -1
- data/spec/spec_helper.rb +2 -1
- data/spec/table_for/column_spec.rb +14 -0
- metadata +41 -67
data/Changelog
CHANGED
data/Gemfile
CHANGED
data/README.rdoc
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
{<img src="https://secure.travis-ci.org/lunich/table_for.png" />}[http://travis-ci.org/lunich/table_for]
|
2
|
+
|
1
3
|
== Description
|
2
4
|
|
3
5
|
table_for_collection is a simple gem used to render tables based on the given collection.
|
@@ -125,3 +127,6 @@ Unfortunately it works incorrect if there is no "-" before %> in this code:
|
|
125
127
|
<%= table_for @users do -%>
|
126
128
|
|
127
129
|
We hope it will be fixed soon.
|
130
|
+
|
131
|
+
Also we need to check if all our samples are correct.
|
132
|
+
|
data/lib/table_for/column.rb
CHANGED
@@ -10,14 +10,14 @@ module TableHelper
|
|
10
10
|
@options.delete(:title)
|
11
11
|
elsif @attr.nil?
|
12
12
|
" "
|
13
|
-
elsif records.class.respond_to?(:human_attribute_name)
|
14
|
-
records.class.human_attribute_name(@attr.to_s)
|
13
|
+
elsif records[0].class.respond_to?(:human_attribute_name)
|
14
|
+
records[0].class.human_attribute_name(@attr.to_s)
|
15
15
|
elsif @attr.to_s.respond_to?(:humanize)
|
16
16
|
@attr.to_s.humanize
|
17
17
|
else
|
18
18
|
@attr.to_s.capitalize
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
@title_callback = @options.delete(:title_callback)
|
22
22
|
|
23
23
|
@html = @options.delete(:html) || {}
|
data/lib/table_for/table.rb
CHANGED
@@ -2,7 +2,7 @@ require "core_ex/array"
|
|
2
2
|
|
3
3
|
module TableHelper
|
4
4
|
class Table # :nodoc:
|
5
|
-
delegate :content_tag, :
|
5
|
+
delegate :content_tag, :dom_id, :dom_class, :to => :@template
|
6
6
|
|
7
7
|
def initialize(template, records, options = {})
|
8
8
|
@template, @records, @columns = template, records, []
|
data/lib/table_for/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -2,7 +2,7 @@ require "table_for_collection"
|
|
2
2
|
require "webrat"
|
3
3
|
|
4
4
|
def build_column(klass, arg, options = {})
|
5
|
-
klass.new(template, mock(:test), arg, options)
|
5
|
+
klass.new(template, [mock(:test)], arg, options)
|
6
6
|
end
|
7
7
|
|
8
8
|
# Column instance methods
|
@@ -42,6 +42,7 @@ shared_examples_for "Column class instance" do
|
|
42
42
|
end
|
43
43
|
|
44
44
|
class User < OpenStruct
|
45
|
+
require "active_model"
|
45
46
|
extend ActiveModel::Naming
|
46
47
|
def id
|
47
48
|
@table[:id]
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# encoding: utf-8
|
1
2
|
require 'spec_helper'
|
2
3
|
|
3
4
|
describe TableHelper::Column do
|
@@ -28,4 +29,17 @@ describe TableHelper::Column do
|
|
28
29
|
}.to raise_error(NoMethodError, "Use SimpleColumn or CallbackColumn")
|
29
30
|
end
|
30
31
|
end
|
32
|
+
|
33
|
+
describe "localization and humanization" do
|
34
|
+
it "should translate by human attribute name" do
|
35
|
+
@test_record = User.new(:id => 1, :name => 'Chuck')
|
36
|
+
@test_record.class.stub!(:human_attribute_name).with("name").and_return("nombre")
|
37
|
+
|
38
|
+
TableHelper::Column.new(template, [@test_record], :name).title.should eq("nombre")
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should translate by humanize" do
|
42
|
+
build_column(klass, :full_name).title.should eq("Full name") # Active support activated here
|
43
|
+
end
|
44
|
+
end
|
31
45
|
end
|
metadata
CHANGED
@@ -1,67 +1,50 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: table_for_collection
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 0
|
9
|
-
- 5
|
10
|
-
version: 1.0.5
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.6
|
5
|
+
prerelease:
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Dima Lunich
|
14
9
|
- Andrey Savchenko
|
15
10
|
- Dmitry Shaposhnik
|
16
11
|
autorequire:
|
17
12
|
bindir: bin
|
18
13
|
cert_chain: []
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
dependencies:
|
23
|
-
- !ruby/object:Gem::Dependency
|
14
|
+
date: 2011-11-17 00:00:00.000000000Z
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
24
17
|
name: rspec
|
25
|
-
|
26
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
18
|
+
requirement: &70131758124600 !ruby/object:Gem::Requirement
|
27
19
|
none: false
|
28
|
-
requirements:
|
29
|
-
- -
|
30
|
-
- !ruby/object:Gem::Version
|
31
|
-
hash: 15
|
32
|
-
segments:
|
33
|
-
- 2
|
34
|
-
- 0
|
35
|
-
- 0
|
20
|
+
requirements:
|
21
|
+
- - ! '>='
|
22
|
+
- !ruby/object:Gem::Version
|
36
23
|
version: 2.0.0
|
37
24
|
type: :development
|
38
|
-
version_requirements: *id001
|
39
|
-
- !ruby/object:Gem::Dependency
|
40
|
-
name: actionpack
|
41
25
|
prerelease: false
|
42
|
-
|
26
|
+
version_requirements: *70131758124600
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: actionpack
|
29
|
+
requirement: &70131758124180 !ruby/object:Gem::Requirement
|
43
30
|
none: false
|
44
|
-
requirements:
|
45
|
-
- -
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
|
48
|
-
segments:
|
49
|
-
- 0
|
50
|
-
version: "0"
|
31
|
+
requirements:
|
32
|
+
- - ! '>='
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
51
35
|
type: :runtime
|
52
|
-
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: *70131758124180
|
53
38
|
description: This gem builds HTML-table using given array
|
54
|
-
email:
|
39
|
+
email:
|
55
40
|
- dima.lunich@gmail.com
|
56
41
|
- andrey@aejis.eu
|
57
42
|
- dmitry@shaposhnik.name
|
58
43
|
executables: []
|
59
|
-
|
60
44
|
extensions: []
|
61
|
-
|
62
|
-
extra_rdoc_files:
|
45
|
+
extra_rdoc_files:
|
63
46
|
- README.rdoc
|
64
|
-
files:
|
47
|
+
files:
|
65
48
|
- lib/core_ex/array.rb
|
66
49
|
- lib/table_for/callback_column.rb
|
67
50
|
- lib/table_for/column.rb
|
@@ -82,42 +65,33 @@ files:
|
|
82
65
|
- Changelog
|
83
66
|
- Gemfile
|
84
67
|
- init.rb
|
85
|
-
has_rdoc: true
|
86
68
|
homepage: http://github.com/lunich/table_for
|
87
69
|
licenses: []
|
88
|
-
|
89
70
|
post_install_message:
|
90
|
-
rdoc_options:
|
71
|
+
rdoc_options:
|
91
72
|
- --main
|
92
73
|
- README.rdoc
|
93
|
-
require_paths:
|
74
|
+
require_paths:
|
94
75
|
- lib
|
95
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
76
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
96
77
|
none: false
|
97
|
-
requirements:
|
98
|
-
- -
|
99
|
-
- !ruby/object:Gem::Version
|
100
|
-
|
101
|
-
|
102
|
-
- 0
|
103
|
-
version: "0"
|
104
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ! '>='
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
83
|
none: false
|
106
|
-
requirements:
|
107
|
-
- -
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
|
110
|
-
segments:
|
111
|
-
- 0
|
112
|
-
version: "0"
|
84
|
+
requirements:
|
85
|
+
- - ! '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
113
88
|
requirements: []
|
114
|
-
|
115
|
-
|
116
|
-
rubygems_version: 1.3.7
|
89
|
+
rubyforge_project: ''
|
90
|
+
rubygems_version: 1.8.6
|
117
91
|
signing_key:
|
118
92
|
specification_version: 3
|
119
|
-
summary: table_for_collection-1.0.
|
120
|
-
test_files:
|
93
|
+
summary: table_for_collection-1.0.6
|
94
|
+
test_files:
|
121
95
|
- spec/core_ex/array_spec.rb
|
122
96
|
- spec/spec_helper.rb
|
123
97
|
- spec/table_for/callback_column_spec.rb
|