lite-decorator 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +19 -3
- data/CHANGELOG.md +19 -0
- data/Gemfile.lock +112 -54
- data/README.md +18 -4
- data/lib/generators/rails/USAGE +8 -0
- data/lib/generators/rails/decorator_generator.rb +27 -0
- data/lib/generators/rails/templates/decorator.rb.tt +6 -0
- data/lib/lite/decorator.rb +2 -0
- data/lib/lite/decorator/version.rb +1 -1
- data/lite-decorator.gemspec +3 -1
- metadata +38 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cfcd81ece1dd2fed95e2ecc6844f3a471bcd2d3a703316ac65c05721b4c1ee68
|
4
|
+
data.tar.gz: 38d6fcc2ef7c118d41fbe87c6bd4d4d5c7ffb78dd8e46b4c9754da8fefc45752
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88dd743cd104b85e2ffd7f299efdad4421da9474f5515f678ba7e7dd7a43219cac4c0823f7139116fb3afe3c267d7470096c84b79fa49380a18c64c8a52049ee
|
7
|
+
data.tar.gz: 866478f1b47392b2c9f79ca5ae4ed72a81dca46c41b8cbe0b0d8410c5016467bf4126971ccc0514289b885bc32bc5f39e55df2af7091f59ec0e5147cd6d3904a
|
data/.rubocop.yml
CHANGED
@@ -1,12 +1,16 @@
|
|
1
1
|
require:
|
2
2
|
- rubocop-performance
|
3
|
+
- rubocop-rake
|
3
4
|
- rubocop-rspec
|
4
5
|
AllCops:
|
5
|
-
TargetRubyVersion:
|
6
|
+
TargetRubyVersion: 3.0
|
7
|
+
NewCops: enable
|
6
8
|
DisplayCopNames: true
|
7
9
|
DisplayStyleGuide: true
|
8
|
-
|
9
|
-
|
10
|
+
Gemspec/RequiredRubyVersion:
|
11
|
+
Enabled: false
|
12
|
+
Layout/EmptyLinesAroundAttributeAccessor:
|
13
|
+
Enabled: true
|
10
14
|
Layout/EmptyLinesAroundBlockBody:
|
11
15
|
Exclude:
|
12
16
|
- 'spec/**/**/*'
|
@@ -14,14 +18,26 @@ Layout/EmptyLinesAroundClassBody:
|
|
14
18
|
EnforcedStyle: empty_lines_except_namespace
|
15
19
|
Layout/EmptyLinesAroundModuleBody:
|
16
20
|
EnforcedStyle: empty_lines_except_namespace
|
21
|
+
Layout/LineLength:
|
22
|
+
Max: 100
|
23
|
+
Layout/SpaceAroundMethodCallOperator:
|
24
|
+
Enabled: true
|
25
|
+
Lint/RaiseException:
|
26
|
+
Enabled: true
|
27
|
+
Lint/StructNewOverride:
|
28
|
+
Enabled: true
|
17
29
|
Metrics/BlockLength:
|
18
30
|
Exclude:
|
19
31
|
- 'spec/**/**/*'
|
20
32
|
- '*.gemspec'
|
33
|
+
Naming/MemoizedInstanceVariableName:
|
34
|
+
Enabled: false
|
21
35
|
RSpec/ExampleLength:
|
22
36
|
Enabled: false
|
23
37
|
RSpec/MultipleExpectations:
|
24
38
|
Enabled: false
|
39
|
+
Style/ArgumentsForwarding:
|
40
|
+
Enabled: false
|
25
41
|
Style/Documentation:
|
26
42
|
Enabled: false
|
27
43
|
Style/ExpandPathArguments:
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [1.1.0] - 2021-07-19
|
10
|
+
### Added
|
11
|
+
- Added Ruby 3.0 support
|
12
|
+
|
13
|
+
## [1.0.3] - 2019-12-21
|
14
|
+
### Added
|
15
|
+
- Added ruby 2.7 support
|
16
|
+
### Removed
|
17
|
+
- Removed generator empty directory check
|
18
|
+
|
19
|
+
## [1.0.2] - 2019-12-20
|
20
|
+
### Removed
|
21
|
+
- Removed lite-decorator generator
|
22
|
+
- Removed spec from rails generator
|
23
|
+
|
24
|
+
## [1.0.1] - 2019-09-02
|
25
|
+
### Added
|
26
|
+
- Add rails generators
|
27
|
+
|
9
28
|
## [1.0.0] - 2019-09-01
|
10
29
|
### Added
|
11
30
|
- Initial project version
|
data/Gemfile.lock
CHANGED
@@ -1,73 +1,129 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
lite-decorator (1.
|
4
|
+
lite-decorator (1.1.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
9
|
+
actionpack (6.1.4)
|
10
|
+
actionview (= 6.1.4)
|
11
|
+
activesupport (= 6.1.4)
|
12
|
+
rack (~> 2.0, >= 2.0.9)
|
13
|
+
rack-test (>= 0.6.3)
|
14
|
+
rails-dom-testing (~> 2.0)
|
15
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
16
|
+
actionview (6.1.4)
|
17
|
+
activesupport (= 6.1.4)
|
18
|
+
builder (~> 3.1)
|
19
|
+
erubi (~> 1.4)
|
20
|
+
rails-dom-testing (~> 2.0)
|
21
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
22
|
+
activemodel (6.1.4)
|
23
|
+
activesupport (= 6.1.4)
|
24
|
+
activerecord (6.1.4)
|
25
|
+
activemodel (= 6.1.4)
|
26
|
+
activesupport (= 6.1.4)
|
27
|
+
activesupport (6.1.4)
|
15
28
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
16
|
-
i18n (>=
|
17
|
-
minitest (
|
18
|
-
tzinfo (~>
|
19
|
-
zeitwerk (~> 2.
|
20
|
-
ast (2.4.
|
29
|
+
i18n (>= 1.6, < 2)
|
30
|
+
minitest (>= 5.1)
|
31
|
+
tzinfo (~> 2.0)
|
32
|
+
zeitwerk (~> 2.3)
|
33
|
+
ast (2.4.2)
|
34
|
+
builder (3.2.4)
|
21
35
|
colorize (0.8.1)
|
22
|
-
concurrent-ruby (1.1.
|
23
|
-
|
24
|
-
|
25
|
-
|
36
|
+
concurrent-ruby (1.1.9)
|
37
|
+
crass (1.0.6)
|
38
|
+
database_cleaner (2.0.1)
|
39
|
+
database_cleaner-active_record (~> 2.0.0)
|
40
|
+
database_cleaner-active_record (2.0.1)
|
41
|
+
activerecord (>= 5.a)
|
42
|
+
database_cleaner-core (~> 2.0.0)
|
43
|
+
database_cleaner-core (2.0.1)
|
44
|
+
diff-lcs (1.4.4)
|
45
|
+
erubi (1.10.0)
|
46
|
+
fasterer (0.9.0)
|
26
47
|
colorize (~> 0.7)
|
27
|
-
ruby_parser (>= 3.
|
28
|
-
|
48
|
+
ruby_parser (>= 3.14.1)
|
49
|
+
generator_spec (0.9.4)
|
50
|
+
activesupport (>= 3.0.0)
|
51
|
+
railties (>= 3.0.0)
|
52
|
+
i18n (1.8.10)
|
29
53
|
concurrent-ruby (~> 1.0)
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
54
|
+
loofah (2.10.0)
|
55
|
+
crass (~> 1.0.2)
|
56
|
+
nokogiri (>= 1.5.9)
|
57
|
+
method_source (1.0.0)
|
58
|
+
mini_portile2 (2.5.3)
|
59
|
+
minitest (5.14.4)
|
60
|
+
nokogiri (1.11.7)
|
61
|
+
mini_portile2 (~> 2.5.0)
|
62
|
+
racc (~> 1.4)
|
63
|
+
parallel (1.20.1)
|
64
|
+
parser (3.0.2.0)
|
65
|
+
ast (~> 2.4.1)
|
66
|
+
racc (1.5.2)
|
67
|
+
rack (2.2.3)
|
68
|
+
rack-test (1.1.0)
|
69
|
+
rack (>= 1.0, < 3)
|
70
|
+
rails-dom-testing (2.0.3)
|
71
|
+
activesupport (>= 4.2.0)
|
72
|
+
nokogiri (>= 1.6)
|
73
|
+
rails-html-sanitizer (1.3.0)
|
74
|
+
loofah (~> 2.3)
|
75
|
+
railties (6.1.4)
|
76
|
+
actionpack (= 6.1.4)
|
77
|
+
activesupport (= 6.1.4)
|
78
|
+
method_source
|
79
|
+
rake (>= 0.13)
|
80
|
+
thor (~> 1.0)
|
35
81
|
rainbow (3.0.0)
|
36
|
-
rake (
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
rspec-
|
41
|
-
|
42
|
-
rspec-
|
43
|
-
rspec-
|
82
|
+
rake (13.0.6)
|
83
|
+
regexp_parser (2.1.1)
|
84
|
+
rexml (3.2.5)
|
85
|
+
rspec (3.10.0)
|
86
|
+
rspec-core (~> 3.10.0)
|
87
|
+
rspec-expectations (~> 3.10.0)
|
88
|
+
rspec-mocks (~> 3.10.0)
|
89
|
+
rspec-core (3.10.1)
|
90
|
+
rspec-support (~> 3.10.0)
|
91
|
+
rspec-expectations (3.10.1)
|
44
92
|
diff-lcs (>= 1.2.0, < 2.0)
|
45
|
-
rspec-support (~> 3.
|
46
|
-
rspec-mocks (3.
|
93
|
+
rspec-support (~> 3.10.0)
|
94
|
+
rspec-mocks (3.10.2)
|
47
95
|
diff-lcs (>= 1.2.0, < 2.0)
|
48
|
-
rspec-support (~> 3.
|
49
|
-
rspec-support (3.
|
50
|
-
rubocop (
|
51
|
-
jaro_winkler (~> 1.5.1)
|
96
|
+
rspec-support (~> 3.10.0)
|
97
|
+
rspec-support (3.10.2)
|
98
|
+
rubocop (1.18.3)
|
52
99
|
parallel (~> 1.10)
|
53
|
-
parser (>=
|
100
|
+
parser (>= 3.0.0.0)
|
54
101
|
rainbow (>= 2.2.2, < 4.0)
|
102
|
+
regexp_parser (>= 1.8, < 3.0)
|
103
|
+
rexml
|
104
|
+
rubocop-ast (>= 1.7.0, < 2.0)
|
55
105
|
ruby-progressbar (~> 1.7)
|
56
|
-
unicode-display_width (>= 1.4.0, <
|
57
|
-
rubocop-
|
58
|
-
|
59
|
-
rubocop-
|
60
|
-
rubocop (>=
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
106
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
107
|
+
rubocop-ast (1.8.0)
|
108
|
+
parser (>= 3.0.1.1)
|
109
|
+
rubocop-performance (1.11.4)
|
110
|
+
rubocop (>= 1.7.0, < 2.0)
|
111
|
+
rubocop-ast (>= 0.4.0)
|
112
|
+
rubocop-rake (0.6.0)
|
113
|
+
rubocop (~> 1.0)
|
114
|
+
rubocop-rspec (2.4.0)
|
115
|
+
rubocop (~> 1.0)
|
116
|
+
rubocop-ast (>= 1.1.0)
|
117
|
+
ruby-progressbar (1.11.0)
|
118
|
+
ruby_parser (3.16.0)
|
119
|
+
sexp_processor (~> 4.15, >= 4.15.1)
|
120
|
+
sexp_processor (4.15.3)
|
121
|
+
sqlite3 (1.4.2)
|
122
|
+
thor (1.1.0)
|
123
|
+
tzinfo (2.0.4)
|
124
|
+
concurrent-ruby (~> 1.0)
|
125
|
+
unicode-display_width (2.0.0)
|
126
|
+
zeitwerk (2.4.2)
|
71
127
|
|
72
128
|
PLATFORMS
|
73
129
|
ruby
|
@@ -77,13 +133,15 @@ DEPENDENCIES
|
|
77
133
|
bundler
|
78
134
|
database_cleaner
|
79
135
|
fasterer
|
136
|
+
generator_spec
|
80
137
|
lite-decorator!
|
81
138
|
rake
|
82
139
|
rspec
|
83
140
|
rubocop
|
84
141
|
rubocop-performance
|
142
|
+
rubocop-rake
|
85
143
|
rubocop-rspec
|
86
144
|
sqlite3
|
87
145
|
|
88
146
|
BUNDLED WITH
|
89
|
-
2.
|
147
|
+
2.2.24
|
data/README.md
CHANGED
@@ -24,12 +24,26 @@ Or install it yourself as:
|
|
24
24
|
|
25
25
|
## Table of Contents
|
26
26
|
|
27
|
+
* [Setup](#setup)
|
27
28
|
* [Usage](#usage)
|
28
|
-
* [Access](#access)
|
29
29
|
|
30
|
-
##
|
30
|
+
## Setup
|
31
|
+
|
32
|
+
### Generator
|
33
|
+
|
34
|
+
Use `rails g decorator NAME` will generate the following files:
|
35
|
+
|
36
|
+
```erb
|
37
|
+
app/decorators/[name]_decorator.rb
|
38
|
+
```
|
39
|
+
|
40
|
+
If a `ApplicationDecorator` file in the `app/decorators` directory is available, the
|
41
|
+
generator will create file that inherit from `ApplicationDecorator` if not it will
|
42
|
+
fallback to `Lite::Decorator::Base`.
|
31
43
|
|
32
|
-
|
44
|
+
## Decorator
|
45
|
+
|
46
|
+
You will need to fill this class with the methods you want to decorate:
|
33
47
|
|
34
48
|
```ruby
|
35
49
|
class UserDecorator < Lite::Decorator::Base
|
@@ -41,7 +55,7 @@ class UserDecorator < Lite::Decorator::Base
|
|
41
55
|
end
|
42
56
|
```
|
43
57
|
|
44
|
-
##
|
58
|
+
## Usage
|
45
59
|
|
46
60
|
To access the decorator you need to pass the object to the decorator class and thats it.
|
47
61
|
You can even decorate a collection of objects by passing the collection to `decorate`.
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rails/generators'
|
4
|
+
|
5
|
+
module Rails
|
6
|
+
class DecoratorGenerator < Rails::Generators::NamedBase
|
7
|
+
|
8
|
+
source_root File.expand_path('../templates', __FILE__)
|
9
|
+
check_class_collision suffix: 'Decorator'
|
10
|
+
|
11
|
+
def copy_files
|
12
|
+
path = File.join('app', 'decorators', class_path, "#{file_name}_decorator.rb")
|
13
|
+
template('decorator.rb.tt', path)
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def file_name
|
19
|
+
@_file_name ||= remove_possible_suffix(super)
|
20
|
+
end
|
21
|
+
|
22
|
+
def remove_possible_suffix(name)
|
23
|
+
name.sub(/_?decorator$/i, '')
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
data/lib/lite/decorator.rb
CHANGED
data/lite-decorator.gemspec
CHANGED
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
|
|
25
25
|
)
|
26
26
|
else
|
27
27
|
raise 'RubyGems 2.0 or newer is required to protect against ' \
|
28
|
-
|
28
|
+
'public gem pushes.'
|
29
29
|
end
|
30
30
|
|
31
31
|
# Specify which files should be added to the gem when it is released.
|
@@ -41,10 +41,12 @@ Gem::Specification.new do |spec|
|
|
41
41
|
spec.add_development_dependency 'bundler'
|
42
42
|
spec.add_development_dependency 'database_cleaner'
|
43
43
|
spec.add_development_dependency 'fasterer'
|
44
|
+
spec.add_development_dependency 'generator_spec'
|
44
45
|
spec.add_development_dependency 'rake'
|
45
46
|
spec.add_development_dependency 'rspec'
|
46
47
|
spec.add_development_dependency 'rubocop'
|
47
48
|
spec.add_development_dependency 'rubocop-performance'
|
49
|
+
spec.add_development_dependency 'rubocop-rake'
|
48
50
|
spec.add_development_dependency 'rubocop-rspec'
|
49
51
|
spec.add_development_dependency 'sqlite3'
|
50
52
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lite-decorator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juan Gomez
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: generator_spec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: rake
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,6 +136,20 @@ dependencies:
|
|
122
136
|
- - ">="
|
123
137
|
- !ruby/object:Gem::Version
|
124
138
|
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: rubocop-rake
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
125
153
|
- !ruby/object:Gem::Dependency
|
126
154
|
name: rubocop-rspec
|
127
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -150,7 +178,7 @@ dependencies:
|
|
150
178
|
- - ">="
|
151
179
|
- !ruby/object:Gem::Version
|
152
180
|
version: '0'
|
153
|
-
description:
|
181
|
+
description:
|
154
182
|
email:
|
155
183
|
- j.gomez@drexed.com
|
156
184
|
executables: []
|
@@ -172,6 +200,9 @@ files:
|
|
172
200
|
- _config.yml
|
173
201
|
- bin/console
|
174
202
|
- bin/setup
|
203
|
+
- lib/generators/rails/USAGE
|
204
|
+
- lib/generators/rails/decorator_generator.rb
|
205
|
+
- lib/generators/rails/templates/decorator.rb.tt
|
175
206
|
- lib/lite/decorator.rb
|
176
207
|
- lib/lite/decorator/base.rb
|
177
208
|
- lib/lite/decorator/version.rb
|
@@ -180,7 +211,7 @@ homepage: http://drexed.github.io/lite-decorator
|
|
180
211
|
licenses:
|
181
212
|
- MIT
|
182
213
|
metadata: {}
|
183
|
-
post_install_message:
|
214
|
+
post_install_message:
|
184
215
|
rdoc_options: []
|
185
216
|
require_paths:
|
186
217
|
- lib
|
@@ -195,8 +226,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
195
226
|
- !ruby/object:Gem::Version
|
196
227
|
version: '0'
|
197
228
|
requirements: []
|
198
|
-
rubygems_version: 3.
|
199
|
-
signing_key:
|
229
|
+
rubygems_version: 3.2.24
|
230
|
+
signing_key:
|
200
231
|
specification_version: 4
|
201
232
|
summary: Ruby Decorator based framework (aka decorator/presenter objects)
|
202
233
|
test_files: []
|