mirror of
https://gitea.invidious.io/iv-org/shard-ameba.git
synced 2024-08-15 00:53:29 +00:00
Refactor building default globs
This commit is contained in:
parent
7690074cab
commit
eb60b25c4e
2 changed files with 4 additions and 8 deletions
|
@ -20,7 +20,7 @@ module Ameba
|
|||
File.touch "lib/shard.cr"
|
||||
yml = YAML.parse "{}"
|
||||
config = Config.new(yml)
|
||||
config.globs.should eq Config::DEFAULT_GLOBS
|
||||
config.globs.should eq ["**/*.cr", "!lib"]
|
||||
File.delete "lib/shard.cr"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -55,10 +55,7 @@ class Ameba::Config
|
|||
Path[XDG_CONFIG_HOME] / "ameba/config.yml",
|
||||
}
|
||||
|
||||
DEFAULT_GLOBS = %w(
|
||||
**/*.cr
|
||||
!lib
|
||||
)
|
||||
SOURCES_GLOB = "**/*.cr"
|
||||
|
||||
getter rules : Array(Rule::Base)
|
||||
property severity = Severity::Convention
|
||||
|
@ -240,9 +237,8 @@ class Ameba::Config
|
|||
end
|
||||
|
||||
private def default_globs
|
||||
DEFAULT_GLOBS.select do |glob|
|
||||
!Dir[glob].empty? ||
|
||||
(glob.starts_with?("!") && !Dir["#{glob[1..-1]}/**/*.cr"].empty?)
|
||||
[SOURCES_GLOB].tap do |globs|
|
||||
globs.push("!lib") if !Dir["lib/**/*.cr"].empty?
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue