lite-decorator 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -0
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +43 -1
- data/README.md +13 -3
- data/lib/generators/lite/decorator/install_generator.rb +17 -0
- data/lib/generators/lite/decorator/templates/install.rb +4 -0
- data/lib/generators/rails/USAGE +9 -0
- data/lib/generators/rails/decorator_generator.rb +34 -0
- data/lib/generators/rails/templates/decorator.rb.tt +6 -0
- data/lib/generators/rails/templates/spec.rb.tt +7 -0
- data/lib/lite/decorator/version.rb +1 -1
- data/lib/lite/decorator.rb +3 -0
- data/lite-decorator.gemspec +1 -0
- metadata +22 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b217a968ad5aa2bfc976383a9458990fbfad83387e0f533a4f34b7666ce895a7
|
4
|
+
data.tar.gz: 8071528b21c91446bdd136b49c9aca06cc93594af049ac7e5ece08a36dcd6990
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a9e7f484acae99a89351772d7e5e8d820bb9ecdbee1b0811a0f76ff49f6dff9797d8706b936e0fb8607ab0c83735c81e93ab8f6bd5346f4c5ece47e14123df73
|
7
|
+
data.tar.gz: 9526e30deed656eb2deb927d78b6d5762cd00aa1ce308e6ea556d7e12ee64a1a33e609e9bd36980d0460ef887e87661d1352324cfa0a820d9b424e6ecd2618d8
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,11 +1,24 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
lite-decorator (1.0.
|
4
|
+
lite-decorator (1.0.1)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
+
actionpack (6.0.0)
|
10
|
+
actionview (= 6.0.0)
|
11
|
+
activesupport (= 6.0.0)
|
12
|
+
rack (~> 2.0)
|
13
|
+
rack-test (>= 0.6.3)
|
14
|
+
rails-dom-testing (~> 2.0)
|
15
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
16
|
+
actionview (6.0.0)
|
17
|
+
activesupport (= 6.0.0)
|
18
|
+
builder (~> 3.1)
|
19
|
+
erubi (~> 1.4)
|
20
|
+
rails-dom-testing (~> 2.0)
|
21
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
9
22
|
activemodel (6.0.0)
|
10
23
|
activesupport (= 6.0.0)
|
11
24
|
activerecord (6.0.0)
|
@@ -18,20 +31,47 @@ GEM
|
|
18
31
|
tzinfo (~> 1.1)
|
19
32
|
zeitwerk (~> 2.1, >= 2.1.8)
|
20
33
|
ast (2.4.0)
|
34
|
+
builder (3.2.3)
|
21
35
|
colorize (0.8.1)
|
22
36
|
concurrent-ruby (1.1.5)
|
37
|
+
crass (1.0.4)
|
23
38
|
database_cleaner (1.7.0)
|
24
39
|
diff-lcs (1.3)
|
40
|
+
erubi (1.8.0)
|
25
41
|
fasterer (0.6.0)
|
26
42
|
colorize (~> 0.7)
|
27
43
|
ruby_parser (>= 3.13.0)
|
44
|
+
generator_spec (0.9.4)
|
45
|
+
activesupport (>= 3.0.0)
|
46
|
+
railties (>= 3.0.0)
|
28
47
|
i18n (1.6.0)
|
29
48
|
concurrent-ruby (~> 1.0)
|
30
49
|
jaro_winkler (1.5.3)
|
50
|
+
loofah (2.2.3)
|
51
|
+
crass (~> 1.0.2)
|
52
|
+
nokogiri (>= 1.5.9)
|
53
|
+
method_source (0.9.2)
|
54
|
+
mini_portile2 (2.4.0)
|
31
55
|
minitest (5.11.3)
|
56
|
+
nokogiri (1.10.4)
|
57
|
+
mini_portile2 (~> 2.4.0)
|
32
58
|
parallel (1.17.0)
|
33
59
|
parser (2.6.4.0)
|
34
60
|
ast (~> 2.4.0)
|
61
|
+
rack (2.0.7)
|
62
|
+
rack-test (1.1.0)
|
63
|
+
rack (>= 1.0, < 3)
|
64
|
+
rails-dom-testing (2.0.3)
|
65
|
+
activesupport (>= 4.2.0)
|
66
|
+
nokogiri (>= 1.6)
|
67
|
+
rails-html-sanitizer (1.2.0)
|
68
|
+
loofah (~> 2.2, >= 2.2.2)
|
69
|
+
railties (6.0.0)
|
70
|
+
actionpack (= 6.0.0)
|
71
|
+
activesupport (= 6.0.0)
|
72
|
+
method_source
|
73
|
+
rake (>= 0.8.7)
|
74
|
+
thor (>= 0.20.3, < 2.0)
|
35
75
|
rainbow (3.0.0)
|
36
76
|
rake (12.3.3)
|
37
77
|
rspec (3.8.0)
|
@@ -63,6 +103,7 @@ GEM
|
|
63
103
|
sexp_processor (~> 4.9)
|
64
104
|
sexp_processor (4.12.1)
|
65
105
|
sqlite3 (1.4.1)
|
106
|
+
thor (0.20.3)
|
66
107
|
thread_safe (0.3.6)
|
67
108
|
tzinfo (1.2.5)
|
68
109
|
thread_safe (~> 0.1)
|
@@ -77,6 +118,7 @@ DEPENDENCIES
|
|
77
118
|
bundler
|
78
119
|
database_cleaner
|
79
120
|
fasterer
|
121
|
+
generator_spec
|
80
122
|
lite-decorator!
|
81
123
|
rake
|
82
124
|
rspec
|
data/README.md
CHANGED
@@ -24,15 +24,25 @@ 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
|
## Usage
|
31
31
|
|
32
|
-
|
32
|
+
`rails g lite:decorator:install` will generate the following file:
|
33
|
+
`../app/decorators/application_decorator.rb`
|
33
34
|
|
34
35
|
```ruby
|
35
|
-
class
|
36
|
+
class ApplicationDecorator < Lite::Query::Base
|
37
|
+
end
|
38
|
+
```
|
39
|
+
|
40
|
+
Use `rails g decorator NAME` will generate the following file: `../app/decorators/[name]_decorator.rb`
|
41
|
+
|
42
|
+
You will then need to fill this class with the methods you want to decorate:
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
class UserDecorator < ApplicationDecorator
|
36
46
|
|
37
47
|
def full_name
|
38
48
|
first_name + ' ' + last_name
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rails/generators'
|
4
|
+
|
5
|
+
module Lite
|
6
|
+
module Decorator
|
7
|
+
class InstallGenerator < Rails::Generators::Base
|
8
|
+
|
9
|
+
source_root File.expand_path('../templates', __FILE__)
|
10
|
+
|
11
|
+
def copy_application_query_file
|
12
|
+
copy_file('install.rb', 'app/decorators/application_decorator.rb')
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,34 @@
|
|
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
|
+
empty_directory('app/decorators')
|
14
|
+
template('decorator.rb.tt', path)
|
15
|
+
end
|
16
|
+
|
17
|
+
def copy_specs
|
18
|
+
path = File.join('spec', 'decorators', class_path, "#{file_name}_decorator_spec.rb")
|
19
|
+
empty_directory('spec/decorators')
|
20
|
+
template('spec.rb.tt', path)
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def file_name
|
26
|
+
@_file_name ||= remove_possible_suffix(super)
|
27
|
+
end
|
28
|
+
|
29
|
+
def remove_possible_suffix(name)
|
30
|
+
name.sub(/_?decorator$/i, '')
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
data/lib/lite/decorator.rb
CHANGED
data/lite-decorator.gemspec
CHANGED
@@ -41,6 +41,7 @@ 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'
|
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.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juan Gomez
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-09-
|
11
|
+
date: 2019-09-03 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
|
@@ -172,6 +186,12 @@ files:
|
|
172
186
|
- _config.yml
|
173
187
|
- bin/console
|
174
188
|
- bin/setup
|
189
|
+
- lib/generators/lite/decorator/install_generator.rb
|
190
|
+
- lib/generators/lite/decorator/templates/install.rb
|
191
|
+
- lib/generators/rails/USAGE
|
192
|
+
- lib/generators/rails/decorator_generator.rb
|
193
|
+
- lib/generators/rails/templates/decorator.rb.tt
|
194
|
+
- lib/generators/rails/templates/spec.rb.tt
|
175
195
|
- lib/lite/decorator.rb
|
176
196
|
- lib/lite/decorator/base.rb
|
177
197
|
- lib/lite/decorator/version.rb
|