gemwork 0.5.2 → 0.6.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 +8 -0
- data/README.md +91 -7
- data/lib/.DS_Store +0 -0
- data/lib/gemwork/.DS_Store +0 -0
- data/lib/gemwork/test/support/much_stub.rb +2 -2
- data/lib/gemwork/version.rb +1 -1
- data/lib/reek/.reek-rails.yml +51 -0
- data/lib/rubocop/.rubocop-rails.yml +4 -1
- data/lib/rubocop/all_cops-rails.yml +17 -0
- data/lib/rubocop/layout-rails.yml +4 -0
- data/lib/rubocop/metrics-rails.yml +14 -0
- data/lib/rubocop/rails.yml +9 -0
- data/lib/rubocop/style-rails.yml +14 -0
- data/lib/rubocop/style.yml +10 -0
- data/lib/tasks/eslint.rake +13 -0
- data/lib/tasks/prettier.rake +6 -0
- metadata +12 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c91820eba811f86523e00689d992d8c1cc0e350590a523c2aa81e428b48ce71c
|
4
|
+
data.tar.gz: 9dc933263f0566026a1d619fa27e81fb63bd3226f16b497ac9b02af0f96bc420
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5de44ccbd9ac0866f7e23d2b41113fbc64c8408004b83eb502ab98a05472d416dc3bdd111f5bb326be3a8fd03be8a70c1503a880c9e37e2fe6fdfbb1f0cc3f0a
|
7
|
+
data.tar.gz: 30f7ae391a501f736752981febc7b20af556dbee1f99f89103bacf173d130f0c8278ad2b8f8615bc770944bbf5d6d1baa703c0765f0546f14dff1c924f2abd23
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [0.6.0] - 2024-10-9
|
4
|
+
|
5
|
+
- Update RuboCop Styles, especially for Rails projects
|
6
|
+
- Add Rake tasks for: `eslint` and `prettier`
|
7
|
+
|
8
|
+
## [0.5.3] - 2024-9-1
|
9
|
+
|
10
|
+
- Fix `MuchStub.unstub!` to actually run after ActiveSupport::TestCase test cases
|
3
11
|
|
4
12
|
## [0.5.2] - 2024-8-22
|
5
13
|
|
data/README.md
CHANGED
@@ -58,7 +58,7 @@ Running `rake -T` after this will reveal the additional tasks defined by Gemwork
|
|
58
58
|
|
59
59
|
### Rails
|
60
60
|
|
61
|
-
For a Rails project, you may need to conditionally run the above by returning early unless the current environment is development. Further, you may want to include other tasks, such as `test:system`.
|
61
|
+
For a Rails project, you may need to conditionally run the above by returning early unless the current environment is development. Further, you may want to include other tasks, such as `eslint`, `prettier`, and `test:system`.
|
62
62
|
|
63
63
|
```ruby
|
64
64
|
# frozen_string_literal: true
|
@@ -70,7 +70,7 @@ spec = Gem::Specification.find_by_name("gemwork")
|
|
70
70
|
# Load additional tasks defined by Gemwork.
|
71
71
|
Dir.glob(
|
72
72
|
Pathname.new(spec.gem_dir).
|
73
|
-
join("lib", "tasks", "{util,rubocop,reek}.rake")) do |task|
|
73
|
+
join("lib", "tasks", "{util,rubocop,reek,eslint,prettier}.rake")) do |task|
|
74
74
|
load(task)
|
75
75
|
end
|
76
76
|
|
@@ -81,12 +81,15 @@ task :default do
|
|
81
81
|
test
|
82
82
|
rubocop
|
83
83
|
reek
|
84
|
+
eslint
|
85
|
+
prettier
|
84
86
|
test:system
|
85
87
|
])
|
86
88
|
end
|
87
89
|
```
|
88
90
|
|
89
|
-
##
|
91
|
+
## RuboCop Integration
|
92
|
+
|
90
93
|
### Simple Usage
|
91
94
|
|
92
95
|
Add the following to the `.rubocop.yml` file in your gem:
|
@@ -120,7 +123,7 @@ The above (simple usage) will automatically includes all RuboCop configuration s
|
|
120
123
|
```yaml
|
121
124
|
# .rubocop.yml
|
122
125
|
|
123
|
-
# Load
|
126
|
+
# Load RuboCop plugins.
|
124
127
|
require:
|
125
128
|
- rubocop-rake
|
126
129
|
- rubocop-minitest
|
@@ -151,7 +154,7 @@ See also: [RuboCop's Configuration Guide on Inheritance](https://github.com/rubo
|
|
151
154
|
```yaml
|
152
155
|
# .rubocop.yml
|
153
156
|
|
154
|
-
# Load
|
157
|
+
# Load RuboCop plugins.
|
155
158
|
require:
|
156
159
|
- rubocop-capybara
|
157
160
|
- rubocop-minitest
|
@@ -179,11 +182,14 @@ AllCops:
|
|
179
182
|
- bin/bundle
|
180
183
|
```
|
181
184
|
|
185
|
+
## Reek
|
186
|
+
|
187
|
+
The reek gem doesn't support config files integration. But recommended starting configs have been placed in [lib/reek/](https://github.com/pdobb/gemwork/blob/master/lib/reek). One for gems and one for Rails projects.
|
188
|
+
|
182
189
|
## Testing Support
|
183
190
|
|
184
191
|
The following requires may be added to `./test/test_helper.rb` to simplify test configuration. These requires support the gem dependencies mentioned in the following section.
|
185
192
|
|
186
|
-
|
187
193
|
```ruby
|
188
194
|
# frozen_string_literal: true
|
189
195
|
|
@@ -201,24 +207,82 @@ require "gemwork/test/support/spec_dsl"
|
|
201
207
|
# ...
|
202
208
|
```
|
203
209
|
|
210
|
+
## Other Setup
|
211
|
+
|
212
|
+
### Rails
|
213
|
+
|
214
|
+
For a Rails app, additional configuration may be desired to improve linter support.
|
215
|
+
|
216
|
+
#### eslint
|
217
|
+
|
218
|
+
The below fixes eslint linting errors in Rails (7+, ...) projects.
|
219
|
+
|
220
|
+
```json
|
221
|
+
// .eslintrc.json
|
222
|
+
|
223
|
+
{
|
224
|
+
"env": {
|
225
|
+
"browser": true,
|
226
|
+
"es2021": true
|
227
|
+
},
|
228
|
+
"extends": ["eslint:recommended", "plugin:prettier/recommended"],
|
229
|
+
"parserOptions": {
|
230
|
+
"ecmaVersion": "latest",
|
231
|
+
"sourceType": "module"
|
232
|
+
},
|
233
|
+
"overrides": [
|
234
|
+
{
|
235
|
+
"files": ["config/tailwind.config.js"],
|
236
|
+
"env": {
|
237
|
+
"node": true
|
238
|
+
},
|
239
|
+
"rules": {
|
240
|
+
"no-unused-vars": ["error", { "varsIgnorePattern": "defaultTheme" }]
|
241
|
+
}
|
242
|
+
}
|
243
|
+
]
|
244
|
+
}
|
245
|
+
```
|
246
|
+
|
247
|
+
#### prettier
|
248
|
+
|
249
|
+
General config recommendations for prettier:
|
250
|
+
|
251
|
+
```
|
252
|
+
# .prettierignore
|
253
|
+
|
254
|
+
vendor
|
255
|
+
```
|
256
|
+
|
257
|
+
```json
|
258
|
+
// .prettierrc.json
|
259
|
+
|
260
|
+
{
|
261
|
+
"semi": false
|
262
|
+
}
|
263
|
+
```
|
264
|
+
|
204
265
|
## Gem Dependencies
|
205
266
|
|
206
267
|
Gemwork depends on the following gems. None of these are actually used by Gemwork, itself, but are included for use by child gems. This is meant to ease dependency management for child gems as these things evolve over time.
|
207
268
|
|
208
269
|
#### Unit Testing
|
270
|
+
|
209
271
|
- [minitest](https://github.com/minitest/minitest)
|
210
272
|
- [minitest-reporters](https://github.com/minitest-reporters/minitest-reporters) -- Create customizable MiniTest output formats.
|
211
273
|
- [much-stub](https://github.com/redding/much-stub) -- Stubbing API for replacing method calls on objects in test runs.
|
212
274
|
- [simplecov](https://github.com/simplecov-ruby/simplecov) -- Code coverage for Ruby.
|
213
275
|
|
214
276
|
#### Linters
|
277
|
+
|
215
278
|
- [reek](https://github.com/troessner/reek) -- Code smell detector for Ruby.
|
216
|
-
- [rubocop](https://github.com/rubocop/rubocop)
|
279
|
+
- [rubocop](https://github.com/rubocop/rubocop) -- A Ruby static code analyzer and formatter, based on the community Ruby style guide.
|
217
280
|
- [rubocop-minitest](https://github.com/rubocop/rubocop-minitest) -- Code style checking for Minitest files.
|
218
281
|
- [rubocop-performance](https://github.com/rubocop/rubocop-performance/) -- An extension of RuboCop focused on code performance checks.
|
219
282
|
- [rubocop-rake](https://github.com/rubocop/rubocop-rake) -- A RuboCop plugin for Rake.
|
220
283
|
|
221
284
|
#### Documentation
|
285
|
+
|
222
286
|
- [yard](https://github.com/lsegal/yard) -- YARD is a Ruby Documentation tool. The Y stands for "Yay!".
|
223
287
|
|
224
288
|
### Rails
|
@@ -226,6 +290,7 @@ Gemwork depends on the following gems. None of these are actually used by Gemwor
|
|
226
290
|
For Rails projects, you may want to manually install additional gems as well:
|
227
291
|
|
228
292
|
#### Linters
|
293
|
+
|
229
294
|
- [rubocop-rails](https://github.com/rubocop/rubocop-rails) -- A RuboCop extension focused on enforcing Rails best practices and coding conventions.
|
230
295
|
- [rubocop-capybara](https://github.com/rubocop/rubocop-capybara) -- Code style checking for Capybara files.
|
231
296
|
|
@@ -260,6 +325,25 @@ With the above, you can opt in to using a locally built and installed Gemwork ge
|
|
260
325
|
REBUILD_GEMWORK=1 bin/setup
|
261
326
|
```
|
262
327
|
|
328
|
+
### Testing
|
329
|
+
|
330
|
+
To test this gem (gemwork):
|
331
|
+
|
332
|
+
```bash
|
333
|
+
rake
|
334
|
+
```
|
335
|
+
|
336
|
+
#### Linters
|
337
|
+
|
338
|
+
```bash
|
339
|
+
rubocop
|
340
|
+
|
341
|
+
reek
|
342
|
+
|
343
|
+
npx prettier . --check
|
344
|
+
npx prettier . --write
|
345
|
+
```
|
346
|
+
|
263
347
|
### Releases
|
264
348
|
|
265
349
|
To release a new version of Gemwork to RubyGems:
|
data/lib/.DS_Store
ADDED
Binary file
|
Binary file
|
data/lib/gemwork/version.rb
CHANGED
@@ -0,0 +1,51 @@
|
|
1
|
+
detectors:
|
2
|
+
DuplicateMethodCall:
|
3
|
+
allow_calls:
|
4
|
+
- self.class
|
5
|
+
UncommunicativeVariableName:
|
6
|
+
accept:
|
7
|
+
- _
|
8
|
+
UnusedPrivateMethod:
|
9
|
+
enabled: false # Disabled by default.
|
10
|
+
UtilityFunction:
|
11
|
+
public_methods_only: true # Disabled by default.
|
12
|
+
|
13
|
+
directories:
|
14
|
+
app/channels/application_cable:
|
15
|
+
IrresponsibleModule:
|
16
|
+
enabled: false
|
17
|
+
app/controllers:
|
18
|
+
IrresponsibleModule:
|
19
|
+
enabled: false
|
20
|
+
app/helpers:
|
21
|
+
IrresponsibleModule:
|
22
|
+
enabled: false
|
23
|
+
UtilityFunction:
|
24
|
+
enabled: false
|
25
|
+
LongParameterList:
|
26
|
+
enabled: false
|
27
|
+
app/jobs:
|
28
|
+
IrresponsibleModule:
|
29
|
+
enabled: false
|
30
|
+
UtilityFunction:
|
31
|
+
enabled: false
|
32
|
+
app/mailers:
|
33
|
+
IrresponsibleModule:
|
34
|
+
enabled: false
|
35
|
+
app/views: # If using View Models.
|
36
|
+
IrresponsibleModule:
|
37
|
+
enabled: false
|
38
|
+
TooManyMethods:
|
39
|
+
enabled: false
|
40
|
+
UtilityFunction:
|
41
|
+
enabled: false
|
42
|
+
test:
|
43
|
+
IrresponsibleModule:
|
44
|
+
enabled: false
|
45
|
+
UtilityFunction:
|
46
|
+
enabled: false
|
47
|
+
|
48
|
+
exclude_paths:
|
49
|
+
- db/migrate/*
|
50
|
+
- test/**/*
|
51
|
+
- lib/templates/**/*
|
@@ -1,10 +1,13 @@
|
|
1
1
|
inherit_from:
|
2
|
-
- ./all_cops.yml
|
2
|
+
- ./all_cops-rails.yml
|
3
3
|
- ./layout.yml
|
4
|
+
- ./layout-rails.yml
|
4
5
|
- ./lint.yml
|
5
6
|
- ./metrics.yml
|
7
|
+
- ./metrics-rails.yml
|
6
8
|
- ./minitest.yml
|
7
9
|
- ./naming.yml
|
8
10
|
- ./performance.yml
|
9
11
|
- ./rails.yml
|
10
12
|
- ./style.yml
|
13
|
+
- ./style-rails.yml
|
@@ -0,0 +1,17 @@
|
|
1
|
+
AllCops:
|
2
|
+
DisplayCopNames: true
|
3
|
+
DisplayStyleGuide: true
|
4
|
+
ExtraDetails: true
|
5
|
+
NewCops: enable
|
6
|
+
TargetRubyVersion: 3.3
|
7
|
+
UseCache: true
|
8
|
+
Exclude:
|
9
|
+
# Rubocop Defaults
|
10
|
+
- "node_modules/**/*"
|
11
|
+
- "tmp/**/*"
|
12
|
+
- "vendor/**/*"
|
13
|
+
- ".git/**/*"
|
14
|
+
# Custom additions
|
15
|
+
- bin/bundle
|
16
|
+
- db/schema.rb
|
17
|
+
- lib/templates/**/*
|
data/lib/rubocop/rails.yml
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# While bulk changes can be useful, they shouldn't be required. Too much work
|
2
2
|
# for little benefit.
|
3
|
+
Rails/ActionOrder:
|
4
|
+
ExpectedOrder: [index, show, new, create, edit, update, destroy]
|
5
|
+
|
3
6
|
Rails/BulkChangeTable:
|
4
7
|
Enabled: false
|
5
8
|
|
@@ -18,6 +21,10 @@ Rails/HasManyOrHasOneDependent:
|
|
18
21
|
Rails/OrderById:
|
19
22
|
Enabled: true
|
20
23
|
|
24
|
+
Rails/Output:
|
25
|
+
Exclude:
|
26
|
+
- db/seeds.rb
|
27
|
+
|
21
28
|
Rails/PluckId:
|
22
29
|
Enabled: true
|
23
30
|
|
@@ -44,3 +51,5 @@ Rails/UniqBeforePluck:
|
|
44
51
|
|
45
52
|
Rails/WhereExists:
|
46
53
|
EnforcedStyle: where
|
54
|
+
Exclude:
|
55
|
+
- test/**/*
|
data/lib/rubocop/style.yml
CHANGED
@@ -81,6 +81,13 @@ Style/ExpandPathArguments:
|
|
81
81
|
Style/FormatString:
|
82
82
|
Enabled: false # % notation with an Array just reads better sometimes.
|
83
83
|
|
84
|
+
Style/GuardClause:
|
85
|
+
AllowConsecutiveConditionals: true
|
86
|
+
|
87
|
+
Style/HashAsLastArrayItem:
|
88
|
+
Exclude:
|
89
|
+
- test/**/*
|
90
|
+
|
84
91
|
Style/ImplicitRuntimeError:
|
85
92
|
Enabled: false
|
86
93
|
|
@@ -155,6 +162,9 @@ Style/StringLiterals:
|
|
155
162
|
Style/StringLiteralsInInterpolation:
|
156
163
|
EnforcedStyle: double_quotes
|
157
164
|
|
165
|
+
Style/SymbolProc:
|
166
|
+
AllowMethodsWithArguments: true
|
167
|
+
|
158
168
|
Style/TopLevelMethodDefinition:
|
159
169
|
Enabled: false
|
160
170
|
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
desc "Run eslint on app/javascript/**/*.js"
|
4
|
+
task :eslint do
|
5
|
+
command = "npx eslint app/javascript/**/*.js"
|
6
|
+
success = system(command)
|
7
|
+
|
8
|
+
if success
|
9
|
+
puts "\e[32m0 errors, 0 warnings\e[0m"
|
10
|
+
else
|
11
|
+
exit 1
|
12
|
+
end
|
13
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gemwork
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul DobbinSchmaltz
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-10-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -202,26 +202,35 @@ files:
|
|
202
202
|
- CHANGELOG.md
|
203
203
|
- LICENSE.txt
|
204
204
|
- README.md
|
205
|
+
- lib/.DS_Store
|
205
206
|
- lib/gemwork.rb
|
207
|
+
- lib/gemwork/.DS_Store
|
206
208
|
- lib/gemwork/test/support/much_stub.rb
|
207
209
|
- lib/gemwork/test/support/reporters.rb
|
208
210
|
- lib/gemwork/test/support/simplecov.rb
|
209
211
|
- lib/gemwork/test/support/spec_dsl.rb
|
210
212
|
- lib/gemwork/version.rb
|
213
|
+
- lib/reek/.reek-rails.yml
|
211
214
|
- lib/reek/.reek.yml
|
212
215
|
- lib/rubocop/.rubocop-gems.yml
|
213
216
|
- lib/rubocop/.rubocop-rails.yml
|
214
217
|
- lib/rubocop/.rubocop.yml
|
218
|
+
- lib/rubocop/all_cops-rails.yml
|
215
219
|
- lib/rubocop/all_cops.yml
|
216
220
|
- lib/rubocop/gemspec.yml
|
221
|
+
- lib/rubocop/layout-rails.yml
|
217
222
|
- lib/rubocop/layout.yml
|
218
223
|
- lib/rubocop/lint.yml
|
224
|
+
- lib/rubocop/metrics-rails.yml
|
219
225
|
- lib/rubocop/metrics.yml
|
220
226
|
- lib/rubocop/minitest.yml
|
221
227
|
- lib/rubocop/naming.yml
|
222
228
|
- lib/rubocop/performance.yml
|
223
229
|
- lib/rubocop/rails.yml
|
230
|
+
- lib/rubocop/style-rails.yml
|
224
231
|
- lib/rubocop/style.yml
|
232
|
+
- lib/tasks/eslint.rake
|
233
|
+
- lib/tasks/prettier.rake
|
225
234
|
- lib/tasks/reek.rake
|
226
235
|
- lib/tasks/rubocop.rake
|
227
236
|
- lib/tasks/test.rake
|
@@ -251,7 +260,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
251
260
|
- !ruby/object:Gem::Version
|
252
261
|
version: '0'
|
253
262
|
requirements: []
|
254
|
-
rubygems_version: 3.5.
|
263
|
+
rubygems_version: 3.5.18
|
255
264
|
signing_key:
|
256
265
|
specification_version: 4
|
257
266
|
summary: Common gem framework code used by pdobb's Ruby Gems.
|