Class: FastIgnore::PathRegexpBuilder
- Inherits:
-
Object
- Object
- FastIgnore::PathRegexpBuilder
- Defined in:
- lib/fast_ignore/path_regexp_builder.rb
Instance Method Summary collapse
- #append(value) ⇒ Object (also: #<<)
- #append_any_dir ⇒ Object
- #append_any_non_dir ⇒ Object
- #append_character_class_close ⇒ Object
- #append_character_class_dash ⇒ Object
- #append_character_class_negation ⇒ Object
- #append_character_class_open ⇒ Object
- #append_dir ⇒ Object
- #append_dir_or_end_anchor ⇒ Object
- #append_dir_or_start_anchor ⇒ Object
- #append_end_anchor ⇒ Object
-
#append_escaped(value) ⇒ Object
builder methods.
- #append_many_non_dir ⇒ Object
- #append_one_non_dir ⇒ Object
- #append_start_anchor ⇒ Object
-
#dup ⇒ Object
String methods.
- #empty? ⇒ Boolean
- #end_with?(str) ⇒ Boolean
-
#initialize ⇒ PathRegexpBuilder
constructor
A new instance of PathRegexpBuilder.
- #prepend(value) ⇒ Object
- #to_regexp ⇒ Object
- #to_str ⇒ Object (also: #to_s)
Constructor Details
#initialize ⇒ PathRegexpBuilder
Returns a new instance of PathRegexpBuilder.
5 6 7 |
# File 'lib/fast_ignore/path_regexp_builder.rb', line 5 def initialize @string = +'' end |
Instance Method Details
#append(value) ⇒ Object Also known as: <<
37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/fast_ignore/path_regexp_builder.rb', line 37 def append(value) @string.<<(value) self rescue FrozenError # :nocov: # the string seems to become inadvertently frozen in 2.5 and 2.6 with specific inputs # and i don't understand why # it seems like it's happening during the Regexp.new # for some reason that i don't understand @string = @string.dup append(value) # :nocov: end |
#append_any_dir ⇒ Object
80 81 82 |
# File 'lib/fast_ignore/path_regexp_builder.rb', line 80 def append_any_dir append('(?:.*/)?') end |
#append_any_non_dir ⇒ Object
88 89 90 91 |
# File 'lib/fast_ignore/path_regexp_builder.rb', line 88 def append_any_non_dir append_one_non_dir append('*') end |
#append_character_class_close ⇒ Object
126 127 128 |
# File 'lib/fast_ignore/path_regexp_builder.rb', line 126 def append_character_class_close append(']') end |
#append_character_class_dash ⇒ Object
122 123 124 |
# File 'lib/fast_ignore/path_regexp_builder.rb', line 122 def append_character_class_dash append('-') end |
#append_character_class_negation ⇒ Object
118 119 120 |
# File 'lib/fast_ignore/path_regexp_builder.rb', line 118 def append_character_class_negation append('^') end |
#append_character_class_open ⇒ Object
114 115 116 |
# File 'lib/fast_ignore/path_regexp_builder.rb', line 114 def append_character_class_open append('(?!/)[') end |
#append_dir ⇒ Object
76 77 78 |
# File 'lib/fast_ignore/path_regexp_builder.rb', line 76 def append_dir append('/') end |
#append_dir_or_end_anchor ⇒ Object
110 111 112 |
# File 'lib/fast_ignore/path_regexp_builder.rb', line 110 def append_dir_or_end_anchor append('(?:/|\\z)') end |
#append_dir_or_start_anchor ⇒ Object
106 107 108 |
# File 'lib/fast_ignore/path_regexp_builder.rb', line 106 def append_dir_or_start_anchor append('(?:\\A|/)') end |
#append_end_anchor ⇒ Object
98 99 100 |
# File 'lib/fast_ignore/path_regexp_builder.rb', line 98 def append_end_anchor append('\\z') end |
#append_escaped(value) ⇒ Object
builder methods
70 71 72 73 74 |
# File 'lib/fast_ignore/path_regexp_builder.rb', line 70 def append_escaped(value) return unless value append(::Regexp.escape(value)) end |
#append_many_non_dir ⇒ Object
93 94 95 96 |
# File 'lib/fast_ignore/path_regexp_builder.rb', line 93 def append_many_non_dir append_one_non_dir append('+') end |
#append_one_non_dir ⇒ Object
84 85 86 |
# File 'lib/fast_ignore/path_regexp_builder.rb', line 84 def append_one_non_dir append('[^/]') end |
#append_start_anchor ⇒ Object
102 103 104 |
# File 'lib/fast_ignore/path_regexp_builder.rb', line 102 def append_start_anchor append('\\A') end |
#dup ⇒ Object
String methods
16 17 18 19 20 21 22 |
# File 'lib/fast_ignore/path_regexp_builder.rb', line 16 def dup out = super @string = @string.dup out end |
#empty? ⇒ Boolean
29 30 31 |
# File 'lib/fast_ignore/path_regexp_builder.rb', line 29 def empty? @string.empty? end |
#end_with?(str) ⇒ Boolean
33 34 35 |
# File 'lib/fast_ignore/path_regexp_builder.rb', line 33 def end_with?(str) @string.end_with?(str) end |
#prepend(value) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/fast_ignore/path_regexp_builder.rb', line 53 def prepend(value) @string.prepend(value) self rescue FrozenError # :nocov: # the string seems to become inadvertently frozen in 2.5 and 2.6 with specific inputs # and i don't understand why # it seems like it's happening during the Regexp.new # for some reason that i don't understand @string = @string.dup prepend(value) # :nocov: end |
#to_regexp ⇒ Object
9 10 11 12 |
# File 'lib/fast_ignore/path_regexp_builder.rb', line 9 def to_regexp # Regexp::IGNORECASE = 1 ::Regexp.new(@string, 1) end |
#to_str ⇒ Object Also known as: to_s
24 25 26 |
# File 'lib/fast_ignore/path_regexp_builder.rb', line 24 def to_str @string end |