easy_table 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +5 -1
- data/Appraisals +7 -0
- data/circle.yml +8 -1
- data/easy_table.gemspec +3 -1
- data/gemfiles/rails_4.gemfile +10 -0
- data/gemfiles/rails_4.gemfile.lock +89 -0
- data/gemfiles/rails_5.gemfile +10 -0
- data/gemfiles/rails_5.gemfile.lock +86 -0
- data/lib/easy_table.rb +1 -2
- data/lib/easy_table/action_view_extensions/table_helper.rb +1 -2
- data/lib/easy_table/components/base.rb +1 -1
- data/lib/easy_table/components/column.rb +17 -12
- data/lib/easy_table/components/columns.rb +5 -3
- data/lib/easy_table/components/span.rb +9 -5
- data/lib/easy_table/components/spans.rb +1 -1
- data/lib/easy_table/table_builder.rb +13 -16
- data/lib/easy_table/version.rb +1 -2
- data/test/action_view_extensions/table_helper_test.rb +1 -5
- data/test/components/spans_test.rb +1 -5
- data/test/test_helper.rb +2 -3
- metadata +24 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6162558a23ee392fde530fb336a4eacea249cf34
|
4
|
+
data.tar.gz: 393f00005cb26d539ecb048e587d874265f2e053
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c69e4ee289a8c17bf46d39e42fe09d9fef23ebff60958022933919bae03a692db443b883f7898eb0bec458258b91efd841418f0b21ad7a8d3ac484c12e733c8
|
7
|
+
data.tar.gz: 623d48a187589ab8d9b84b5019aa826d6c47ddaeef17da0745c73947054db93e6ad9da904933a4d9ac651d555702e1a245e7ddb7fa5b246265bda6f9a8e2bfa8
|
data/.travis.yml
CHANGED
data/Appraisals
ADDED
data/circle.yml
CHANGED
data/easy_table.gemspec
CHANGED
@@ -17,5 +17,7 @@ Gem::Specification.new do |gem|
|
|
17
17
|
|
18
18
|
gem.add_dependency 'activemodel', '> 4.2'
|
19
19
|
gem.add_dependency 'actionpack', '> 4.2'
|
20
|
-
gem.add_dependency 'rubytree', '~> 0
|
20
|
+
gem.add_dependency 'rubytree', '~> 1.0'
|
21
|
+
|
22
|
+
gem.add_development_dependency "appraisal"
|
21
23
|
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ..
|
3
|
+
specs:
|
4
|
+
easy_table (0.0.9)
|
5
|
+
actionpack (> 4.2)
|
6
|
+
activemodel (> 4.2)
|
7
|
+
rubytree (~> 1.0)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
actionpack (4.2.9)
|
13
|
+
actionview (= 4.2.9)
|
14
|
+
activesupport (= 4.2.9)
|
15
|
+
rack (~> 1.6)
|
16
|
+
rack-test (~> 0.6.2)
|
17
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
18
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
19
|
+
actionview (4.2.9)
|
20
|
+
activesupport (= 4.2.9)
|
21
|
+
builder (~> 3.1)
|
22
|
+
erubis (~> 2.7.0)
|
23
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
24
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
25
|
+
activemodel (4.2.9)
|
26
|
+
activesupport (= 4.2.9)
|
27
|
+
builder (~> 3.1)
|
28
|
+
activesupport (4.2.9)
|
29
|
+
i18n (~> 0.7)
|
30
|
+
minitest (~> 5.1)
|
31
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
32
|
+
tzinfo (~> 1.1)
|
33
|
+
appraisal (2.2.0)
|
34
|
+
bundler
|
35
|
+
rake
|
36
|
+
thor (>= 0.14.0)
|
37
|
+
builder (3.2.3)
|
38
|
+
erubis (2.7.0)
|
39
|
+
i18n (0.8.6)
|
40
|
+
json (2.1.0)
|
41
|
+
loofah (2.0.3)
|
42
|
+
nokogiri (>= 1.5.9)
|
43
|
+
metaclass (0.0.4)
|
44
|
+
mini_portile2 (2.2.0)
|
45
|
+
minitest (5.10.3)
|
46
|
+
mocha (1.2.1)
|
47
|
+
metaclass (~> 0.0.1)
|
48
|
+
nokogiri (1.8.0)
|
49
|
+
mini_portile2 (~> 2.2.0)
|
50
|
+
rack (1.6.8)
|
51
|
+
rack-test (0.6.3)
|
52
|
+
rack (>= 1.0)
|
53
|
+
rails-deprecated_sanitizer (1.0.3)
|
54
|
+
activesupport (>= 4.2.0.alpha)
|
55
|
+
rails-dom-testing (1.0.8)
|
56
|
+
activesupport (>= 4.2.0.beta, < 5.0)
|
57
|
+
nokogiri (~> 1.6)
|
58
|
+
rails-deprecated_sanitizer (>= 1.0.1)
|
59
|
+
rails-html-sanitizer (1.0.3)
|
60
|
+
loofah (~> 2.0)
|
61
|
+
rake (12.0.0)
|
62
|
+
rubytree (1.0.0)
|
63
|
+
json (~> 2.1)
|
64
|
+
structured_warnings (~> 0.3)
|
65
|
+
shoulda (3.5.0)
|
66
|
+
shoulda-context (~> 1.0, >= 1.0.1)
|
67
|
+
shoulda-matchers (>= 1.4.1, < 3.0)
|
68
|
+
shoulda-context (1.2.2)
|
69
|
+
shoulda-matchers (2.8.0)
|
70
|
+
activesupport (>= 3.0.0)
|
71
|
+
structured_warnings (0.3.0)
|
72
|
+
thor (0.19.4)
|
73
|
+
thread_safe (0.3.6)
|
74
|
+
tzinfo (1.2.3)
|
75
|
+
thread_safe (~> 0.1)
|
76
|
+
|
77
|
+
PLATFORMS
|
78
|
+
ruby
|
79
|
+
|
80
|
+
DEPENDENCIES
|
81
|
+
actionpack (= 4.2.9)
|
82
|
+
appraisal
|
83
|
+
easy_table!
|
84
|
+
mocha
|
85
|
+
rake
|
86
|
+
shoulda
|
87
|
+
|
88
|
+
BUNDLED WITH
|
89
|
+
1.16.1
|
@@ -0,0 +1,86 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ..
|
3
|
+
specs:
|
4
|
+
easy_table (0.0.9)
|
5
|
+
actionpack (> 4.2)
|
6
|
+
activemodel (> 4.2)
|
7
|
+
rubytree (~> 1.0)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
actionpack (5.1.2)
|
13
|
+
actionview (= 5.1.2)
|
14
|
+
activesupport (= 5.1.2)
|
15
|
+
rack (~> 2.0)
|
16
|
+
rack-test (~> 0.6.3)
|
17
|
+
rails-dom-testing (~> 2.0)
|
18
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
19
|
+
actionview (5.1.2)
|
20
|
+
activesupport (= 5.1.2)
|
21
|
+
builder (~> 3.1)
|
22
|
+
erubi (~> 1.4)
|
23
|
+
rails-dom-testing (~> 2.0)
|
24
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
25
|
+
activemodel (5.1.2)
|
26
|
+
activesupport (= 5.1.2)
|
27
|
+
activesupport (5.1.2)
|
28
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
29
|
+
i18n (~> 0.7)
|
30
|
+
minitest (~> 5.1)
|
31
|
+
tzinfo (~> 1.1)
|
32
|
+
appraisal (2.2.0)
|
33
|
+
bundler
|
34
|
+
rake
|
35
|
+
thor (>= 0.14.0)
|
36
|
+
builder (3.2.3)
|
37
|
+
concurrent-ruby (1.0.5)
|
38
|
+
erubi (1.6.1)
|
39
|
+
i18n (0.8.6)
|
40
|
+
json (2.1.0)
|
41
|
+
loofah (2.0.3)
|
42
|
+
nokogiri (>= 1.5.9)
|
43
|
+
metaclass (0.0.4)
|
44
|
+
mini_portile2 (2.2.0)
|
45
|
+
minitest (5.10.3)
|
46
|
+
mocha (1.2.1)
|
47
|
+
metaclass (~> 0.0.1)
|
48
|
+
nokogiri (1.8.0)
|
49
|
+
mini_portile2 (~> 2.2.0)
|
50
|
+
rack (2.0.3)
|
51
|
+
rack-test (0.6.3)
|
52
|
+
rack (>= 1.0)
|
53
|
+
rails-dom-testing (2.0.3)
|
54
|
+
activesupport (>= 4.2.0)
|
55
|
+
nokogiri (>= 1.6)
|
56
|
+
rails-html-sanitizer (1.0.3)
|
57
|
+
loofah (~> 2.0)
|
58
|
+
rake (12.0.0)
|
59
|
+
rubytree (1.0.0)
|
60
|
+
json (~> 2.1)
|
61
|
+
structured_warnings (~> 0.3)
|
62
|
+
shoulda (3.5.0)
|
63
|
+
shoulda-context (~> 1.0, >= 1.0.1)
|
64
|
+
shoulda-matchers (>= 1.4.1, < 3.0)
|
65
|
+
shoulda-context (1.2.2)
|
66
|
+
shoulda-matchers (2.8.0)
|
67
|
+
activesupport (>= 3.0.0)
|
68
|
+
structured_warnings (0.3.0)
|
69
|
+
thor (0.19.4)
|
70
|
+
thread_safe (0.3.6)
|
71
|
+
tzinfo (1.2.3)
|
72
|
+
thread_safe (~> 0.1)
|
73
|
+
|
74
|
+
PLATFORMS
|
75
|
+
ruby
|
76
|
+
|
77
|
+
DEPENDENCIES
|
78
|
+
actionpack (= 5.1.2)
|
79
|
+
appraisal
|
80
|
+
easy_table!
|
81
|
+
mocha
|
82
|
+
rake
|
83
|
+
shoulda
|
84
|
+
|
85
|
+
BUNDLED WITH
|
86
|
+
1.16.1
|
data/lib/easy_table.rb
CHANGED
@@ -3,10 +3,15 @@ module EasyTable
|
|
3
3
|
class Column
|
4
4
|
include Base
|
5
5
|
|
6
|
-
delegate :tag, :capture, :content_tag, :
|
6
|
+
delegate :tag, :capture, :content_tag, to: :@template
|
7
7
|
|
8
8
|
def initialize(node, title, label, opts, template, block)
|
9
|
-
@node
|
9
|
+
@node = node
|
10
|
+
@title = title
|
11
|
+
@label = label
|
12
|
+
@template = template
|
13
|
+
@block = block
|
14
|
+
@opts = opts
|
10
15
|
header_opts = @opts.select { |k, _v| k =~ /^header_.*/ }
|
11
16
|
header_opts.each { |k, _v| @opts.delete(k) }
|
12
17
|
@header_opts = header_opts.inject({}) do |h, e|
|
@@ -21,11 +26,11 @@ module EasyTable
|
|
21
26
|
end
|
22
27
|
|
23
28
|
def td(record)
|
24
|
-
if @block.present?
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
+
html = if @block.present?
|
30
|
+
capture { @block.call(record, self) }
|
31
|
+
else
|
32
|
+
record.send(@title).to_s
|
33
|
+
end
|
29
34
|
concat(content_tag(:td, html, html_opts(record)))
|
30
35
|
end
|
31
36
|
|
@@ -37,17 +42,17 @@ module EasyTable
|
|
37
42
|
|
38
43
|
def concat(tag)
|
39
44
|
@template.safe_concat(tag) unless tag.nil?
|
40
|
-
|
45
|
+
''
|
41
46
|
end
|
42
47
|
|
43
48
|
def html_opts(record)
|
44
49
|
@opts.inject({}) do |h, e|
|
45
50
|
k, v = *e
|
46
51
|
h[k] = case v
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
52
|
+
when Proc
|
53
|
+
v.call(record)
|
54
|
+
else
|
55
|
+
v
|
51
56
|
end
|
52
57
|
h
|
53
58
|
end
|
@@ -3,9 +3,11 @@ module EasyTable
|
|
3
3
|
module Columns
|
4
4
|
def column(title, label_or_opts = nil, opts = {}, &block)
|
5
5
|
if label_or_opts.is_a?(Hash) && label_or_opts.extractable_options?
|
6
|
-
label
|
6
|
+
label = nil
|
7
|
+
opts = label_or_opts
|
7
8
|
else
|
8
|
-
label
|
9
|
+
label = label_or_opts
|
10
|
+
opts = opts
|
9
11
|
end
|
10
12
|
child = node << Tree::TreeNode.new(title)
|
11
13
|
column = Column.new(child, title, label, opts, @template, block)
|
@@ -19,4 +21,4 @@ module EasyTable
|
|
19
21
|
end
|
20
22
|
end
|
21
23
|
end
|
22
|
-
end
|
24
|
+
end
|
@@ -6,11 +6,16 @@ module EasyTable
|
|
6
6
|
include Spans
|
7
7
|
|
8
8
|
def initialize(node, title, label, html_opts, template, block)
|
9
|
-
@node
|
9
|
+
@node = node
|
10
|
+
@title = title
|
11
|
+
@label = label
|
12
|
+
@template = template
|
13
|
+
@block = block
|
14
|
+
@html_opts = html_opts
|
10
15
|
block.call(self)
|
11
16
|
end
|
12
17
|
|
13
|
-
delegate :tag, :content_tag, :
|
18
|
+
delegate :tag, :content_tag, to: :@template
|
14
19
|
|
15
20
|
def head
|
16
21
|
opts = @html_opts.merge(colspan: colspan, scope: 'col')
|
@@ -36,9 +41,8 @@ module EasyTable
|
|
36
41
|
|
37
42
|
def concat(tag)
|
38
43
|
@template.safe_concat(tag)
|
39
|
-
|
44
|
+
''
|
40
45
|
end
|
41
|
-
|
42
46
|
end
|
43
47
|
end
|
44
|
-
end
|
48
|
+
end
|
@@ -1,10 +1,9 @@
|
|
1
1
|
module EasyTable
|
2
2
|
class TableBuilder
|
3
|
-
|
4
3
|
include EasyTable::Components::Columns
|
5
4
|
include EasyTable::Components::Spans
|
6
5
|
|
7
|
-
delegate :tag, :content_tag, :
|
6
|
+
delegate :tag, :content_tag, to: :@template
|
8
7
|
|
9
8
|
def initialize(collection, template, options)
|
10
9
|
@collection = collection
|
@@ -49,11 +48,9 @@ module EasyTable
|
|
49
48
|
rows.shift
|
50
49
|
rows.each do |row|
|
51
50
|
concat(
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
end
|
56
|
-
end
|
51
|
+
content_tag(:tr) do
|
52
|
+
row.map(&:content).each(&:head)
|
53
|
+
end
|
57
54
|
)
|
58
55
|
end
|
59
56
|
end
|
@@ -62,28 +59,28 @@ module EasyTable
|
|
62
59
|
tr_opts = @tr_opts.inject({}) do |h, e|
|
63
60
|
k, v = *e
|
64
61
|
h[k] = case v
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
62
|
+
when Proc
|
63
|
+
v.call(record)
|
64
|
+
else
|
65
|
+
v
|
69
66
|
end
|
70
67
|
h
|
71
68
|
end
|
72
69
|
|
73
|
-
id =
|
74
|
-
id ||=
|
70
|
+
id = "#{record.class.model_name.to_s.parameterize}-#{record.to_param}" if record.class.respond_to?(:model_name)
|
71
|
+
id ||= "#{record.class.name.to_s.parameterize}-#{record.id}" if record.respond_to?(:id)
|
75
72
|
|
76
73
|
id.present? ?
|
77
|
-
tr_opts.merge(
|
74
|
+
tr_opts.merge(id: id) : tr_opts
|
78
75
|
end
|
79
76
|
|
80
77
|
def concat(tag)
|
81
78
|
@template.safe_concat(tag)
|
82
|
-
|
79
|
+
''
|
83
80
|
end
|
84
81
|
|
85
82
|
def options_from_hash(args)
|
86
83
|
args.last.is_a?(Hash) ? args.pop : {}
|
87
84
|
end
|
88
85
|
end
|
89
|
-
end
|
86
|
+
end
|
data/lib/easy_table/version.rb
CHANGED
data/test/test_helper.rb
CHANGED
@@ -15,16 +15,15 @@ require 'shoulda-context'
|
|
15
15
|
|
16
16
|
module Rails
|
17
17
|
def self.env
|
18
|
-
ActiveSupport::StringInquirer.new(
|
18
|
+
ActiveSupport::StringInquirer.new('test')
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
|
22
|
+
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
23
23
|
require 'easy_table'
|
24
24
|
|
25
25
|
I18n.default_locale = :en
|
26
26
|
|
27
27
|
class ActionView::TestCase
|
28
28
|
include EasyTable::ActionViewExtensions::TableHelper
|
29
|
-
|
30
29
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: easy_table
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jakub Głuszecki
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -44,14 +44,28 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0
|
47
|
+
version: '1.0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0
|
54
|
+
version: '1.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: appraisal
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
description: HTML tables made easy (in Rails 4 & 5)
|
56
70
|
email:
|
57
71
|
- jakub.gluszecki@gmail.com
|
@@ -61,12 +75,17 @@ extra_rdoc_files: []
|
|
61
75
|
files:
|
62
76
|
- ".gitignore"
|
63
77
|
- ".travis.yml"
|
78
|
+
- Appraisals
|
64
79
|
- Gemfile
|
65
80
|
- LICENSE
|
66
81
|
- README.md
|
67
82
|
- Rakefile
|
68
83
|
- circle.yml
|
69
84
|
- easy_table.gemspec
|
85
|
+
- gemfiles/rails_4.gemfile
|
86
|
+
- gemfiles/rails_4.gemfile.lock
|
87
|
+
- gemfiles/rails_5.gemfile
|
88
|
+
- gemfiles/rails_5.gemfile.lock
|
70
89
|
- lib/easy_table.rb
|
71
90
|
- lib/easy_table/action_view_extensions/table_helper.rb
|
72
91
|
- lib/easy_table/components/base.rb
|
@@ -99,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
99
118
|
version: '0'
|
100
119
|
requirements: []
|
101
120
|
rubyforge_project:
|
102
|
-
rubygems_version: 2.6.
|
121
|
+
rubygems_version: 2.6.14
|
103
122
|
signing_key:
|
104
123
|
specification_version: 4
|
105
124
|
summary: HTML tables made easy (in Rails 4 & 5)
|