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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eaaf2c138c43c26a31c7db96a3c62cdc84448e6bf0bd69ec6f52903982f31355
4
- data.tar.gz: 4a7aba009bc16257c892eef7f4bde045d05d3f44c075d058d65c1ae8f9590043
3
+ metadata.gz: b87f43721c846fb9a6580451cb7fe607f40de8dd57bfab60c3e48454404c3456
4
+ data.tar.gz: d1b79c925d24ff57b3e0a6d7d74923d241807d6015f1570ba17c58bb9458493e
5
5
  SHA512:
6
- metadata.gz: e4f748d58f6d729bf843b5866cc2de2c37783365604d975d64811ef752893cffc16782e4914264b612ddccc5d59663ced29aeabbc45c9f3287b2bf3fb363f3c5
7
- data.tar.gz: c5cf28f08d04aff707feac23e3727e0a42c3802af1f16d779779cf4ee5a09e375261a769fce6440cf7e9369076b08be931b9dc5121ac9ff3f220f269a059808c
6
+ metadata.gz: ff71be320a1218b786037efa9132d2167e80e899012afb843a59f03b7df414448892c2a71efa9e6504c2b558724a43fb1c17cd688802e0e3bbdf494ff9e7a714
7
+ data.tar.gz: 0a4f3bd777b3f8ca63086cbe63a61f759ca4915e4e6f80db74f69310d3ad59e997706fca8e6252326b2d217e2a79e6f3c4020eddb4eb646d6870fdc6cec44847
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ # v0.3.3
2
+ - some performance improvements. maybe
3
+
1
4
  # v0.3.2
2
5
  - handle soft links to nowhere
3
6
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fast_ignore (0.3.2)
4
+ fast_ignore (0.3.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/bin/ls ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../lib/fast_ignore'
4
+
5
+ puts FastIgnore.new(relative: true).to_a.join("\n")
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: File.directory?(path))
69
+ def pruned_allowed?(path, dir = File.directory?(path))
70
70
  rules.each do |rule|
71
- return rule.negation? if rule.match?(path, dir: dir)
71
+ return rule.negation? if rule.match?(path, dir = dir)
72
72
  end
73
73
  end
74
74
  end
@@ -4,38 +4,56 @@ class FastIgnore
4
4
  class Rule
5
5
  using DeletePrefixSuffix unless RUBY_VERSION >= '2.5'
6
6
 
7
- def initialize(rule, root: Dir.pwd)
8
- @root = root
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
- @rule = @rule.delete_prefix('!') if negation?
14
- @rule = @rule.delete_suffix('/') if dir_only?
15
- @rule = "#{prefix}#{@rule}"
14
+ extract_negation
15
+ extract_dir_only
16
+
17
+ @rule = "#{root}#{prefix}#{@rule}"
16
18
  end
17
19
 
18
20
  def negation?
19
- @negation ||= @rule.start_with?('!')
21
+ @negation
20
22
  end
21
23
 
22
- def dir_only?
23
- @dir_only ||= @rule.end_with?('/')
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 match?(path, dir: File.directory?(path))
27
- return false if !dir && dir_only?
32
+ def extract_dir_only
33
+ @dir_only = false
34
+ @not_dir_only = true
35
+ return unless @rule.end_with?('/')
28
36
 
29
- path = path.delete_prefix(root)
37
+ @rule = @rule[0..-2]
38
+ @dir_only = true
39
+ @not_dir_only = false
40
+ end
30
41
 
31
- File.fnmatch?(@rule, path, File::FNM_DOTMATCH | File::FNM_PATHNAME)
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
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class FastIgnore
4
- VERSION = '0.3.2'
4
+ VERSION = '0.3.3'
5
5
  end
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.2
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-20 00:00:00.000000000 Z
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
- rubyforge_project:
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