dekorator 1.3.0 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +19 -2
- data/README.md +5 -25
- data/lib/dekorator/rails/record.rb +11 -0
- data/lib/dekorator/railtie.rb +2 -0
- data/lib/dekorator/version.rb +1 -1
- data/lib/dekorator.rb +1 -1
- data/lib/generators/rspec/templates/decorator_spec.rb +1 -1
- metadata +11 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a8cf77e0e4432f46ef49b35fd5b33353baab42b6bae0422107fcdde1af45a56
|
4
|
+
data.tar.gz: d37560a12fa9881661f0f819b59da82e31f6c54d2ef902642699eee6b5855085
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2376a0cfd846905cffc58b06c97606a5d2ffe1a10fd7161173fc626000617edfcf3a417c0e32f008bf5ab352803102cb8eeab6358f1bf1e5a2dc752838d1fbec
|
7
|
+
data.tar.gz: 1424f697f9b2a6f82c341aaa2b21f6b860bab7dcdece497f611790ead322551e4559ce40c8e70262180b1e001afa7a08b2e8f3573da5b15f0f08aa04e38aa532
|
data/CHANGELOG.md
CHANGED
@@ -6,17 +6,32 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
7
|
|
8
8
|
## [Unreleased]
|
9
|
-
Nothing yet
|
9
|
+
Nothing yet.
|
10
|
+
|
11
|
+
## [1.5.0] - 2024-03-06
|
12
|
+
### Added
|
13
|
+
- Add Ruby 3.3 support ([#53](https://github.com/komposable/dekorator/pull/53))
|
14
|
+
- Include `#decorated` method in `ActiveRecord::Base` ([#52](https://github.com/komposable/dekorator/pull/52))
|
15
|
+
### Removed
|
16
|
+
- Drop Ruby 2.7 support ([#53](https://github.com/komposable/dekorator/pull/53))
|
17
|
+
- Drop Rails 6.0 support ([#53](https://github.com/komposable/dekorator/pull/53))
|
18
|
+
|
19
|
+
## [1.4.0] - 2023-11-09
|
20
|
+
### Changed
|
21
|
+
- ⚠️ **Breaking** `.decorates_association` now generate `#decorated_[ASSOCIATION_NAME]` instead `#[ASSOCIATION_NAME]` ([#48](https://github.com/komposable/dekorator/pull/48))
|
10
22
|
|
11
23
|
## [1.3.0] - 2023-11-06
|
12
24
|
### Added
|
13
25
|
- Add Rails 7.1 support ([#49](https://github.com/komposable/dekorator/pull/49))
|
26
|
+
### Fixes
|
27
|
+
- Fix RSpec `decorator_spec.rb` template by using `File#exist?` instead `File#exists?` ([#51](https://github.com/komposable/dekorator/pull/51))
|
14
28
|
### Removed
|
15
29
|
- Add Rails 7.0 on CI tests via Appraisals ([#47](https://github.com/komposable/dekorator/pull/47))
|
16
30
|
- Drop Ruby 2.5 and 2.6 support ([#47](https://github.com/komposable/dekorator/pull/47))
|
17
31
|
- Remove Coveralls usage ([#47](https://github.com/komposable/dekorator/pull/47))
|
18
32
|
|
19
33
|
## [1.2.1] - 2021-10-14
|
34
|
+
### Changed
|
20
35
|
- Make decorated `Enumerable` not lazy anymore ([#46](https://github.com/komposable/dekorator/pull/46))
|
21
36
|
|
22
37
|
## [1.2.0] - 2021-10-14
|
@@ -57,7 +72,9 @@ Nothing yet
|
|
57
72
|
- Create `dekorator:install` generator ([a2a36d66](https://github.com/komposable/dekorator/commit/a2a36d66c6de6cb0a00f783794cd29f899bc04b6))
|
58
73
|
- Create `decorator` generator ([a2a36d66](https://github.com/komposable/dekorator/commit/a2a36d66c6de6cb0a00f783794cd29f899bc04b6))
|
59
74
|
|
60
|
-
[Unreleased]: https://github.com/komposable/dekorator/compare/v1.
|
75
|
+
[Unreleased]: https://github.com/komposable/dekorator/compare/v1.5.0...main
|
76
|
+
[1.5.0]: https://github.com/komposable/dekorator/compare/v1.4.0...v1.5.0
|
77
|
+
[1.4.0]: https://github.com/komposable/dekorator/compare/v1.3.0...v1.4.0
|
61
78
|
[1.3.0]: https://github.com/komposable/dekorator/compare/v1.2.1...v1.3.0
|
62
79
|
[1.2.1]: https://github.com/komposable/dekorator/compare/v1.2.0...v1.2.1
|
63
80
|
[1.2.0]: https://github.com/komposable/dekorator/compare/v1.1.0...v1.2.0
|
data/README.md
CHANGED
@@ -12,8 +12,8 @@ This gem has been inspired by our Rails development practices at [Pantographe](h
|
|
12
12
|
|
13
13
|
## Compatibility
|
14
14
|
|
15
|
-
* Ruby
|
16
|
-
* Rails 6.
|
15
|
+
* Ruby 3.0+
|
16
|
+
* Rails 6.1+
|
17
17
|
|
18
18
|
## Installation
|
19
19
|
|
@@ -108,12 +108,12 @@ class PostDecorator < ApplicationDecorator
|
|
108
108
|
end
|
109
109
|
```
|
110
110
|
|
111
|
-
In this example, `UserDecorator#posts` will be decorated
|
111
|
+
In this example, `UserDecorator#posts` will be decorated as `#decorated_posts`.
|
112
112
|
|
113
113
|
```ruby
|
114
114
|
decorated_user = decorate(User.first)
|
115
115
|
decorated_user # => UserDecorator
|
116
|
-
decorated_user.
|
116
|
+
decorated_user.decorated_posts.first # => PostDecorator
|
117
117
|
```
|
118
118
|
|
119
119
|
### Custom decorator
|
@@ -148,31 +148,11 @@ end
|
|
148
148
|
|
149
149
|
decorated_user = decorate(User.first)
|
150
150
|
decorated_user # => UserDecorator
|
151
|
-
decorated_user.
|
151
|
+
decorated_user.decorated_posts.first # => ArticleDecorator
|
152
152
|
```
|
153
153
|
|
154
154
|
## Compatibility
|
155
155
|
|
156
|
-
### ActiveAdmin
|
157
|
-
|
158
|
-
This gem is compatible with [`activeadmin`][activeadmin] ([2.8+](https://github.com/activeadmin/activeadmin/pull/6249)).
|
159
|
-
For `activeadmin` before `2.8`, use `dekorator` `1.0.*`.
|
160
|
-
|
161
|
-
Simply use `#decorate_with`
|
162
|
-
|
163
|
-
```ruby
|
164
|
-
# app/admin/post.rb
|
165
|
-
ActiveAdmin.register Post do
|
166
|
-
decorate_with PostDecorator
|
167
|
-
|
168
|
-
index do
|
169
|
-
column :title
|
170
|
-
column :image
|
171
|
-
actions
|
172
|
-
end
|
173
|
-
end
|
174
|
-
```
|
175
|
-
|
176
156
|
### Devise
|
177
157
|
|
178
158
|
If you use the [`Devise`][devise] gem you may have an issue if you decorate your
|
data/lib/dekorator/railtie.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
module Dekorator
|
4
4
|
require "dekorator/rails/controller"
|
5
|
+
require "dekorator/rails/record"
|
5
6
|
|
6
7
|
class Railtie < ::Rails::Railtie
|
7
8
|
rake_tasks do
|
@@ -10,6 +11,7 @@ module Dekorator
|
|
10
11
|
|
11
12
|
config.to_prepare do |_app|
|
12
13
|
ActionController::Base.include Dekorator::Controller
|
14
|
+
ActiveRecord::Base.include Dekorator::Record
|
13
15
|
end
|
14
16
|
end
|
15
17
|
end
|
data/lib/dekorator/version.rb
CHANGED
data/lib/dekorator.rb
CHANGED
@@ -54,7 +54,7 @@ module Dekorator
|
|
54
54
|
def decorates_association(relation_name, with: :__guess__)
|
55
55
|
relation_name = relation_name.to_sym
|
56
56
|
|
57
|
-
define_method(relation_name) do
|
57
|
+
define_method(:"decorated_#{relation_name}") do
|
58
58
|
@_decorated_associations[relation_name] ||= decorate(__getobj__.public_send(relation_name), with: with)
|
59
59
|
end
|
60
60
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dekorator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pantographe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-03-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionview
|
@@ -16,7 +16,7 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '6.
|
19
|
+
version: '6.1'
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: '7.2'
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: '6.
|
29
|
+
version: '6.1'
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '7.2'
|
@@ -36,7 +36,7 @@ dependencies:
|
|
36
36
|
requirements:
|
37
37
|
- - ">="
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: '6.
|
39
|
+
version: '6.1'
|
40
40
|
- - "<"
|
41
41
|
- !ruby/object:Gem::Version
|
42
42
|
version: '7.2'
|
@@ -46,7 +46,7 @@ dependencies:
|
|
46
46
|
requirements:
|
47
47
|
- - ">="
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: '6.
|
49
|
+
version: '6.1'
|
50
50
|
- - "<"
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: '7.2'
|
@@ -56,7 +56,7 @@ dependencies:
|
|
56
56
|
requirements:
|
57
57
|
- - ">="
|
58
58
|
- !ruby/object:Gem::Version
|
59
|
-
version: '6.
|
59
|
+
version: '6.1'
|
60
60
|
- - "<"
|
61
61
|
- !ruby/object:Gem::Version
|
62
62
|
version: '7.2'
|
@@ -66,7 +66,7 @@ dependencies:
|
|
66
66
|
requirements:
|
67
67
|
- - ">="
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: '6.
|
69
|
+
version: '6.1'
|
70
70
|
- - "<"
|
71
71
|
- !ruby/object:Gem::Version
|
72
72
|
version: '7.2'
|
@@ -83,6 +83,7 @@ files:
|
|
83
83
|
- README.md
|
84
84
|
- lib/dekorator.rb
|
85
85
|
- lib/dekorator/rails/controller.rb
|
86
|
+
- lib/dekorator/rails/record.rb
|
86
87
|
- lib/dekorator/rails/tasks/dekorator.rake
|
87
88
|
- lib/dekorator/railtie.rb
|
88
89
|
- lib/dekorator/version.rb
|
@@ -112,14 +113,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
112
113
|
requirements:
|
113
114
|
- - ">="
|
114
115
|
- !ruby/object:Gem::Version
|
115
|
-
version:
|
116
|
+
version: 3.0.0
|
116
117
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
118
|
requirements:
|
118
119
|
- - ">="
|
119
120
|
- !ruby/object:Gem::Version
|
120
121
|
version: '0'
|
121
122
|
requirements: []
|
122
|
-
rubygems_version: 3.
|
123
|
+
rubygems_version: 3.5.6
|
123
124
|
signing_key:
|
124
125
|
specification_version: 4
|
125
126
|
summary: An opinionated way of organizing model-view code in Ruby on Rails, based
|