ruboclean 0.5.0 → 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/Gemfile.lock +1 -1
- data/README.md +2 -1
- data/lib/ruboclean/cli_arguments.rb +4 -0
- data/lib/ruboclean/logger.rb +19 -0
- data/lib/ruboclean/runner.rb +12 -1
- data/lib/ruboclean/version.rb +1 -1
- data/lib/ruboclean.rb +21 -3
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eed645db36081518d593efb17c64f3c1566a978548a699d10aecf64893ad0f48
|
4
|
+
data.tar.gz: 62c988143427e15fa10e551cedb5965be6a81dd7afbba5ec40ef303ce6e6183c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31f137822127611a4aa5b54df8e7d9222d96937438367ab73a3bdf588e1a854b36a2ba8ce617125ff955948046214ad63037b4ae8a4b5f571f979793c252b2c0
|
7
|
+
data.tar.gz: c939cd53f18fae460f56d76b6ed1c463b229795ac4518ef246ef12b4dd11135067c329276b5d1a9418aebdcf690c8088a4944ff5b338b314be01246dd0acd26e
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -84,7 +84,7 @@ gem install ruboclean
|
|
84
84
|
## Command synopsis
|
85
85
|
|
86
86
|
```shell
|
87
|
-
ruboclean [path] [--silent] [--preserve-comments] [--preserve-paths]
|
87
|
+
ruboclean [path] [--silent] [--preserve-comments] [--preserve-paths] [--verify]
|
88
88
|
```
|
89
89
|
|
90
90
|
### Parameters
|
@@ -95,6 +95,7 @@ ruboclean [path] [--silent] [--preserve-comments] [--preserve-paths]
|
|
95
95
|
| `--silent` | Suppress any output displayed on the screen when executing the command. |
|
96
96
|
| `--preserve-comments` | Preserves **preceding** comments for each top-level entry in the configuration. Inline comments are **not** preserved. |
|
97
97
|
| `--preserve-paths` | Skips the path cleanup that are applied against `Include:` and `Exclude:` configuration. |
|
98
|
+
| `--verify` | Executes in dry-run mode. Exits with 1 if changes are needed, otherwise 0. |
|
98
99
|
|
99
100
|
### Examples
|
100
101
|
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Ruboclean
|
4
|
+
# Logger for clean management of log levels
|
5
|
+
class Logger
|
6
|
+
def initialize(log_level = :verbose)
|
7
|
+
raise ArgumentError, "Invalid log level" unless %i[verbose none].include?(log_level)
|
8
|
+
|
9
|
+
@log_level = log_level
|
10
|
+
end
|
11
|
+
|
12
|
+
def verbose(message)
|
13
|
+
case @log_level
|
14
|
+
when :verbose
|
15
|
+
print message
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/ruboclean/runner.rb
CHANGED
@@ -17,12 +17,21 @@ module Ruboclean
|
|
17
17
|
.then(&method(:cleanup_paths))
|
18
18
|
.then(&method(:convert_to_yaml))
|
19
19
|
.then(&method(:write_file!))
|
20
|
+
.then(&method(:changed?))
|
21
|
+
end
|
22
|
+
|
23
|
+
def changed?(target_yaml)
|
24
|
+
target_yaml != source_yaml
|
20
25
|
end
|
21
26
|
|
22
27
|
def verbose?
|
23
28
|
cli_arguments.verbose?
|
24
29
|
end
|
25
30
|
|
31
|
+
def verify?
|
32
|
+
cli_arguments.verify?
|
33
|
+
end
|
34
|
+
|
26
35
|
def path
|
27
36
|
cli_arguments.path
|
28
37
|
end
|
@@ -54,7 +63,9 @@ module Ruboclean
|
|
54
63
|
end
|
55
64
|
|
56
65
|
def write_file!(target_yaml)
|
57
|
-
|
66
|
+
target_yaml.tap do |content|
|
67
|
+
source_file_pathname.write(content) unless verify?
|
68
|
+
end
|
58
69
|
end
|
59
70
|
|
60
71
|
def source_file_pathname
|
data/lib/ruboclean/version.rb
CHANGED
data/lib/ruboclean.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require "ruboclean/cli_arguments"
|
4
4
|
require "ruboclean/orderer"
|
5
|
+
require "ruboclean/logger"
|
5
6
|
require "ruboclean/grouper"
|
6
7
|
require "ruboclean/path_cleanup"
|
7
8
|
require "ruboclean/runner"
|
@@ -12,8 +13,25 @@ require "ruboclean/version"
|
|
12
13
|
module Ruboclean
|
13
14
|
def self.run_from_cli!(args)
|
14
15
|
runner = Runner.new(args)
|
15
|
-
|
16
|
-
|
17
|
-
|
16
|
+
logger = Ruboclean::Logger.new(runner.verbose? ? :verbose : :none)
|
17
|
+
|
18
|
+
logger.verbose "Using path '#{runner.path}' ... "
|
19
|
+
changed = runner.run!
|
20
|
+
logger.verbose post_execution_message(changed, runner.verify?)
|
21
|
+
|
22
|
+
exit !changed if runner.verify?
|
23
|
+
exit 0
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.post_execution_message(changed, verify)
|
27
|
+
if changed
|
28
|
+
if verify
|
29
|
+
"needs clean.\n"
|
30
|
+
else
|
31
|
+
"done.\n"
|
32
|
+
end
|
33
|
+
else
|
34
|
+
"already clean.\n"
|
35
|
+
end
|
18
36
|
end
|
19
37
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruboclean
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- lxxxvi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Cleans and orders settings in .rubocop.yml
|
14
14
|
email:
|
@@ -34,6 +34,7 @@ files:
|
|
34
34
|
- lib/ruboclean.rb
|
35
35
|
- lib/ruboclean/cli_arguments.rb
|
36
36
|
- lib/ruboclean/grouper.rb
|
37
|
+
- lib/ruboclean/logger.rb
|
37
38
|
- lib/ruboclean/orderer.rb
|
38
39
|
- lib/ruboclean/path_cleanup.rb
|
39
40
|
- lib/ruboclean/runner.rb
|