fast_ignore 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -3
- data/.travis.yml +4 -1
- data/CHANGELOG.md +3 -0
- data/Gemfile.lock +15 -17
- data/README.md +22 -12
- data/lib/fast_ignore/delete_prefix_suffix.rb +24 -0
- data/lib/fast_ignore/rule.rb +2 -0
- data/lib/fast_ignore/version.rb +1 -1
- data/lib/fast_ignore.rb +2 -0
- metadata +4 -5
- data/.ruby-version +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '078431fdfb48356146694f1fffba57803f876a1b67f52c6b8180ec5f9efe2f30'
|
4
|
+
data.tar.gz: 4c9e880bf30a6656382a7437b97847be095c4e4f77276979a52e11e421905cb6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b986db1ce0dc3a0359cd7d556e52caaa5c9adc3f6ff0d513fed436f036b73db937546c981705c7da560fe9833c2f24fe2e521d428575bd1f3d05c8f15fb37535
|
7
|
+
data.tar.gz: d871816557a546cd2a43bc2206b5dbcab7fa3a4418ff8ffb98f85d36ea66cbe12dd9aac329bb30db9f4d7144c75b09423b8e2054597540caf2a6f42edf682478
|
data/.rubocop.yml
CHANGED
@@ -11,6 +11,7 @@ AllCops:
|
|
11
11
|
- db/schema*
|
12
12
|
- .bundle/**/*
|
13
13
|
- tmp/**/*
|
14
|
+
- vendor/**/*
|
14
15
|
DisplayCopNames: true
|
15
16
|
DisplayStyleGuide: true
|
16
17
|
|
@@ -68,15 +69,15 @@ Layout/FirstHashElementLineBreak:
|
|
68
69
|
Enabled: true
|
69
70
|
|
70
71
|
# to match our preference for consistent indentation
|
71
|
-
Layout/
|
72
|
+
Layout/IndentFirstArgument:
|
72
73
|
EnforcedStyle: consistent
|
73
74
|
|
74
75
|
# to match our preference for consistent indentation
|
75
|
-
Layout/
|
76
|
+
Layout/IndentFirstArrayElement:
|
76
77
|
EnforcedStyle: consistent
|
77
78
|
|
78
79
|
# to match our preference for consistent indentation
|
79
|
-
Layout/
|
80
|
+
Layout/IndentFirstHashElement:
|
80
81
|
EnforcedStyle: consistent
|
81
82
|
|
82
83
|
# to match our preference for consistent indentation
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
fast_ignore (0.
|
4
|
+
fast_ignore (0.3.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
@@ -9,42 +9,40 @@ GEM
|
|
9
9
|
ast (2.4.0)
|
10
10
|
coderay (1.1.2)
|
11
11
|
diff-lcs (1.3)
|
12
|
-
jaro_winkler (1.5.
|
12
|
+
jaro_winkler (1.5.3)
|
13
13
|
method_source (0.9.2)
|
14
|
-
parallel (1.
|
15
|
-
parser (2.6.
|
14
|
+
parallel (1.17.0)
|
15
|
+
parser (2.6.3.0)
|
16
16
|
ast (~> 2.4.0)
|
17
17
|
pry (0.12.2)
|
18
18
|
coderay (~> 1.1.0)
|
19
19
|
method_source (~> 0.9.0)
|
20
|
-
psych (3.1.0)
|
21
20
|
rainbow (3.0.0)
|
22
21
|
rake (10.5.0)
|
23
22
|
rspec (3.8.0)
|
24
23
|
rspec-core (~> 3.8.0)
|
25
24
|
rspec-expectations (~> 3.8.0)
|
26
25
|
rspec-mocks (~> 3.8.0)
|
27
|
-
rspec-core (3.8.
|
26
|
+
rspec-core (3.8.2)
|
28
27
|
rspec-support (~> 3.8.0)
|
29
|
-
rspec-expectations (3.8.
|
28
|
+
rspec-expectations (3.8.4)
|
30
29
|
diff-lcs (>= 1.2.0, < 2.0)
|
31
30
|
rspec-support (~> 3.8.0)
|
32
|
-
rspec-mocks (3.8.
|
31
|
+
rspec-mocks (3.8.1)
|
33
32
|
diff-lcs (>= 1.2.0, < 2.0)
|
34
33
|
rspec-support (~> 3.8.0)
|
35
|
-
rspec-support (3.8.
|
36
|
-
rubocop (0.
|
34
|
+
rspec-support (3.8.2)
|
35
|
+
rubocop (0.74.0)
|
37
36
|
jaro_winkler (~> 1.5.1)
|
38
37
|
parallel (~> 1.10)
|
39
|
-
parser (>= 2.
|
40
|
-
psych (>= 3.1.0)
|
38
|
+
parser (>= 2.6)
|
41
39
|
rainbow (>= 2.2.2, < 4.0)
|
42
40
|
ruby-progressbar (~> 1.7)
|
43
|
-
unicode-display_width (>= 1.4.0, < 1.
|
44
|
-
rubocop-rspec (1.
|
41
|
+
unicode-display_width (>= 1.4.0, < 1.7)
|
42
|
+
rubocop-rspec (1.35.0)
|
45
43
|
rubocop (>= 0.60.0)
|
46
|
-
ruby-progressbar (1.10.
|
47
|
-
unicode-display_width (1.
|
44
|
+
ruby-progressbar (1.10.1)
|
45
|
+
unicode-display_width (1.6.0)
|
48
46
|
|
49
47
|
PLATFORMS
|
50
48
|
ruby
|
@@ -59,4 +57,4 @@ DEPENDENCIES
|
|
59
57
|
rubocop-rspec (~> 1)
|
60
58
|
|
61
59
|
BUNDLED WITH
|
62
|
-
1.17.
|
60
|
+
1.17.3
|
data/README.md
CHANGED
@@ -1,8 +1,11 @@
|
|
1
1
|
# FastIgnore
|
2
2
|
|
3
|
-
![travis](https://travis-ci.org/robotdana/fast_ignore.svg?branch=master)
|
3
|
+
[![travis](https://travis-ci.org/robotdana/fast_ignore.svg?branch=master)](https://travis-ci.org/robotdana/fast_ignore)
|
4
4
|
|
5
|
-
Filter a directory using a .gitignore file.
|
5
|
+
Filter a directory tree using a .gitignore file. Recognises all of the gitignore rules.
|
6
|
+
```ruby
|
7
|
+
FastIgnore.new(relative: true).sort == `git ls-files`.split("\n").sort
|
8
|
+
```
|
6
9
|
|
7
10
|
## Installation
|
8
11
|
|
@@ -13,19 +16,22 @@ gem 'fast_ignore'
|
|
13
16
|
```
|
14
17
|
|
15
18
|
And then execute:
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
+
```sh
|
20
|
+
$ bundle
|
21
|
+
```
|
19
22
|
Or install it yourself as:
|
20
|
-
|
21
|
-
|
23
|
+
```sh
|
24
|
+
$ gem install fast_ignore
|
25
|
+
```
|
22
26
|
|
23
27
|
## Usage
|
28
|
+
|
24
29
|
```ruby
|
25
30
|
FastIgnore.new.each { |file| puts "#{file} is not ignored by the .gitignore" }
|
26
31
|
```
|
27
32
|
|
28
|
-
Like many other enumerables, FastIgnore
|
33
|
+
Like many other enumerables, `FastIgnore#each` can return an enumerator
|
34
|
+
|
29
35
|
```ruby
|
30
36
|
FastIgnore.new.each.with_index { |file, index| puts "#{file}#{index}" }
|
31
37
|
```
|
@@ -53,7 +59,7 @@ FastIgnore.new(files: 'absolute/path/to/my/ignore/file', gitignore: false)
|
|
53
59
|
FastIgnore.new(rules: %w{my*rule /and/another !rule}, gitignore: false)
|
54
60
|
```
|
55
61
|
|
56
|
-
By default, FastIgnore will look in the directory the script is run in (PWD) for a gitignore file. If it's somewhere else:
|
62
|
+
By default, FastIgnore will look in the directory the script is run in (`PWD`) for a gitignore file. If it's somewhere else:
|
57
63
|
```ruby
|
58
64
|
FastIgnore.new(gitignore: '/absolute/path/to/.gitignore').to_a
|
59
65
|
```
|
@@ -64,13 +70,17 @@ To check if a single file is allowed, use
|
|
64
70
|
FastIgnore.new.allowed?('/absolute/path/to/file')
|
65
71
|
```
|
66
72
|
|
67
|
-
## Known issues
|
68
|
-
- Doesn't take into account
|
73
|
+
## Known issues
|
74
|
+
- Doesn't take into account project excludes in `.git/info/exclude`
|
69
75
|
- Doesn't take into account globally ignored files in `git config core.excludesFile`
|
70
|
-
This is probably a wontfix, as you need git to read the config, and may as well just
|
71
76
|
```ruby
|
72
77
|
`git ls-files`.split("\n")
|
73
78
|
```
|
79
|
+
- Doesn't follow this rule in the gitignore documentation because I don't understand what it means that isn't covered by other rules:
|
80
|
+
If the pattern does not contain a slash /, Git treats it as a shell glob pattern and checks for a match against the pathname relative to the location of the .gitignore file
|
81
|
+
(relative to the toplevel of the work tree if not from a .gitignore file)
|
82
|
+
if someone can explain it with examples [make an issue please](https://github.com/robotdana/fast_ignore/issues/new)
|
83
|
+
|
74
84
|
## Development
|
75
85
|
|
76
86
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# This is a backport of ruby 2.5's delete_prefix/delete_suffix methods
|
4
|
+
module DeletePrefixSuffix
|
5
|
+
refine String do
|
6
|
+
def delete_prefix!(str)
|
7
|
+
slice!(0..(str.length - 1)) if start_with?(str)
|
8
|
+
self
|
9
|
+
end
|
10
|
+
|
11
|
+
def delete_suffix!(str)
|
12
|
+
slice!(-str.length..-1) if end_with?(str)
|
13
|
+
self
|
14
|
+
end
|
15
|
+
|
16
|
+
def delete_prefix(str)
|
17
|
+
dup.delete_prefix!(str)
|
18
|
+
end
|
19
|
+
|
20
|
+
def delete_suffix(str)
|
21
|
+
dup.delete_suffix!(str)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/fast_ignore/rule.rb
CHANGED
data/lib/fast_ignore/version.rb
CHANGED
data/lib/fast_ignore.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative './fast_ignore/delete_prefix_suffix'
|
3
4
|
require_relative './fast_ignore/rule'
|
4
5
|
require_relative './fast_ignore/rule_list'
|
5
6
|
require_relative './fast_ignore/file_rule_list'
|
@@ -9,6 +10,7 @@ require 'find'
|
|
9
10
|
|
10
11
|
class FastIgnore
|
11
12
|
include Enumerable
|
13
|
+
using DeletePrefixSuffix unless RUBY_VERSION >= '2.5'
|
12
14
|
|
13
15
|
attr_reader :rules
|
14
16
|
attr_reader :relative
|
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.
|
4
|
+
version: 0.3.0
|
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-
|
11
|
+
date: 2019-08-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -104,7 +104,6 @@ files:
|
|
104
104
|
- ".gitignore"
|
105
105
|
- ".rspec"
|
106
106
|
- ".rubocop.yml"
|
107
|
-
- ".ruby-version"
|
108
107
|
- ".travis.yml"
|
109
108
|
- CHANGELOG.md
|
110
109
|
- Gemfile
|
@@ -116,6 +115,7 @@ files:
|
|
116
115
|
- bin/setup
|
117
116
|
- fast_ignore.gemspec
|
118
117
|
- lib/fast_ignore.rb
|
118
|
+
- lib/fast_ignore/delete_prefix_suffix.rb
|
119
119
|
- lib/fast_ignore/file_rule_list.rb
|
120
120
|
- lib/fast_ignore/gitignore_rule_list.rb
|
121
121
|
- lib/fast_ignore/rule.rb
|
@@ -143,8 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
143
143
|
- !ruby/object:Gem::Version
|
144
144
|
version: '0'
|
145
145
|
requirements: []
|
146
|
-
|
147
|
-
rubygems_version: 2.7.6
|
146
|
+
rubygems_version: 3.0.3
|
148
147
|
signing_key:
|
149
148
|
specification_version: 4
|
150
149
|
summary: Parse gitignore files, quickly
|
data/.ruby-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
2.5.1
|