fast_ignore 0.17.2 → 0.17.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/README.md +0 -13
- data/lib/fast_ignore/builders/gitignore.rb +15 -0
- data/lib/fast_ignore/builders/shebang.rb +17 -0
- data/lib/fast_ignore/builders/shebang_or_gitignore.rb +15 -0
- data/lib/fast_ignore/candidate.rb +85 -0
- data/lib/fast_ignore/gitconfig_parser.rb +1 -1
- data/lib/fast_ignore/gitignore_include_rule_builder.rb +40 -63
- data/lib/fast_ignore/gitignore_rule_builder.rb +49 -26
- data/lib/fast_ignore/gitignore_rule_group.rb +31 -0
- data/lib/fast_ignore/gitignore_rule_scanner.rb +12 -0
- data/lib/fast_ignore/matchers/allow_any_dir.rb +39 -0
- data/lib/fast_ignore/matchers/allow_path_regexp.rb +45 -0
- data/lib/fast_ignore/matchers/ignore_path_regexp.rb +45 -0
- data/lib/fast_ignore/matchers/shebang_regexp.rb +46 -0
- data/lib/fast_ignore/matchers/unmatchable.rb +31 -0
- data/lib/fast_ignore/matchers/within_dir.rb +50 -0
- data/lib/fast_ignore/path_expander.rb +11 -0
- data/lib/fast_ignore/path_regexp_builder.rb +130 -0
- data/lib/fast_ignore/patterns.rb +33 -0
- data/lib/fast_ignore/relative_candidate.rb +20 -0
- data/lib/fast_ignore/rule_group.rb +42 -0
- data/lib/fast_ignore/rule_groups.rb +55 -0
- data/lib/fast_ignore/version.rb +1 -1
- data/lib/fast_ignore/walkers/base.rb +26 -0
- data/lib/fast_ignore/walkers/file_system.rb +46 -0
- data/lib/fast_ignore/walkers/gitignore_collecting_file_system.rb +48 -0
- data/lib/fast_ignore.rb +54 -84
- metadata +23 -11
- data/lib/fast_ignore/file_root.rb +0 -35
- data/lib/fast_ignore/gitignore_rule_regexp_builder.rb +0 -76
- data/lib/fast_ignore/rule.rb +0 -65
- data/lib/fast_ignore/rule_builder.rb +0 -37
- data/lib/fast_ignore/rule_set.rb +0 -76
- data/lib/fast_ignore/rule_sets.rb +0 -109
- data/lib/fast_ignore/shebang_rule.rb +0 -80
- data/lib/fast_ignore/unmatchable_rule.rb +0 -41
@@ -1,80 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class FastIgnore
|
4
|
-
class ShebangRule
|
5
|
-
attr_reader :negation
|
6
|
-
alias_method :negation?, :negation
|
7
|
-
undef :negation
|
8
|
-
|
9
|
-
attr_reader :rule
|
10
|
-
|
11
|
-
attr_reader :file_path_pattern
|
12
|
-
|
13
|
-
attr_reader :squashable_type
|
14
|
-
|
15
|
-
def squash(rules)
|
16
|
-
::FastIgnore::ShebangRule.new(::Regexp.union(rules.map(&:rule)).freeze, negation?, file_path_pattern)
|
17
|
-
end
|
18
|
-
|
19
|
-
def component_rules_count
|
20
|
-
1
|
21
|
-
end
|
22
|
-
|
23
|
-
def initialize(rule, negation, file_path_pattern)
|
24
|
-
@rule = rule
|
25
|
-
@negation = negation
|
26
|
-
@file_path_pattern = file_path_pattern
|
27
|
-
|
28
|
-
@squashable_type = (negation ? 13 : 12) + file_path_pattern.object_id
|
29
|
-
|
30
|
-
freeze
|
31
|
-
end
|
32
|
-
|
33
|
-
def file_only?
|
34
|
-
true
|
35
|
-
end
|
36
|
-
|
37
|
-
def dir_only?
|
38
|
-
false
|
39
|
-
end
|
40
|
-
|
41
|
-
# :nocov:
|
42
|
-
def inspect
|
43
|
-
allow_fragment = 'allow ' if @negation
|
44
|
-
in_fragment = " in #{@file_path_pattern}" if @file_path_pattern
|
45
|
-
"#<ShebangRule #{allow_fragment}#!:#{@rule.to_s[15..-4]}#{in_fragment}>"
|
46
|
-
end
|
47
|
-
# :nocov:
|
48
|
-
|
49
|
-
def match?(relative_path, full_path, filename, content)
|
50
|
-
return false if filename.include?('.')
|
51
|
-
return false unless (not @file_path_pattern) || @file_path_pattern.match?(relative_path)
|
52
|
-
|
53
|
-
(content || first_line(full_path))&.match?(@rule)
|
54
|
-
end
|
55
|
-
|
56
|
-
def shebang?
|
57
|
-
true
|
58
|
-
end
|
59
|
-
|
60
|
-
private
|
61
|
-
|
62
|
-
def first_line(path) # rubocop:disable Metrics/MethodLength
|
63
|
-
file = ::File.new(path)
|
64
|
-
first_line = file.sysread(64)
|
65
|
-
if first_line.start_with?('#!')
|
66
|
-
first_line += file.readline unless first_line.include?("\n")
|
67
|
-
else
|
68
|
-
file.close
|
69
|
-
return
|
70
|
-
end
|
71
|
-
file.close
|
72
|
-
first_line
|
73
|
-
rescue ::EOFError, ::SystemCallError
|
74
|
-
# :nocov:
|
75
|
-
file&.close
|
76
|
-
# :nocov:
|
77
|
-
first_line
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class FastIgnore
|
4
|
-
class UnmatchableRule
|
5
|
-
class << self
|
6
|
-
def squash(_)
|
7
|
-
self
|
8
|
-
end
|
9
|
-
|
10
|
-
def squashable_type
|
11
|
-
5
|
12
|
-
end
|
13
|
-
|
14
|
-
def component_rules_count
|
15
|
-
1
|
16
|
-
end
|
17
|
-
|
18
|
-
def dir_only?
|
19
|
-
false
|
20
|
-
end
|
21
|
-
|
22
|
-
def file_only?
|
23
|
-
false
|
24
|
-
end
|
25
|
-
|
26
|
-
def shebang?
|
27
|
-
false
|
28
|
-
end
|
29
|
-
|
30
|
-
# :nocov:
|
31
|
-
def inspect
|
32
|
-
'#<UnmatchableRule>'
|
33
|
-
end
|
34
|
-
# :nocov:
|
35
|
-
|
36
|
-
def match?(_relative_path, _full_path, _filename, _content)
|
37
|
-
false
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|