autoload-checker 0.1.0 → 0.1.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 +4 -4
- data/.github/workflows/ruby.yml +28 -0
- data/.gitignore +1 -0
- data/Gemfile.lock +1 -0
- data/README.md +3 -3
- data/autoload-checker.gemspec +24 -0
- data/bin/autoload_checker.rb +5 -5
- data/lib/autoload_checker.rb +3 -3
- data/lib/namespace/validator.rb +3 -3
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 36c041f55a40686ad53d4743b9f437c3ea295410e1b769c0805865e9f64d9154
|
4
|
+
data.tar.gz: 8c0fe9f5d1fdc3ee9beb1a7b9ebbfaf0f2ea3f5924a4e20ca4e398adea5263d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b03379660dd50055861f91fa5d8577c8ca6260682381fe297d08ea74e05224af32cdc9bf35c16c6632a614a490abc2a6021e81da9c6c8c4a7b8cf4e13c029d7c
|
7
|
+
data.tar.gz: 5a8ec87de2d329ced60e14b34756ba2a7f0edae915dae5f712846ea93b09445b30e59252b9e4afcc0455eed2bb7760ad5f6e2a1aff7c5853a665bfb0503a31db
|
@@ -0,0 +1,28 @@
|
|
1
|
+
name: Ruby
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ "master" ]
|
6
|
+
pull_request:
|
7
|
+
branches: [ "master" ]
|
8
|
+
|
9
|
+
permissions:
|
10
|
+
contents: read
|
11
|
+
|
12
|
+
jobs:
|
13
|
+
test:
|
14
|
+
|
15
|
+
runs-on: ubuntu-latest
|
16
|
+
strategy:
|
17
|
+
matrix:
|
18
|
+
ruby-version: ['2.5.8']
|
19
|
+
|
20
|
+
steps:
|
21
|
+
- uses: actions/checkout@v3
|
22
|
+
- name: Set up Ruby
|
23
|
+
uses: ruby/setup-ruby@2b019609e2b0f1ea1a2bc8ca11cb82ab46ada124
|
24
|
+
with:
|
25
|
+
ruby-version: ${{ matrix.ruby-version }}
|
26
|
+
bundler-cache: true
|
27
|
+
- name: Run tests
|
28
|
+
run: bundle exec rspec
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
*.gem
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# autoload-checker
|
2
2
|
|
3
3
|
Checks for conflicts in class/module definitions and corrects them. For instance, you have
|
4
4
|
a file `foo/bar/baz.rb` with following content:
|
@@ -28,8 +28,8 @@ in `foo/bar/baz.rb`.
|
|
28
28
|
# Usage
|
29
29
|
|
30
30
|
```
|
31
|
-
Usage: ./autoload_checker.rb [options]
|
32
|
-
-p, --path
|
31
|
+
Usage: ./bin/autoload_checker.rb [options]
|
32
|
+
-p, --path DIR,... [Mandatory] directories to check
|
33
33
|
-c, --correct Enable errors correction
|
34
34
|
-h, --help Prints this help
|
35
35
|
```
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = "autoload-checker"
|
5
|
+
spec.version = '0.1.1'
|
6
|
+
spec.authors = %w[cyberfined]
|
7
|
+
spec.email = %w[cyberfined@protonmail.com]
|
8
|
+
|
9
|
+
spec.summary = "Checks for conflicts in class/module definitions and corrects them."
|
10
|
+
spec.description = "Checks for conflicts in class/module definitions and corrects them."
|
11
|
+
spec.homepage = "https://github.com/cyberfined/autoload-checker"
|
12
|
+
spec.license = "WTFPL"
|
13
|
+
|
14
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
15
|
+
f.match %r{^(spec)/}
|
16
|
+
end
|
17
|
+
|
18
|
+
spec.bindir = "bin"
|
19
|
+
spec.executables = %w[autoload_checker.rb]
|
20
|
+
|
21
|
+
spec.required_ruby_version = ">= 2.5"
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
24
|
+
end
|
data/bin/autoload_checker.rb
CHANGED
@@ -7,13 +7,13 @@ require 'optparse'
|
|
7
7
|
require 'namespace'
|
8
8
|
require 'autoload_checker'
|
9
9
|
|
10
|
-
Options = Struct.new(:
|
10
|
+
Options = Struct.new(:root_dirs, :correct)
|
11
11
|
|
12
12
|
options = Options.new(nil, false)
|
13
13
|
opt_parser = OptionParser.new do |opts|
|
14
14
|
opts.banner = "Usage: #{$0} [options]"
|
15
|
-
|
16
|
-
options.
|
15
|
+
opts.on('-p DIR,...', '--path', Array, '[Mandatory] directories to check') do |v|
|
16
|
+
options.root_dirs = v
|
17
17
|
end
|
18
18
|
opts.on('-c', '--correct', TrueClass, 'Enable errors correction') { |v| options.correct = v }
|
19
19
|
opts.on('-h', '--help', 'Prints this help') do
|
@@ -23,11 +23,11 @@ opt_parser = OptionParser.new do |opts|
|
|
23
23
|
end
|
24
24
|
opt_parser.parse!
|
25
25
|
|
26
|
-
unless options.
|
26
|
+
unless options.root_dirs
|
27
27
|
puts opt_parser.help
|
28
28
|
exit(1)
|
29
29
|
end
|
30
30
|
|
31
|
-
autoload_checker = AutoloadChecker.new(
|
31
|
+
autoload_checker = AutoloadChecker.new(root_dirs: options.root_dirs, correct: options.correct)
|
32
32
|
autoload_checker.call
|
33
33
|
exit(1) if autoload_checker.fixes.any? && !options.correct
|
data/lib/autoload_checker.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class AutoloadChecker
|
4
|
-
def initialize(
|
5
|
-
@
|
4
|
+
def initialize(root_dirs:, correct:, output: $stderr)
|
5
|
+
@root_dirs = root_dirs
|
6
6
|
@correct = correct
|
7
7
|
@output = output
|
8
8
|
end
|
@@ -27,7 +27,7 @@ class AutoloadChecker
|
|
27
27
|
private
|
28
28
|
|
29
29
|
def validator
|
30
|
-
@validator ||= Namespace::Validator.new(@
|
30
|
+
@validator ||= Namespace::Validator.new(@root_dirs)
|
31
31
|
end
|
32
32
|
|
33
33
|
def correct?
|
data/lib/namespace/validator.rb
CHANGED
@@ -8,14 +8,14 @@ class Namespace
|
|
8
8
|
class Validator
|
9
9
|
attr_reader :fixes, :namespaces
|
10
10
|
|
11
|
-
def initialize(
|
12
|
-
@
|
11
|
+
def initialize(root_dirs)
|
12
|
+
@root_dirs = root_dirs
|
13
13
|
@namespaces = {}
|
14
14
|
@fixes = Hash.new { |hsh, k| hsh[k] = [] }
|
15
15
|
end
|
16
16
|
|
17
17
|
def call
|
18
|
-
directories =
|
18
|
+
directories = @root_dirs
|
19
19
|
new_directories = []
|
20
20
|
|
21
21
|
while directories.any?
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: autoload-checker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- cyberfined
|
@@ -32,10 +32,13 @@ executables:
|
|
32
32
|
extensions: []
|
33
33
|
extra_rdoc_files: []
|
34
34
|
files:
|
35
|
+
- ".github/workflows/ruby.yml"
|
36
|
+
- ".gitignore"
|
35
37
|
- Gemfile
|
36
38
|
- Gemfile.lock
|
37
39
|
- LICENSE
|
38
40
|
- README.md
|
41
|
+
- autoload-checker.gemspec
|
39
42
|
- bin/autoload_checker.rb
|
40
43
|
- lib/autoload_checker.rb
|
41
44
|
- lib/namespace.rb
|