-
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
16 changed files
with
1,224 additions
and
158 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
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
118 changes: 118 additions & 0 deletions
118
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,118 @@ | ||
# 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 root_end | ||
# / or \ or UMC path or driver letter | ||
matched if scan(%r{(?:[\\/]{1,2}|[a-zA-Z]:[\\/])\s*\z}) | ||
end | ||
|
||
# @return [String, nil] | ||
def root | ||
# / or \ or UMC path or driver letter | ||
matched if scan(%r{(?:[\\/]{1,2}|[a-zA-Z]:[\\/])}) | ||
end | ||
|
||
# @return [String, nil] | ||
def home_slash_end | ||
'~' if scan(%r{~[\\/]\s*\z}) | ||
end | ||
|
||
# @return [String, nil] | ||
def home_slash_or_end | ||
'~' if scan(%r{~(?:[\\/]|\s*\z)}) | ||
end | ||
|
||
# @return [Boolean] | ||
def dot_slash_or_end? | ||
skip(%r{\.(?:[\\/]|\s*\z)}) | ||
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_or_end? | ||
skip(%r{\.\.(?:[\\/]|\s*\z)}) | ||
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.