pattern_bibz 1.1.1 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0f5369152845fdbc8e19d533e3f1e98f405d3f68be7bdd37b382e2735dbb673b
4
- data.tar.gz: e749aef193207c6b23c631fcc7b4ff953a4721dd5316641de57ff5937f38bf13
3
+ metadata.gz: 5d0944f7564dc72e3c86c84b59ee1f1319728a10a96d1bea4b6adedfb26ed267
4
+ data.tar.gz: fa502ac8f9dd715207403ef4145eb1a64d50857ba318974eb9ba27e481f0a542
5
5
  SHA512:
6
- metadata.gz: e352d8e9227f4a69702fa680b13253057674120b068c648c271623b8854d3cbb21e5c48b5691f2629d6c36d6b70978c1f71457f6fa8ccbb671bb31c656ac1e49
7
- data.tar.gz: 30a166020233dbe7c379445e95ec299dc99292ad84a130c9d5eb75af91b53da84e572ae2837606817f887493e581a3741246470b31630706b517f4a146d0a7df
6
+ metadata.gz: 15c43dec4a2fbe0932e214467c50532ce950a1253bdfd7f07bed8d9b7c8fa6407ef664520715977bc6b726fa0a3e762bae3e46e904df0bc914e510604026ee30
7
+ data.tar.gz: 334d29ef567384adfaf78159767fd5e855e47140e370110b20894d02d98daf98e10933ff2440ee3a6995fdf7baffc2f701cf48543272049b002bc2ccbcc7a473
data/README.md CHANGED
@@ -1,53 +1,98 @@
1
- # PatternBibz
1
+ ![Pattern Bibz logo](https://raw.githubusercontent.com/thooams/pattern_bibz/main/pattern-bibz-logo.gif)
2
+
3
+ # Pattern Bibz
4
+
2
5
  Rails Ruby Pattern Generator.
3
- This gem allows to generate your design pattern through the ralis generator.
6
+ This gem allows to generate your design pattern through the rails generator.
7
+
8
+ [![Gem Version](https://badge.fury.io/rb/pattern_bibz.svg)](https://badge.fury.io/rb/pattern_bibz)
9
+ [![Maintainability](https://api.codeclimate.com/v1/badges/7e8e319e9f7197593733/maintainability)](https://codeclimate.com/github/thooams/pattern_bibz/maintainability)
10
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/7e8e319e9f7197593733/test_coverage)](https://codeclimate.com/github/thooams/pattern_bibz/test_coverage)
11
+ [![security](https://hakiri.io/github/thooams/pattern_bibz/main.svg)](https://hakiri.io/github/thooams/pattern_bibz/main)
12
+ [![Ci](https://github.com/thooams/pattern_bibz/workflows/CI/badge.svg)](https://github.com/thooams/pattern_bibz/actions)
13
+ [![Linter](https://github.com/thooams/pattern_bibz/workflows/Linter/badge.svg)](https://github.com/thooams/pattern_bibz/actions)
14
+ [![Inline docs](http://inch-ci.org/github/thooams/pattern_bibz.svg?branch=master)](http://inch-ci.org/github/thooams/pattern_bibz)
15
+ [![Ruby Style Guide](https://img.shields.io/badge/code_style-rubocop-brightgreen.svg)](https://github.com/rubocop-hq/rubocop)
16
+
4
17
 
5
18
  ## Usage
19
+
6
20
  ```bash
7
21
  rails generate pattern PATTERN_NAME
8
22
  ```
9
23
 
10
24
  ## Example
25
+
11
26
  ```bash
12
27
  rails generate pattern MyCustomDecorator
13
28
  ```
14
29
 
15
- This will create:
30
+ Files generated:
31
+
16
32
  app/decorators/application_decorator.rb
17
33
  app/decorators/my_custom_decorator.rb
18
34
  test/decorators/application_decoratior_test.rb
19
35
  test/decorators/my_custom_decorator_test.rb
20
36
 
21
37
  ## Installation
38
+
22
39
  Add this line to your application's Gemfile:
23
40
 
24
41
  ```ruby
25
- gem 'pattern_bibz'
42
+ gem 'pattern_bibz', group: :development
26
43
  ```
27
44
 
28
45
  And then execute:
46
+
29
47
  ```bash
30
48
  $ bundle
31
49
  ```
32
50
 
33
51
  Or install it yourself as:
52
+
34
53
  ```bash
35
54
  $ gem install pattern_bibz
36
55
  ```
37
56
 
38
57
  ## Utils
39
58
  To extend your Rails model generator:
59
+
40
60
  ```bash
41
- rails g pattern_bibz:extend_model
61
+ $ rails g pattern_bibz:extend_model
42
62
  ```
43
63
 
44
64
  Then you can generate your model:
65
+
45
66
  ```bash
46
- rails g model MyModel title:string ...
67
+ $ rails g model MyModel title:string ...
47
68
  ```
48
69
 
49
- ## Contributing
50
- Contribution directions go here.
70
+ Your generated model will look like this:
71
+
72
+ ```ruby
73
+ # frozen_string_literal: true
74
+
75
+ class MyModel < ApplicationRecord
76
+ # Scopes
77
+
78
+ # Constants
79
+
80
+ # Callbacks
81
+
82
+ # Attr_accessors
83
+
84
+ # Associations
85
+
86
+ # Enums
87
+
88
+ # Validations
89
+
90
+ # Delegations
91
+
92
+ # Methods
93
+ end
94
+ ```
51
95
 
52
96
  ## License
97
+
53
98
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -1,44 +1,54 @@
1
+ require 'value_objects/pattern_value_object'
2
+
1
3
  # Generate template files and tests with a patten name
2
4
  class PatternGenerator < Rails::Generators::NamedBase
3
5
  source_root File.expand_path('templates', __dir__)
4
6
 
5
7
  def create_application_pattern_file
6
- @pattern_name = file_name.split('_').last
7
- application_file_name = "app/#{@pattern_name.pluralize}/application_#{@pattern_name}.rb"
8
+ @pattern_value_object = PatternValueObject.new(file_name)
9
+ application_file_name = "app/#{@pattern_value_object.directory_name}/application_#{@pattern_value_object.pattern_name}.rb"
8
10
 
9
11
  return if File.exist?(application_file_name)
10
12
 
11
13
  create_file application_file_name, <<~FILE
12
- class Application#{@pattern_name.titleize}
14
+ # frozen_string_literal: true
15
+
16
+ class Application#{@pattern_value_object.pattern_klass_name}
13
17
  end
14
18
  FILE
15
19
  end
16
20
 
17
21
  def create_app_pattern_file
18
- create_file "app/#{@pattern_name.pluralize}/#{file_name}.rb", <<~FILE
19
- class #{class_name} < Application#{@pattern_name.titleize}
22
+ create_file "app/#{@pattern_value_object.directory_name}/#{@pattern_value_object.file_name}.rb", <<~FILE
23
+ # frozen_string_literal: true
24
+
25
+ class #{@pattern_value_object.klass_name} < Application#{@pattern_value_object.pattern_klass_name}
20
26
  end
21
27
  FILE
22
28
  end
23
29
 
24
30
  def create_test_application_pattern_file
25
- application_file_name = "test/#{@pattern_name.pluralize}/application_#{@pattern_name}_test.rb"
31
+ application_file_name = "test/#{@pattern_value_object.directory_name}/application_#{@pattern_value_object.pattern_name}_test.rb"
26
32
 
27
33
  return if File.exist?(application_file_name)
28
34
 
29
35
  create_file application_file_name, <<~FILE
36
+ # frozen_string_literal: true
37
+
30
38
  require 'test_helper'
31
39
 
32
- class Application#{@pattern_name.titleize}Test < ActiveSupport::TestCase
40
+ class Application#{@pattern_value_object.pattern_klass_name}Test < ActiveSupport::TestCase
33
41
  end
34
42
  FILE
35
43
  end
36
44
 
37
45
  def create_test_pattern_file
38
- create_file "test/#{@pattern_name.pluralize}/#{file_name}_test.rb", <<~FILE
46
+ create_file "test/#{@pattern_value_object.directory_name}/#{@pattern_value_object.file_name}_test.rb", <<~FILE
47
+ # frozen_string_literal: true
48
+
39
49
  require 'test_helper'
40
50
 
41
- class #{class_name}Test < ActiveSupport::TestCase
51
+ class #{@pattern_value_object.klass_name}Test < ActiveSupport::TestCase
42
52
  end
43
53
  FILE
44
54
  end
@@ -1,4 +1,6 @@
1
1
  <% module_namespacing do -%>
2
+ # frozen_string_literal: true
3
+
2
4
  class <%= class_name %> < <%= parent_class_name.classify %>
3
5
  # Scopes
4
6
 
@@ -1,5 +1,3 @@
1
1
  require "pattern_bibz/railtie"
2
2
 
3
- module PatternBibz
4
- # Your code goes here...
5
- end
3
+ module PatternBibz; end
@@ -1,3 +1,3 @@
1
1
  module PatternBibz
2
- VERSION = '1.1.1'
2
+ VERSION = '1.3.1'
3
3
  end
@@ -0,0 +1,42 @@
1
+ # Fetch values from a pattern name
2
+ class PatternValueObject
3
+ COMPOUND_NAMES = %w[view_object value_object].freeze
4
+
5
+ def initialize(name)
6
+ @name = name
7
+ end
8
+
9
+ def pattern_name
10
+ @pattern_name ||= fetch_pattern_name
11
+ end
12
+
13
+ def pattern_klass_name
14
+ pattern_name.classify.delete(' ')
15
+ end
16
+
17
+ def directory_name
18
+ pattern_name.pluralize
19
+ end
20
+
21
+ def file_name
22
+ @name
23
+ end
24
+
25
+ def klass_name
26
+ @name.classify.delete(' ')
27
+ end
28
+
29
+ private
30
+
31
+ def fetch_pattern_name
32
+ if compound_name?
33
+ COMPOUND_NAMES.find { |a| @name.match?(a) }
34
+ else
35
+ @name.split('_').last
36
+ end
37
+ end
38
+
39
+ def compound_name?
40
+ COMPOUND_NAMES.any? { |w| @name.match?(w) }
41
+ end
42
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pattern_bibz
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas HUMMEL
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-21 00:00:00.000000000 Z
11
+ date: 2021-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -20,7 +20,7 @@ dependencies:
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
22
  version: 6.0.2.2
23
- type: :runtime
23
+ type: :development
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
@@ -72,6 +72,76 @@ dependencies:
72
72
  - - ">="
73
73
  - !ruby/object:Gem::Version
74
74
  version: '0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: rubocop-ast
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ - !ruby/object:Gem::Dependency
90
+ name: rubocop-minitest
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ - !ruby/object:Gem::Dependency
104
+ name: rubocop-performance
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ - !ruby/object:Gem::Dependency
118
+ name: rubocop-rails
119
+ requirement: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ type: :development
125
+ prerelease: false
126
+ version_requirements: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ - !ruby/object:Gem::Dependency
132
+ name: simplecov
133
+ requirement: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ type: :development
139
+ prerelease: false
140
+ version_requirements: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - ">="
143
+ - !ruby/object:Gem::Version
144
+ version: '0'
75
145
  description: 'Generate your pattern files through this generator: Eq. rails g pattern
76
146
  MyCustomDecorator'
77
147
  email:
@@ -91,12 +161,13 @@ files:
91
161
  - lib/pattern_bibz/railtie.rb
92
162
  - lib/pattern_bibz/version.rb
93
163
  - lib/tasks/pattern_bibz_tasks.rake
164
+ - lib/value_objects/pattern_value_object.rb
94
165
  homepage: http://thooams.github.io/pattern_bibz
95
166
  licenses:
96
167
  - MIT
97
168
  metadata:
98
169
  allowed_push_host: https://rubygems.org
99
- post_install_message:
170
+ post_install_message:
100
171
  rdoc_options: []
101
172
  require_paths:
102
173
  - lib
@@ -104,15 +175,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
104
175
  requirements:
105
176
  - - ">="
106
177
  - !ruby/object:Gem::Version
107
- version: '0'
178
+ version: 3.0.0
108
179
  required_rubygems_version: !ruby/object:Gem::Requirement
109
180
  requirements:
110
181
  - - ">="
111
182
  - !ruby/object:Gem::Version
112
183
  version: '0'
113
184
  requirements: []
114
- rubygems_version: 3.1.2
115
- signing_key:
185
+ rubygems_version: 3.2.3
186
+ signing_key:
116
187
  specification_version: 4
117
188
  summary: Rails Pattern generator
118
189
  test_files: []