Class: FastIgnore::GitignoreIncludeRuleBuilder
Instance Method Summary
collapse
#anchored!, #blank!, #break!, #build, #dir_only!, #emit_any_dir, #emit_dir, #expand_rule_path!, #never_anchored!, #nothing_emitted?, #prefix, #process_backslash, #process_character_class, #process_character_class_range, #process_end, #process_rule, #process_slash, #process_star_end_after_slash, #process_two_stars
Constructor Details
Returns a new instance of GitignoreIncludeRuleBuilder.
5
6
7
8
9
|
# File 'lib/fast_ignore/gitignore_include_rule_builder.rb', line 5
def initialize(rule, expand_path_with: nil)
super
@negation = true
end
|
Instance Method Details
#build_as_parent ⇒ Object
59
60
61
62
63
64
65
66
67
|
# File 'lib/fast_ignore/gitignore_include_rule_builder.rb', line 59
def build_as_parent
anchored!
dir_only!
catch :abort_build do
process_rule
build_rule(child_file_rule: false)
end
end
|
#build_child_file_rule ⇒ Object
rubocop:disable Metrics/MethodLength
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/fast_ignore/gitignore_include_rule_builder.rb', line 43
def build_child_file_rule if @child_re.end_with?('/')
@child_re.append_many_non_dir.append_dir if @dir_only
else
@child_re.append_dir
end
@child_re.prepend(prefix)
if @negation
::FastIgnore::Matchers::AllowPathRegexp.new(@child_re.to_regexp, @anchored, false)
else
::FastIgnore::Matchers::IgnorePathRegexp.new(@child_re.to_regexp, @anchored, false)
end
end
|
#build_parent_dir_rules ⇒ Object
#build_rule(child_file_rule: true) ⇒ Object
69
70
71
72
73
|
# File 'lib/fast_ignore/gitignore_include_rule_builder.rb', line 69
def build_rule(child_file_rule: true)
@child_re ||= @re.dup
[super(), *build_parent_dir_rules, (build_child_file_rule if child_file_rule)].compact
end
|
#emit_end ⇒ Object
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/fast_ignore/gitignore_include_rule_builder.rb', line 19
def emit_end
if @dir_only
@child_re = @re.dup
@re.append_end_anchor
else
@re.append_dir_or_end_anchor
end
break!
end
|
#negated! ⇒ Object
11
12
13
|
# File 'lib/fast_ignore/gitignore_include_rule_builder.rb', line 11
def negated!
@negation = false
end
|
#unmatchable_rule! ⇒ Object
15
16
17
|
# File 'lib/fast_ignore/gitignore_include_rule_builder.rb', line 15
def unmatchable_rule!
throw :abort_build, ::FastIgnore::Matchers::Unmatchable
end
|