-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GlobGitignore doesn't preprocess patterns
- Loading branch information
Showing
10 changed files
with
580 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 108 additions & 0 deletions
108
lib/path_list/pattern_parser/gitignore/windows_rule_scanner.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'strscan' | ||
|
||
class PathList | ||
class PatternParser | ||
class Gitignore | ||
# @api private | ||
class WindowsRuleScanner < RuleScanner | ||
# @return [Boolean] | ||
def slash? | ||
skip(%r{[\\/]}) | ||
end | ||
|
||
# @return [String, nil] | ||
def home | ||
# not sure this makes sense on windows, but just for similarity | ||
scan(%r{~[^/\\]*}) | ||
end | ||
|
||
# @return [String, nil] | ||
def root | ||
# / or \ or UMC path or driver letter | ||
matched if scan(%r{(?:[\\/]{1,2}|[a-zA-Z]:[\\/])}) | ||
end | ||
|
||
# @return [Boolean] | ||
def dot_slash? | ||
skip(%r{\.[\\/]}) | ||
end | ||
|
||
# @return [Boolean] | ||
def dot_slash_end? | ||
skip(%r{\.[\\/]\s*\z}) | ||
end | ||
|
||
# @return [Boolean] | ||
def dot_dot_slash_end? | ||
skip(%r{\.\.[\\/]\s*\z}) | ||
end | ||
|
||
# @return [Boolean] | ||
def dot_dot_slash? | ||
skip(%r{\.\.[\\/]}) | ||
end | ||
|
||
# @return [Boolean] | ||
def slash_end? | ||
skip(%r{[\\/]\s*\z}) | ||
end | ||
|
||
# @return [Boolean] | ||
def escape? | ||
skip(/`/) | ||
end | ||
|
||
# @return [Boolean] | ||
def star_star_slash_end? | ||
skip(%r{\*{2,}[\\/]\s*\z}) | ||
end | ||
|
||
# @return [Boolean] | ||
def star_star_slash_slash? | ||
skip(%r{\*{2,}[\\/]{2}}) | ||
end | ||
|
||
# @return [Boolean] | ||
def slash_slash? | ||
skip(%r{[\\/]{2}}) | ||
end | ||
|
||
# @return [Boolean] | ||
def star_star_slash? | ||
skip(%r{\*{2,}[\\/]}) | ||
end | ||
|
||
# @return [Boolean] | ||
def slash_star_star_end? | ||
skip(%r{[\\/]\*{2,}\s*\z}) | ||
end | ||
|
||
# @return [String, nil] | ||
def character_class_literal | ||
matched if scan(/[^\]`][^\]`-]*(?!-)/) | ||
end | ||
|
||
# @return [String, nil] | ||
def character_class_range_start | ||
matched.delete_prefix('`') if scan(/(`.|[^`\]])(?=-(`.|[^`\]]))/) | ||
end | ||
|
||
# @return [String, nil] | ||
def character_class_range_end | ||
# we already confirmed this was going to match | ||
# with the lookahead in character_class_range_start | ||
skip(/-/) | ||
scan(/(`.|[^`\]])/) | ||
matched.delete_prefix('`') | ||
end | ||
|
||
# @return [String, nil] | ||
def literal | ||
matched if scan(%r{[^*[\\/]?\[`\s]+}) | ||
end | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.