mirror of
https://gitea.invidious.io/iv-org/shard-ameba.git
synced 2024-08-15 00:53:29 +00:00
parent
c12b4f1aa5
commit
e1b51f62a5
4 changed files with 21 additions and 4 deletions
|
@ -55,10 +55,10 @@ module Ameba::Rule
|
|||
rule.excluded?(Source.new "", "source.cr").should be_true
|
||||
end
|
||||
|
||||
pending "returns true if source matches the wildcard" do
|
||||
it "returns true if source matches the wildcard" do
|
||||
rule = DummyRule.new
|
||||
rule.excluded = %w(**/*.cr)
|
||||
rule.excluded?(Source.new "", "source.cr").should be_true
|
||||
rule.excluded?(Source.new "", __FILE__).should be_true
|
||||
end
|
||||
|
||||
it "returns false if source does not match the wildcard" do
|
||||
|
|
|
@ -35,5 +35,17 @@ module Ameba
|
|||
s.fullpath.should_not be_nil
|
||||
end
|
||||
end
|
||||
|
||||
describe "#matches_path?" do
|
||||
it "returns true if source's path is matched" do
|
||||
s = Source.new "", "source.cr"
|
||||
s.matches_path?("source.cr").should be_true
|
||||
end
|
||||
|
||||
it "returns false if source's path is not matched" do
|
||||
s = Source.new "", "source.cr"
|
||||
s.matches_path?("new_source.cr").should be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -75,8 +75,8 @@ module Ameba::Rule
|
|||
#
|
||||
def excluded?(source)
|
||||
excluded.try &.any? do |path|
|
||||
# TODO: file pattern match
|
||||
source.path == path || source.fullpath == File.expand_path(path)
|
||||
source.matches_path?(path) ||
|
||||
Dir.glob(path).any? { |glob| source.matches_path? glob }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -111,5 +111,10 @@ module Ameba
|
|||
def fullpath
|
||||
@fullpath ||= File.expand_path @path
|
||||
end
|
||||
|
||||
# Returns true if *filepath* matches the source's path, false if it does not.
|
||||
def matches_path?(filepath)
|
||||
path == filepath || path == File.expand_path(filepath)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue