stellwerk 0.0.4 → 0.0.5
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/AGENTS.md +4 -0
- data/CHANGELOG.md +5 -0
- data/lib/stellwerk/commands/check.rb +2 -7
- data/lib/stellwerk/source_file_collector.rb +35 -0
- data/lib/stellwerk/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b38b3bea5bc5d86cc9e334ee31ffde3ff179d97df718c6ebf93acfe558e35cf3
|
|
4
|
+
data.tar.gz: b1ed9aabfff4f362efb53fda1199d4a8c9d83d9a9e831db54df991621e2bf84b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 41b9dbf5fbcb2211f1e2d0f38e11e6b54ac4df7bb35e9727a15021627a07cbc8ec0e3820027daca0d907909a8a6fdf52590ec0e0673e0ab00df311aec4513d9a
|
|
7
|
+
data.tar.gz: a4c4dcf3f10cb2d32bf34d6683939ce4e5e51636e705d5f5f7ac09e7043529ca93639379f230dc2c3355652b43e955f3bd776a794bc0f68d56fce7954f69cd7c
|
data/AGENTS.md
CHANGED
|
@@ -7,3 +7,7 @@ We're in pre-alpha. Don't overengineer, don't overdocument, don't put too much e
|
|
|
7
7
|
## Usage Expectations
|
|
8
8
|
|
|
9
9
|
This gem can only be used with Rails applications for now. In theory we can support any Ruby codebase using zeitwerk, but that's not a priority at this point.
|
|
10
|
+
|
|
11
|
+
## Testing
|
|
12
|
+
|
|
13
|
+
Never test private methods. If it seems that we should test a private method, the method should probably be public on a different class.
|
data/CHANGELOG.md
CHANGED
|
@@ -5,12 +5,11 @@ require "parallel"
|
|
|
5
5
|
|
|
6
6
|
require "stellwerk/config"
|
|
7
7
|
require "stellwerk/printer"
|
|
8
|
+
require "stellwerk/source_file_collector"
|
|
8
9
|
|
|
9
10
|
module Stellwerk
|
|
10
11
|
module Commands
|
|
11
12
|
class Check
|
|
12
|
-
EXCLUDED_PATHS = ["db/", "vendor/"]
|
|
13
|
-
|
|
14
13
|
def initialize(root_path, autoloaders: nil)
|
|
15
14
|
@root_path = Pathname.new(root_path)
|
|
16
15
|
@autoloaders = autoloaders || fake_autoloaders
|
|
@@ -26,11 +25,7 @@ module Stellwerk
|
|
|
26
25
|
root_path: @root_path
|
|
27
26
|
)
|
|
28
27
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
all_files = @root_path.find
|
|
32
|
-
.select { |path| path.to_s.end_with?(".rb") }
|
|
33
|
-
.reject { |path| absolute_exclude_paths.any? { |exclude| path.start_with?(exclude) } }
|
|
28
|
+
all_files = Stellwerk::SourceFileCollector.new(@root_path).call
|
|
34
29
|
puts "collected #{all_files.length} files"
|
|
35
30
|
|
|
36
31
|
before = Time.now
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
require "pathname"
|
|
2
|
+
|
|
3
|
+
module Stellwerk
|
|
4
|
+
class SourceFileCollector
|
|
5
|
+
EXCLUDED_PATHS = ["db/", "vendor/"]
|
|
6
|
+
SOURCE_FILE_EXTENSIONS = [".rb", ".erb"]
|
|
7
|
+
|
|
8
|
+
def initialize(root_path, exclude_paths: EXCLUDED_PATHS)
|
|
9
|
+
@root_path = Pathname.new(root_path)
|
|
10
|
+
@exclude_paths = exclude_paths
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def call
|
|
14
|
+
absolute_exclude_paths = @exclude_paths.map do |path|
|
|
15
|
+
@root_path.join(path).to_s.delete_suffix(File::SEPARATOR)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
@root_path.find
|
|
19
|
+
.select { |path| source_file?(path) }
|
|
20
|
+
.reject { |path| excluded_path?(path.to_s, absolute_exclude_paths) }
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
private
|
|
24
|
+
|
|
25
|
+
def source_file?(path)
|
|
26
|
+
SOURCE_FILE_EXTENSIONS.include?(path.extname)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def excluded_path?(path_str, absolute_exclude_paths)
|
|
30
|
+
absolute_exclude_paths.any? do |exclude_path|
|
|
31
|
+
path_str == exclude_path || path_str.start_with?("#{exclude_path}#{File::SEPARATOR}")
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
data/lib/stellwerk/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: stellwerk
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Philip Theus
|
|
@@ -85,6 +85,7 @@ files:
|
|
|
85
85
|
- lib/stellwerk/printer.rb
|
|
86
86
|
- lib/stellwerk/railtie.rb
|
|
87
87
|
- lib/stellwerk/rules/layers.rb
|
|
88
|
+
- lib/stellwerk/source_file_collector.rb
|
|
88
89
|
- lib/stellwerk/version.rb
|
|
89
90
|
- lib/stellwerk/violation.rb
|
|
90
91
|
- lib/tasks/stellwerk.rake
|