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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6d3c025083ce298a82c386461c7e2b8b48606916aa38e421391a014ef16ec3ba
4
- data.tar.gz: a319dbe20b7b3cd9f3af475f96afa20cf33cb02323cfe47e26cd1c16d2bbb665
3
+ metadata.gz: b217a968ad5aa2bfc976383a9458990fbfad83387e0f533a4f34b7666ce895a7
4
+ data.tar.gz: 8071528b21c91446bdd136b49c9aca06cc93594af049ac7e5ece08a36dcd6990
5
5
  SHA512:
6
- metadata.gz: c758c5b34a92815bab10680c367b77aae5086bff0e24ec771c47e2380e0db942021512f1f3adbd50693d07792cb9341df77d4c004f3c254eff36367b4e30b1ca
7
- data.tar.gz: a88fb13faf0304434515cab3447434845008381bd1e64c8caa5fee3ec10c9b2fd1a1bb0513f21bc779e3bc819a08a79ce48dfc0ad6a9c46deae98afdc238c309
6
+ metadata.gz: a9e7f484acae99a89351772d7e5e8d820bb9ecdbee1b0811a0f76ff49f6dff9797d8706b936e0fb8607ab0c83735c81e93ab8f6bd5346f4c5ece47e14123df73
7
+ data.tar.gz: 9526e30deed656eb2deb927d78b6d5762cd00aa1ce308e6ea556d7e12ee64a1a33e609e9bd36980d0460ef887e87661d1352324cfa0a820d9b424e6ecd2618d8
data/.rubocop.yml CHANGED
@@ -18,6 +18,8 @@ Metrics/BlockLength:
18
18
  Exclude:
19
19
  - 'spec/**/**/*'
20
20
  - '*.gemspec'
21
+ Naming/MemoizedInstanceVariableName:
22
+ Enabled: false
21
23
  RSpec/ExampleLength:
22
24
  Enabled: false
23
25
  RSpec/MultipleExpectations:
data/CHANGELOG.md CHANGED
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [1.0.1] - 2019-09-02
10
+ ### Added
11
+ - Add rails generators
12
+
9
13
  ## [1.0.0] - 2019-09-01
10
14
  ### Added
11
15
  - Initial project version
data/Gemfile.lock CHANGED
@@ -1,11 +1,24 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lite-decorator (1.0.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
- Using the decorator class is as simple as creating a class that inherits from the base file.
32
+ `rails g lite:decorator:install` will generate the following file:
33
+ `../app/decorators/application_decorator.rb`
33
34
 
34
35
  ```ruby
35
- class UserDecorator < Lite::Decorator::Base
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,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ class ApplicationDecorator < Lite::Decorator::Base
4
+ end
@@ -0,0 +1,9 @@
1
+ Description:
2
+ Generate a decorator file
3
+
4
+ Example:
5
+ rails generate decorator NAME
6
+
7
+ This will create:
8
+ - app/decorators/[name]_decorator.rb
9
+ - spec/decorators/[name]_decorator_spec.rb
@@ -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
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ <% module_namespacing do -%>
4
+ class <%= class_name %>Decorator < ApplicationDecorator
5
+ end
6
+ <% end -%>
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rails_helper'
4
+
5
+ RSpec.describe <%= class_name %>Decorator, type: :decorator do
6
+ pending "add some examples to (or delete) #{__FILE__}"
7
+ end
@@ -3,7 +3,7 @@
3
3
  module Lite
4
4
  module Decorator
5
5
 
6
- VERSION ||= '1.0.0'
6
+ VERSION ||= '1.0.1'
7
7
 
8
8
  end
9
9
  end
@@ -3,3 +3,6 @@
3
3
  %w[version base].each do |name|
4
4
  require "lite/decorator/#{name}"
5
5
  end
6
+
7
+ require 'generators/lite/decorator/install_generator'
8
+ require 'generators/rails/decorator_generator'
@@ -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.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-01 00:00:00.000000000 Z
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