fast_ignore 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a4c51ea85828e7c8659e7e67c6b4f72a577e463439412da55842d2ccdc8cb2be
4
- data.tar.gz: c9cfdfcfa66b2df5b927ce0a53f094cf72c1a9db33f09cf992e7d1337fc9a37a
3
+ metadata.gz: '078431fdfb48356146694f1fffba57803f876a1b67f52c6b8180ec5f9efe2f30'
4
+ data.tar.gz: 4c9e880bf30a6656382a7437b97847be095c4e4f77276979a52e11e421905cb6
5
5
  SHA512:
6
- metadata.gz: f25671f6eff33fdd7a56cdda01941413b0de30fa35eca7aee5f495414335fb5b48eff2ed67c19a7c2638483c7e7ba10069e42e41ae099da577af9772b3c66680
7
- data.tar.gz: 6b64940f041f0ce7edeb913ea01d030f92925fdae4ad454e4ca84ccd373e02779ac2b234d2645a9bab823547a9775c1f41547001077557c90fa33d83b5dc7a0c
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/FirstParameterIndentation:
72
+ Layout/IndentFirstArgument:
72
73
  EnforcedStyle: consistent
73
74
 
74
75
  # to match our preference for consistent indentation
75
- Layout/IndentArray:
76
+ Layout/IndentFirstArrayElement:
76
77
  EnforcedStyle: consistent
77
78
 
78
79
  # to match our preference for consistent indentation
79
- Layout/IndentHash:
80
+ Layout/IndentFirstHashElement:
80
81
  EnforcedStyle: consistent
81
82
 
82
83
  # to match our preference for consistent indentation
data/.travis.yml CHANGED
@@ -3,5 +3,8 @@ sudo: false
3
3
  language: ruby
4
4
  cache: bundler
5
5
  rvm:
6
- - 2.5.1
6
+ - 2.3
7
+ - 2.4
8
+ - 2.5
9
+ - 2.6
7
10
  before_install: gem install bundler -v 1.17.3
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ # v0.3.0
2
+ - Supports 2.3 - 2.6
3
+
1
4
  # v0.2.0
2
5
  - Considers rules relative to the location of the gitignore file instead of just relative to PWD
3
6
  - Can override the path to the gitignore file, using `FastIgnore.new(gitignore: path)`
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fast_ignore (0.2.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.2)
12
+ jaro_winkler (1.5.3)
13
13
  method_source (0.9.2)
14
- parallel (1.15.0)
15
- parser (2.6.2.0)
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.0)
26
+ rspec-core (3.8.2)
28
27
  rspec-support (~> 3.8.0)
29
- rspec-expectations (3.8.2)
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.0)
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.0)
36
- rubocop (0.66.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.5, != 2.5.1.1)
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.6)
44
- rubocop-rspec (1.32.0)
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.0)
47
- unicode-display_width (1.5.0)
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.1
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. Follows all the gitignore formatting rules including `!dir` and `/dir`
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
- $ bundle
18
-
19
+ ```sh
20
+ $ bundle
21
+ ```
19
22
  Or install it yourself as:
20
-
21
- $ gem install fast_ignore
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.new.each can return an enumerator
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/TODOs
68
- - Doesn't take into account ignored project excludes in `.git/info/exclude`
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
@@ -2,6 +2,8 @@
2
2
 
3
3
  class FastIgnore
4
4
  class Rule
5
+ using DeletePrefixSuffix unless RUBY_VERSION >= '2.5'
6
+
5
7
  def initialize(rule, root: Dir.pwd)
6
8
  @root = root
7
9
  @rule = rule
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class FastIgnore
4
- VERSION = '0.2.0'
4
+ VERSION = '0.3.0'
5
5
  end
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.2.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-04-07 00:00:00.000000000 Z
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
- rubyforge_project:
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