active_decorator 1.1.1 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +53 -59
- data/README.md +1 -1
- data/active_decorator.gemspec +1 -1
- data/lib/active_decorator/decorator.rb +5 -0
- data/lib/active_decorator/version.rb +1 -1
- data/test/decorator_test.rb +18 -1
- data/test/test_helper.rb +5 -1
- metadata +7 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aaf638a40c289f98d04544cf74fb6fc4ed4e6d900e9624612ad4369a61b2032d
|
4
|
+
data.tar.gz: 014c96599fa99736ff84c75571a95e6ad49bb24d99220e382b78e8516f746759
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2270ef449d855e51524d81ba1feeda5582732969dd622a0e2e4cc4b700e8e0d1529e0f891ca39572f2c03c41cd6143a2809c8dad27fcfdca1c3408434445ee0
|
7
|
+
data.tar.gz: 515a67fa6e3964ec7b8ece6a6ec4d410fd4479aac285d2bd2d6c59eeea023a35123b54b3bb0c0e4481931328d89200c682f7756db534934d59b90ff6b52984c9
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -11,84 +11,78 @@ before_install:
|
|
11
11
|
- sudo apt update -qq
|
12
12
|
- sudo apt install -y chromium-chromedriver
|
13
13
|
- sudo ln -s /usr/lib/chromium-browser/chromedriver /usr/bin/
|
14
|
-
- gem
|
15
|
-
|
16
|
-
rvm:
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
14
|
+
- gem i bundler -v '<2'
|
15
|
+
|
16
|
+
# rvm:
|
17
|
+
# - 2.6.2
|
18
|
+
# - 2.5.5
|
19
|
+
# - 2.4.5
|
20
|
+
# - 2.3.8
|
21
|
+
# - 2.2.10
|
22
|
+
# - 2.1.10
|
23
|
+
# - 2.0.0
|
24
|
+
# gemfile:
|
25
|
+
# - gemfiles/Gemfile-rails.5.2.x
|
26
|
+
# - gemfiles/Gemfile-rails.5.1.x
|
27
|
+
# - gemfiles/Gemfile-rails.5.0.x
|
28
|
+
# - gemfiles/Gemfile-rails.4.2.x
|
29
|
+
# - gemfiles/Gemfile-rails.4.1.x
|
30
|
+
# - gemfiles/Gemfile-rails.4.0.x
|
31
|
+
# - gemfiles/Gemfile-rails.3.2.x
|
31
32
|
|
32
33
|
matrix:
|
33
|
-
|
34
|
-
- rvm: 2.
|
34
|
+
include:
|
35
|
+
- rvm: 2.6.2
|
35
36
|
gemfile: gemfiles/Gemfile-rails.5.2.x
|
36
|
-
- rvm: 2.
|
37
|
+
- rvm: 2.6.2
|
37
38
|
gemfile: gemfiles/Gemfile-rails.5.2.x
|
38
|
-
|
39
|
-
|
40
|
-
- rvm: 2.3.7
|
41
|
-
gemfile: gemfiles/Gemfile-rails.5.1.x
|
42
|
-
- rvm: 2.1.10
|
39
|
+
env: API=1
|
40
|
+
- rvm: 2.6.2
|
43
41
|
gemfile: gemfiles/Gemfile-rails.5.1.x
|
44
|
-
- rvm: 2.
|
42
|
+
- rvm: 2.6.2
|
45
43
|
gemfile: gemfiles/Gemfile-rails.5.1.x
|
46
|
-
|
47
|
-
|
48
|
-
- rvm: 2.3.7
|
49
|
-
gemfile: gemfiles/Gemfile-rails.5.0.x
|
50
|
-
- rvm: 2.1.10
|
44
|
+
env: API=1
|
45
|
+
- rvm: 2.6.2
|
51
46
|
gemfile: gemfiles/Gemfile-rails.5.0.x
|
52
|
-
- rvm: 2.
|
47
|
+
- rvm: 2.6.2
|
53
48
|
gemfile: gemfiles/Gemfile-rails.5.0.x
|
54
|
-
|
55
|
-
|
49
|
+
env: API=1
|
50
|
+
|
51
|
+
- rvm: 2.5.5
|
52
|
+
gemfile: gemfiles/Gemfile-rails.5.2.x
|
53
|
+
|
56
54
|
- rvm: 2.4.5
|
55
|
+
gemfile: gemfiles/Gemfile-rails.5.2.x
|
56
|
+
|
57
|
+
- rvm: 2.3.8
|
58
|
+
gemfile: gemfiles/Gemfile-rails.5.2.x
|
59
|
+
- rvm: 2.3.8
|
57
60
|
gemfile: gemfiles/Gemfile-rails.4.2.x
|
58
|
-
- rvm: 2.
|
59
|
-
gemfile: gemfiles/Gemfile-rails.4.1.x
|
60
|
-
- rvm: 2.4.5
|
61
|
-
gemfile: gemfiles/Gemfile-rails.4.1.x
|
62
|
-
- rvm: 2.2.10
|
61
|
+
- rvm: 2.3.8
|
63
62
|
gemfile: gemfiles/Gemfile-rails.4.1.x
|
64
|
-
- rvm: 2.
|
65
|
-
gemfile: gemfiles/Gemfile-rails.4.1.x
|
66
|
-
- rvm: 2.5.3
|
67
|
-
gemfile: gemfiles/Gemfile-rails.4.0.x
|
68
|
-
- rvm: 2.4.5
|
63
|
+
- rvm: 2.3.8
|
69
64
|
gemfile: gemfiles/Gemfile-rails.4.0.x
|
65
|
+
|
70
66
|
- rvm: 2.2.10
|
71
|
-
gemfile: gemfiles/Gemfile-rails.
|
67
|
+
gemfile: gemfiles/Gemfile-rails.5.2.x
|
68
|
+
|
72
69
|
- rvm: 2.1.10
|
73
|
-
gemfile: gemfiles/Gemfile-rails.4.
|
74
|
-
|
75
|
-
|
76
|
-
|
70
|
+
gemfile: gemfiles/Gemfile-rails.4.2.x
|
71
|
+
|
72
|
+
- rvm: 2.0.0
|
73
|
+
gemfile: gemfiles/Gemfile-rails.4.2.x
|
74
|
+
|
75
|
+
- rvm: 2.0.0
|
77
76
|
gemfile: gemfiles/Gemfile-rails.3.2.x
|
78
|
-
|
77
|
+
|
78
|
+
|
79
79
|
- rvm: ruby-head
|
80
80
|
gemfile: gemfiles/Gemfile-rails.edge
|
81
|
-
|
82
|
-
gemfile: gemfiles/Gemfile-rails.5.2.x
|
83
|
-
env: API=1
|
84
|
-
- rvm: 2.5.3
|
85
|
-
gemfile: gemfiles/Gemfile-rails.5.1.x
|
86
|
-
env: API=1
|
87
|
-
- rvm: 2.5.3
|
88
|
-
gemfile: gemfiles/Gemfile-rails.5.0.x
|
89
|
-
env: API=1
|
81
|
+
|
90
82
|
- rvm: ruby-head
|
91
83
|
gemfile: gemfiles/Gemfile-rails.edge
|
92
84
|
env: API=1
|
85
|
+
|
93
86
|
allow_failures:
|
94
87
|
- rvm: ruby-head
|
88
|
+
- gemfile: gemfiles/Gemfile-rails.edge
|
data/README.md
CHANGED
@@ -15,7 +15,7 @@ A simple and Rubyish view helper for Rails 3, Rails 4, Rails 5, and Rails 6. Kee
|
|
15
15
|
|
16
16
|
## Supported versions ##
|
17
17
|
|
18
|
-
* Ruby 2.0.0, 2.1.x, 2.2.x, 2.3.x, 2.4.x,
|
18
|
+
* Ruby 2.0.0, 2.1.x, 2.2.x, 2.3.x, 2.4.x, 2.5.x, 2.6.x, and 2.7 (trunk)
|
19
19
|
|
20
20
|
* Rails 3.2.x, 4.0.x, 4.1.x, 4.2.x, 5.0, 5.1, 5.2, and 6.0 (edge)
|
21
21
|
|
data/active_decorator.gemspec
CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |s|
|
|
22
22
|
s.add_development_dependency 'selenium-webdriver'
|
23
23
|
s.add_development_dependency 'puma'
|
24
24
|
s.add_development_dependency 'capybara'
|
25
|
-
s.add_development_dependency 'sqlite3'
|
25
|
+
s.add_development_dependency 'sqlite3', '< 1.4'
|
26
26
|
s.add_development_dependency 'rake'
|
27
27
|
s.add_development_dependency 'jbuilder'
|
28
28
|
end
|
@@ -15,6 +15,7 @@ module ActiveDecorator
|
|
15
15
|
# Decorates the given object.
|
16
16
|
# Plus, performs special decoration for the classes below:
|
17
17
|
# Array: decorates its each element
|
18
|
+
# Hash: decorates its each value
|
18
19
|
# AR::Relation: decorates its each record lazily
|
19
20
|
# AR model: decorates its associations on the fly
|
20
21
|
#
|
@@ -29,6 +30,10 @@ module ActiveDecorator
|
|
29
30
|
obj.each do |r|
|
30
31
|
decorate r
|
31
32
|
end
|
33
|
+
elsif obj.is_a?(Hash)
|
34
|
+
obj.values.each do |v|
|
35
|
+
decorate v
|
36
|
+
end
|
32
37
|
elsif defined?(ActiveRecord) && obj.is_a?(ActiveRecord::Relation)
|
33
38
|
# don't call each nor to_a immediately
|
34
39
|
if obj.respond_to?(:records)
|
data/test/decorator_test.rb
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
require 'test_helper'
|
4
4
|
|
5
5
|
class DecoratorTest < Test::Unit::TestCase
|
6
|
-
|
7
6
|
test 'it returns the object on decoration' do
|
8
7
|
book = Book.new title: 'Boek'
|
9
8
|
assert_equal book, ActiveDecorator::Decorator.instance.decorate(book)
|
@@ -31,4 +30,22 @@ class DecoratorTest < Test::Unit::TestCase
|
|
31
30
|
books = Book.all
|
32
31
|
assert_equal books, ActiveDecorator::Decorator.instance.decorate(ActiveDecorator::Decorator.instance.decorate(books))
|
33
32
|
end
|
33
|
+
|
34
|
+
test 'decorating Array decorates its each element' do
|
35
|
+
array = [Book.new(title: 'Boek')]
|
36
|
+
assert_equal array, ActiveDecorator::Decorator.instance.decorate(array)
|
37
|
+
|
38
|
+
array.each do |value|
|
39
|
+
assert value.is_a?(BookDecorator)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
test 'decorating Hash decorates its each value' do
|
44
|
+
hash = {some_record: Book.new(title: 'Boek')}
|
45
|
+
assert_equal hash, ActiveDecorator::Decorator.instance.decorate(hash)
|
46
|
+
|
47
|
+
hash.values.each do |value|
|
48
|
+
assert value.is_a?(BookDecorator)
|
49
|
+
end
|
50
|
+
end
|
34
51
|
end
|
data/test/test_helper.rb
CHANGED
@@ -30,7 +30,11 @@ rescue LoadError
|
|
30
30
|
include Capybara::DSL
|
31
31
|
end
|
32
32
|
else
|
33
|
-
|
33
|
+
if ActionPack::VERSION::STRING > '5.2'
|
34
|
+
ActionDispatch::SystemTestCase.driven_by :selenium, using: :headless_chrome
|
35
|
+
else
|
36
|
+
ActionDispatch::SystemTestCase.driven_by :selenium_chrome_headless
|
37
|
+
end
|
34
38
|
end
|
35
39
|
|
36
40
|
module DatabaseDeleter
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_decorator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Akira Matsuda
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: test-unit-rails
|
@@ -70,16 +70,16 @@ dependencies:
|
|
70
70
|
name: sqlite3
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - "<"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '1.4'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - "<"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '1.4'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rake
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -197,8 +197,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
197
197
|
- !ruby/object:Gem::Version
|
198
198
|
version: '0'
|
199
199
|
requirements: []
|
200
|
-
|
201
|
-
rubygems_version: 2.7.6
|
200
|
+
rubygems_version: 3.0.3
|
202
201
|
signing_key:
|
203
202
|
specification_version: 4
|
204
203
|
summary: A simple and Rubyish view helper for Rails
|