Class: FastIgnore::GitignoreRuleScanner

Inherits:
StringScanner
  • Object
show all
Defined in:
lib/fast_ignore/gitignore_rule_scanner.rb

Instance Method Summary collapse

Instance Method Details

#backslash?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/fast_ignore/gitignore_rule_scanner.rb', line 25

def backslash?
  skip(/\\/)
end

#character_class_end?Boolean

Returns:

  • (Boolean)


5
6
7
# File 'lib/fast_ignore/gitignore_rule_scanner.rb', line 5

def character_class_end?
  skip(/\]/)
end

#character_class_literalObject



61
62
63
# File 'lib/fast_ignore/gitignore_rule_scanner.rb', line 61

def character_class_literal
  matched if scan(/[^\]\\][^\]\\-]*(?!-)/)
end

#character_class_negation?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/fast_ignore/gitignore_rule_scanner.rb', line 13

def character_class_negation?
  skip(/\^|!/)
end

#character_class_range_endObject



69
70
71
72
73
74
75
# File 'lib/fast_ignore/gitignore_rule_scanner.rb', line 69

def character_class_range_end
  # we already confirmed this was going to match
  # with the lookahead in character_class_range_start
  skip(/-/)
  scan(/(\\.|[^\\\]])/)
  matched
end

#character_class_range_startObject



65
66
67
# File 'lib/fast_ignore/gitignore_rule_scanner.rb', line 65

def character_class_range_start
  matched if scan(/(\\.|[^\\\]])(?=-(\\.|[^\\\]]))/)
end

#character_class_start?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/fast_ignore/gitignore_rule_scanner.rb', line 9

def character_class_start?
  skip(/\[/)
end

#end?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/fast_ignore/gitignore_rule_scanner.rb', line 17

def end?
  skip(/\s*\z/)
end

#exclamation_mark?Boolean

Returns:

  • (Boolean)


85
86
87
# File 'lib/fast_ignore/gitignore_rule_scanner.rb', line 85

def exclamation_mark?
  skip(/!/)
end

#hash?Boolean

Returns:

  • (Boolean)


89
90
91
# File 'lib/fast_ignore/gitignore_rule_scanner.rb', line 89

def hash?
  skip(/#/)
end

#literalObject



77
78
79
# File 'lib/fast_ignore/gitignore_rule_scanner.rb', line 77

def literal
  matched if scan(%r{[^*/?\[\\\s]+})
end

#next_characterObject



37
38
39
# File 'lib/fast_ignore/gitignore_rule_scanner.rb', line 37

def next_character
  matched if scan(/./)
end

#question_mark?Boolean

Returns:

  • (Boolean)


57
58
59
# File 'lib/fast_ignore/gitignore_rule_scanner.rb', line 57

def question_mark?
  skip(/\?/)
end

#significant_whitespaceObject



81
82
83
# File 'lib/fast_ignore/gitignore_rule_scanner.rb', line 81

def significant_whitespace
  matched if scan(/\s+(?!\s|\z)/)
end

#slash?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/fast_ignore/gitignore_rule_scanner.rb', line 21

def slash?
  skip(%r{/})
end

#star?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/fast_ignore/gitignore_rule_scanner.rb', line 33

def star?
  skip(/\*/)
end

#star_end?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/fast_ignore/gitignore_rule_scanner.rb', line 41

def star_end?
  skip(/\*\s*\z/)
end

#star_slash_end?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/fast_ignore/gitignore_rule_scanner.rb', line 49

def star_slash_end?
  skip(%r{\*/\s*\z})
end

#two_star_end?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/fast_ignore/gitignore_rule_scanner.rb', line 45

def two_star_end?
  skip(/\*{2,}\s*\z/)
end

#two_star_slash_end?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/fast_ignore/gitignore_rule_scanner.rb', line 53

def two_star_slash_end?
  skip(%r{\*{2,}/\s*\z})
end

#two_stars?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/fast_ignore/gitignore_rule_scanner.rb', line 29

def two_stars?
  skip(/\*{2,}/)
end