fast_ignore 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/Gemfile.lock +1 -1
- data/bin/ls +5 -0
- data/lib/fast_ignore.rb +2 -2
- data/lib/fast_ignore/rule.rb +31 -13
- data/lib/fast_ignore/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b87f43721c846fb9a6580451cb7fe607f40de8dd57bfab60c3e48454404c3456
|
4
|
+
data.tar.gz: d1b79c925d24ff57b3e0a6d7d74923d241807d6015f1570ba17c58bb9458493e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff71be320a1218b786037efa9132d2167e80e899012afb843a59f03b7df414448892c2a71efa9e6504c2b558724a43fb1c17cd688802e0e3bbdf494ff9e7a714
|
7
|
+
data.tar.gz: 0a4f3bd777b3f8ca63086cbe63a61f759ca4915e4e6f80db74f69310d3ad59e997706fca8e6252326b2d217e2a79e6f3c4020eddb4eb646d6870fdc6cec44847
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/bin/ls
ADDED
data/lib/fast_ignore.rb
CHANGED
@@ -66,9 +66,9 @@ class FastIgnore
|
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
|
-
def pruned_allowed?(path, dir
|
69
|
+
def pruned_allowed?(path, dir = File.directory?(path))
|
70
70
|
rules.each do |rule|
|
71
|
-
return rule.negation? if rule.match?(path, dir
|
71
|
+
return rule.negation? if rule.match?(path, dir = dir)
|
72
72
|
end
|
73
73
|
end
|
74
74
|
end
|
data/lib/fast_ignore/rule.rb
CHANGED
@@ -4,38 +4,56 @@ class FastIgnore
|
|
4
4
|
class Rule
|
5
5
|
using DeletePrefixSuffix unless RUBY_VERSION >= '2.5'
|
6
6
|
|
7
|
-
|
8
|
-
|
7
|
+
FNMATCH_OPTIONS = File::FNM_DOTMATCH | File::FNM_PATHNAME
|
8
|
+
|
9
|
+
def initialize(rule, root:)
|
9
10
|
@rule = rule
|
10
11
|
strip!
|
11
12
|
return if skip?
|
12
13
|
|
13
|
-
|
14
|
-
|
15
|
-
|
14
|
+
extract_negation
|
15
|
+
extract_dir_only
|
16
|
+
|
17
|
+
@rule = "#{root}#{prefix}#{@rule}"
|
16
18
|
end
|
17
19
|
|
18
20
|
def negation?
|
19
|
-
@negation
|
21
|
+
@negation
|
20
22
|
end
|
21
23
|
|
22
|
-
def
|
23
|
-
@
|
24
|
+
def extract_negation
|
25
|
+
@negation = false
|
26
|
+
return unless @rule.start_with?('!')
|
27
|
+
|
28
|
+
@rule = @rule[1..-1]
|
29
|
+
@negation = true
|
24
30
|
end
|
25
31
|
|
26
|
-
def
|
27
|
-
|
32
|
+
def extract_dir_only
|
33
|
+
@dir_only = false
|
34
|
+
@not_dir_only = true
|
35
|
+
return unless @rule.end_with?('/')
|
28
36
|
|
29
|
-
|
37
|
+
@rule = @rule[0..-2]
|
38
|
+
@dir_only = true
|
39
|
+
@not_dir_only = false
|
40
|
+
end
|
30
41
|
|
31
|
-
|
42
|
+
def match?(path, dir = File.directory?(path))
|
43
|
+
return false unless dir || @not_dir_only
|
44
|
+
|
45
|
+
File.fnmatch?(@rule, path, FNMATCH_OPTIONS)
|
32
46
|
end
|
33
47
|
|
34
48
|
def empty?
|
49
|
+
return @empty if defined?(@empty)
|
50
|
+
|
35
51
|
@empty ||= @rule.empty?
|
36
52
|
end
|
37
53
|
|
38
54
|
def comment?
|
55
|
+
return @comment if defined?(@comment)
|
56
|
+
|
39
57
|
@comment ||= @rule.start_with?('#')
|
40
58
|
end
|
41
59
|
|
@@ -53,7 +71,7 @@ class FastIgnore
|
|
53
71
|
elsif @rule.end_with?('/**') || @rule.include?('/**/')
|
54
72
|
'/'
|
55
73
|
else
|
56
|
-
'
|
74
|
+
'/**/'
|
57
75
|
end
|
58
76
|
end
|
59
77
|
|
data/lib/fast_ignore/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fast_ignore
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dana Sherson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-09-
|
11
|
+
date: 2019-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -112,6 +112,7 @@ files:
|
|
112
112
|
- README.md
|
113
113
|
- Rakefile
|
114
114
|
- bin/console
|
115
|
+
- bin/ls
|
115
116
|
- bin/setup
|
116
117
|
- fast_ignore.gemspec
|
117
118
|
- lib/fast_ignore.rb
|
@@ -143,8 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
143
144
|
- !ruby/object:Gem::Version
|
144
145
|
version: '0'
|
145
146
|
requirements: []
|
146
|
-
|
147
|
-
rubygems_version: 2.7.6
|
147
|
+
rubygems_version: 3.0.3
|
148
148
|
signing_key:
|
149
149
|
specification_version: 4
|
150
150
|
summary: Parse gitignore files, quickly
|