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
|
rule.excluded?(Source.new "", "source.cr").should be_true
|
||||||
end
|
end
|
||||||
|
|
||||||
pending "returns true if source matches the wildcard" do
|
it "returns true if source matches the wildcard" do
|
||||||
rule = DummyRule.new
|
rule = DummyRule.new
|
||||||
rule.excluded = %w(**/*.cr)
|
rule.excluded = %w(**/*.cr)
|
||||||
rule.excluded?(Source.new "", "source.cr").should be_true
|
rule.excluded?(Source.new "", __FILE__).should be_true
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns false if source does not match the wildcard" do
|
it "returns false if source does not match the wildcard" do
|
||||||
|
|
|
@ -35,5 +35,17 @@ module Ameba
|
||||||
s.fullpath.should_not be_nil
|
s.fullpath.should_not be_nil
|
||||||
end
|
end
|
||||||
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
|
||||||
end
|
end
|
||||||
|
|
|
@ -75,8 +75,8 @@ module Ameba::Rule
|
||||||
#
|
#
|
||||||
def excluded?(source)
|
def excluded?(source)
|
||||||
excluded.try &.any? do |path|
|
excluded.try &.any? do |path|
|
||||||
# TODO: file pattern match
|
source.matches_path?(path) ||
|
||||||
source.path == path || source.fullpath == File.expand_path(path)
|
Dir.glob(path).any? { |glob| source.matches_path? glob }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -111,5 +111,10 @@ module Ameba
|
||||||
def fullpath
|
def fullpath
|
||||||
@fullpath ||= File.expand_path @path
|
@fullpath ||= File.expand_path @path
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue