pathspec 0.2.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -6
- data/bin/pathspec-rb +16 -29
- data/docs/html/pathspec-rb.html +82 -0
- data/docs/man/pathspec-rb.man.1 +67 -0
- data/docs/pathspec-rb.md +64 -0
- data/lib/pathspec.rb +4 -3
- data/lib/pathspec/gitignorespec.rb +14 -17
- data/lib/pathspec/regexspec.rb +1 -1
- data/lib/pathspec/spec.rb +1 -2
- data/spec/unit/pathspec_spec.rb +4 -3
- metadata +36 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 959defcb28199d86bb69d1b7854937c677e37dc71521f44693a42411897acf01
|
4
|
+
data.tar.gz: dfa517e7b72d5aede4eb9daf642fda9266c1f82454bed03b3b776934f5c56c95
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b1824b7ce0c951017a51d501f5e18299d1fa0400ca0c6db54b9b774c4aa08a3587504d98cd578b99296cf34aad2e07593292563014a0fcc09f72697194b1327c
|
7
|
+
data.tar.gz: 96ab89b84afdc3f69b24f0f84bd5740c2ebee3048246ca5d482bc3f24f08dbda542b03f3a6efb02d33d6cdd225646e1ef2cadaa43be3d1069f1912cfa4f99da1
|
data/README.md
CHANGED
@@ -1,13 +1,12 @@
|
|
1
|
-
pathspec-ruby
|
2
|
-
=============
|
1
|
+
# pathspec-ruby
|
3
2
|
|
4
3
|
[![Gem Version](https://badge.fury.io/rb/pathspec.svg)](https://badge.fury.io/rb/pathspec) [![Build Status](https://travis-ci.org/highb/pathspec-ruby.svg?branch=master)](https://travis-ci.org/highb/pathspec-ruby) [![Maintainability](https://api.codeclimate.com/v1/badges/4f3b5917e01fb34f790d/maintainability)](https://codeclimate.com/github/highb/pathspec-ruby/maintainability)
|
5
4
|
|
6
5
|
[Supported Rubies](https://www.ruby-lang.org/en/downloads/):
|
7
|
-
|
8
|
-
- 2.
|
9
|
-
- 2.
|
10
|
-
- 2.
|
6
|
+
|
7
|
+
- 2.4.6 (Maintenance)
|
8
|
+
- 2.5.6 (Stable)
|
9
|
+
- 2.6.4 (Stable)
|
11
10
|
|
12
11
|
Match Path Specifications, such as .gitignore, in Ruby!
|
13
12
|
|
@@ -16,11 +15,13 @@ Follows .gitignore syntax defined on [gitscm](http://git-scm.com/docs/gitignore)
|
|
16
15
|
.gitignore functionality ported from [Python pathspec](https://pypi.python.org/pypi/pathspec/0.2.2) by [@cpburnz](https://github.com/cpburnz/python-path-specification)
|
17
16
|
|
18
17
|
## Build/Install from Rubygems
|
18
|
+
|
19
19
|
```shell
|
20
20
|
gem install pathspec
|
21
21
|
```
|
22
22
|
|
23
23
|
## CLI Usage
|
24
|
+
|
24
25
|
```bash
|
25
26
|
➜ test-pathspec cat .gitignore
|
26
27
|
*.swp
|
@@ -41,6 +42,7 @@ Gemfile Gemfile.lock coverage file.swp source.rb
|
|
41
42
|
```
|
42
43
|
|
43
44
|
## Usage
|
45
|
+
|
44
46
|
```ruby
|
45
47
|
require 'pathspec'
|
46
48
|
|
@@ -74,10 +76,12 @@ gitignore.match_paths ['/abc/123', '/abc/important.txt', '/abc/']
|
|
74
76
|
```
|
75
77
|
|
76
78
|
## Building/Installing from Source
|
79
|
+
|
77
80
|
```shell
|
78
81
|
git clone git@github.com:highb/pathspec-ruby.git
|
79
82
|
cd pathspec-ruby && bash ./build_from_source.sh
|
80
83
|
```
|
81
84
|
|
82
85
|
## Contributing
|
86
|
+
|
83
87
|
Pull requests, bug reports, and feature requests welcome! :smile: I've tried to write exhaustive tests but who knows what cases I've missed.
|
data/bin/pathspec-rb
CHANGED
@@ -1,26 +1,25 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
require 'optionparser'
|
4
5
|
require 'pathspec'
|
5
|
-
options = {
|
6
|
+
options = {
|
6
7
|
spec_type: :git,
|
7
8
|
spec_filename: '.gitignore'
|
8
9
|
}
|
9
10
|
|
10
11
|
optparser = OptionParser.new do |opts|
|
11
|
-
opts.banner =
|
12
|
+
opts.banner = 'Usage: pathspec-rb [options] [subcommand] [path]
|
12
13
|
Subcommands:
|
13
14
|
specs_match: Finds all specs matching path.
|
14
15
|
tree: Finds all files under path matching the spec.
|
15
16
|
match: Checks if the path matches any spec.
|
16
|
-
|
17
17
|
EXIT STATUS:
|
18
18
|
0 Matches found.
|
19
19
|
1 No matches found.
|
20
20
|
>1 An error occured.
|
21
|
-
|
22
|
-
|
23
|
-
opts.on('-f', '--file FILENAME', String,
|
21
|
+
'
|
22
|
+
opts.on('-f', '--file FILENAME', String,
|
24
23
|
'A spec file to load. Default: .gitignore') do |filename|
|
25
24
|
unless File.readable?(filename)
|
26
25
|
puts "Error: I couldn't read #{filename}"
|
@@ -33,12 +32,12 @@ EXIT STATUS:
|
|
33
32
|
'Spec file type in FILENAME. Default: git. Available: git and regex.') do |type|
|
34
33
|
options[:spec_type] = type
|
35
34
|
end
|
36
|
-
opts.on('-v', '--verbose', 'Only output if there are matches.') do |
|
35
|
+
opts.on('-v', '--verbose', 'Only output if there are matches.') do |_verbose|
|
37
36
|
options[:verbose] = true
|
38
37
|
end
|
39
38
|
end
|
40
39
|
|
41
|
-
|
40
|
+
optparser.parse!
|
42
41
|
|
43
42
|
command = ARGV[0]
|
44
43
|
path = ARGV[1]
|
@@ -51,39 +50,27 @@ end
|
|
51
50
|
|
52
51
|
case command
|
53
52
|
when 'specs_match'
|
54
|
-
if spec.match(path)
|
55
|
-
if options[:verbose]
|
56
|
-
puts "#{path} matches the following specs from #{options[:spec_filename]}:"
|
57
|
-
end
|
53
|
+
if spec.match?(path)
|
54
|
+
puts "#{path} matches the following specs from #{options[:spec_filename]}:" if options[:verbose]
|
58
55
|
puts spec.specs_matching(path)
|
59
56
|
else
|
60
|
-
if options[:verbose]
|
61
|
-
puts "#{path} does not match any specs from #{options[:spec_filename]}"
|
62
|
-
end
|
57
|
+
puts "#{path} does not match any specs from #{options[:spec_filename]}" if options[:verbose]
|
63
58
|
exit 1
|
64
59
|
end
|
65
60
|
when 'tree'
|
66
61
|
tree_matches = spec.match_tree(path)
|
67
|
-
if tree_matches.
|
68
|
-
if options[:verbose]
|
69
|
-
puts "Files in #{path} that match #{options[:spec_filename]}"
|
70
|
-
end
|
62
|
+
if tree_matches.any?
|
63
|
+
puts "Files in #{path} that match #{options[:spec_filename]}" if options[:verbose]
|
71
64
|
puts tree_matches
|
72
65
|
else
|
73
|
-
if options[:verbose]
|
74
|
-
puts "No file in #{path} matched #{options[:spec_filename]}"
|
75
|
-
end
|
66
|
+
puts "No file in #{path} matched #{options[:spec_filename]}" if options[:verbose]
|
76
67
|
exit 1
|
77
68
|
end
|
78
69
|
when 'match', ''
|
79
|
-
if spec.match(path)
|
80
|
-
if options[:verbose]
|
81
|
-
puts "#{path} matches a spec in #{options[:spec_filename]}"
|
82
|
-
end
|
70
|
+
if spec.match?(path)
|
71
|
+
puts "#{path} matches a spec in #{options[:spec_filename]}" if options[:verbose]
|
83
72
|
else
|
84
|
-
if options[:verbose]
|
85
|
-
puts "#{path} does not match any specs in #{options[:spec_filename]}"
|
86
|
-
end
|
73
|
+
puts "#{path} does not match any specs in #{options[:spec_filename]}" if options[:verbose]
|
87
74
|
exit 1
|
88
75
|
end
|
89
76
|
else
|
@@ -0,0 +1,82 @@
|
|
1
|
+
<h1 id="pathspec-rb1">pathspec-rb(1)</h1>
|
2
|
+
|
3
|
+
<h2 data-date="2020/01/04" id="name">NAME</h2>
|
4
|
+
|
5
|
+
<p>pathspec - Test pathspecs against a specific path</p>
|
6
|
+
|
7
|
+
<h2 id="synopsis">SYNOPSIS</h2>
|
8
|
+
|
9
|
+
<p><code>pathspec-rb</code> [<code>OPTIONS</code>] [<code>SUBCOMMAND</code>] [<code>PATH</code>] NAME PATH</p>
|
10
|
+
|
11
|
+
<h2 id="description">DESCRIPTION</h2>
|
12
|
+
|
13
|
+
<p><code>pathspc-rb</code> is a tool that accompanies the pathspec-ruby library to help
|
14
|
+
you test what match results the library would find using path specs. You can
|
15
|
+
either find all specs matching a path, find all files matching specs, or
|
16
|
+
verify that a path would match any spec.</p>
|
17
|
+
|
18
|
+
<p>https://github.com/highb/pathspec-ruby</p>
|
19
|
+
|
20
|
+
<h2 id="sub-commands">SUB-COMMANDS</h2>
|
21
|
+
|
22
|
+
<table>
|
23
|
+
<thead>
|
24
|
+
<tr>
|
25
|
+
<th>Name</th>
|
26
|
+
<th>Description</th>
|
27
|
+
</tr>
|
28
|
+
</thead>
|
29
|
+
<tbody>
|
30
|
+
<tr>
|
31
|
+
<td><em>specs_match</em></td>
|
32
|
+
<td>Find all specs matching path</td>
|
33
|
+
</tr>
|
34
|
+
</tbody>
|
35
|
+
<tbody>
|
36
|
+
<tr>
|
37
|
+
<td><em>tree</em></td>
|
38
|
+
<td>Find all files under path matching the spec</td>
|
39
|
+
</tr>
|
40
|
+
</tbody>
|
41
|
+
<tbody>
|
42
|
+
<tr>
|
43
|
+
<td><em>match</em></td>
|
44
|
+
<td>Check if the path matches any spec</td>
|
45
|
+
</tr>
|
46
|
+
</tbody>
|
47
|
+
</table>
|
48
|
+
|
49
|
+
<h2 id="options">OPTIONS</h2>
|
50
|
+
|
51
|
+
<dl>
|
52
|
+
<dt><code>-f <FILENAME></code>, <code>--file <FILENAME></code></dt>
|
53
|
+
<dd>Load path specs from the file passed in as argument. If this option is not specified, <code>pathspec-rb</code> defaults to loading <code>.gitignore</code>.</dd>
|
54
|
+
<dt><code>-t [git|regex]</code>, <code>--type [git|regex]</code></dt>
|
55
|
+
<dd>Type of spec expected in the loaded specs file (see <code>-f</code> option). Defaults to <code>git</code>.</dd>
|
56
|
+
<dt><code>-v</code>, <code>--verbose</code></dt>
|
57
|
+
<dd>Only output if there are matches.</dd>
|
58
|
+
</dl>
|
59
|
+
|
60
|
+
<h2 id="example">EXAMPLE</h2>
|
61
|
+
|
62
|
+
<p>Find all files ignored by git under your source directory:</p>
|
63
|
+
|
64
|
+
<pre><code> $ pathspec-rb tree src/
|
65
|
+
</code></pre>
|
66
|
+
|
67
|
+
<p>List all spec rules that would match for the specified path:</p>
|
68
|
+
|
69
|
+
<pre><code> $ pathspec-rb specs_match build/
|
70
|
+
</code></pre>
|
71
|
+
|
72
|
+
<p>Check that a path matches at least one of the specs in a new version of a
|
73
|
+
gitignore file:</p>
|
74
|
+
|
75
|
+
<pre><code> $ pathspec-rb match -f .gitignore.new spec/fixtures/
|
76
|
+
</code></pre>
|
77
|
+
|
78
|
+
<h2 id="author">AUTHOR</h2>
|
79
|
+
|
80
|
+
<p>Brandon High highb@users.noreply.github.com</p>
|
81
|
+
|
82
|
+
<p>Gabriel Filion</p>
|
@@ -0,0 +1,67 @@
|
|
1
|
+
.\" generated by kramdown
|
2
|
+
.TH "PATHSPEC\-RB" "1"
|
3
|
+
.SH "NAME"
|
4
|
+
pathspec \- Test pathspecs against a specific path
|
5
|
+
.SH "SYNOPSIS"
|
6
|
+
\fBpathspec\-rb\fP [\fBOPTIONS\fP] [\fBSUBCOMMAND\fP] [\fBPATH\fP] NAME PATH
|
7
|
+
.SH "DESCRIPTION"
|
8
|
+
\fBpathspc\-rb\fP is a tool that accompanies the pathspec\-ruby library to help you test what match results the library would find using path specs\. You can either find all specs matching a path, find all files matching specs, or verify that a path would match any spec\.
|
9
|
+
.P
|
10
|
+
https://github\.com/highb/pathspec\-ruby
|
11
|
+
.SH "SUB\-COMMANDS"
|
12
|
+
.TS
|
13
|
+
box ;
|
14
|
+
lb lb .
|
15
|
+
Name Description
|
16
|
+
=
|
17
|
+
.T&
|
18
|
+
l l .
|
19
|
+
\fIspecs_match\fP Find all specs matching path
|
20
|
+
_
|
21
|
+
.T&
|
22
|
+
l l .
|
23
|
+
\fItree\fP Find all files under path matching the spec
|
24
|
+
_
|
25
|
+
.T&
|
26
|
+
l l .
|
27
|
+
\fImatch\fP Check if the path matches any spec
|
28
|
+
.TE
|
29
|
+
.sp
|
30
|
+
.SH "OPTIONS"
|
31
|
+
.TP
|
32
|
+
\fB\-f <FILENAME>\fP, \fB\-\-file <FILENAME>\fP
|
33
|
+
Load path specs from the file passed in as argument\. If this option is not specified, \fBpathspec\-rb\fP defaults to loading \fB\&\.gitignore\fP\&\.
|
34
|
+
.TP
|
35
|
+
\fB\-t [git|regex]\fP, \fB\-\-type [git|regex]\fP
|
36
|
+
Type of spec expected in the loaded specs file (see \fB\-f\fP option)\. Defaults to \fBgit\fP\&\.
|
37
|
+
.TP
|
38
|
+
\fB\-v\fP, \fB\-\-verbose\fP
|
39
|
+
Only output if there are matches\.
|
40
|
+
.SH "EXAMPLE"
|
41
|
+
Find all files ignored by git under your source directory:
|
42
|
+
.sp
|
43
|
+
.RS 4
|
44
|
+
.EX
|
45
|
+
$ pathspec\-rb tree src/
|
46
|
+
.EE
|
47
|
+
.RE
|
48
|
+
.P
|
49
|
+
List all spec rules that would match for the specified path:
|
50
|
+
.sp
|
51
|
+
.RS 4
|
52
|
+
.EX
|
53
|
+
$ pathspec\-rb specs_match build/
|
54
|
+
.EE
|
55
|
+
.RE
|
56
|
+
.P
|
57
|
+
Check that a path matches at least one of the specs in a new version of a gitignore file:
|
58
|
+
.sp
|
59
|
+
.RS 4
|
60
|
+
.EX
|
61
|
+
$ pathspec\-rb match \-f \.gitignore\.new spec/fixtures/
|
62
|
+
.EE
|
63
|
+
.RE
|
64
|
+
.SH "AUTHOR"
|
65
|
+
Brandon High highb@users\.noreply\.github\.com
|
66
|
+
.P
|
67
|
+
Gabriel Filion
|
data/docs/pathspec-rb.md
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
# pathspec-rb(1)
|
2
|
+
|
3
|
+
{:data-date="2020/01/04"}
|
4
|
+
|
5
|
+
## NAME
|
6
|
+
|
7
|
+
pathspec - Test pathspecs against a specific path
|
8
|
+
|
9
|
+
## SYNOPSIS
|
10
|
+
|
11
|
+
`pathspec-rb` [`OPTIONS`] [`SUBCOMMAND`] [`PATH`] NAME PATH
|
12
|
+
|
13
|
+
## DESCRIPTION
|
14
|
+
|
15
|
+
`pathspc-rb` is a tool that accompanies the pathspec-ruby library to help
|
16
|
+
you test what match results the library would find using path specs. You can
|
17
|
+
either find all specs matching a path, find all files matching specs, or
|
18
|
+
verify that a path would match any spec.
|
19
|
+
|
20
|
+
https://github.com/highb/pathspec-ruby
|
21
|
+
|
22
|
+
## SUB-COMMANDS
|
23
|
+
|
24
|
+
|-
|
25
|
+
| Name | Description
|
26
|
+
|-
|
27
|
+
| *specs_match* | Find all specs matching path
|
28
|
+
|-
|
29
|
+
| *tree* | Find all files under path matching the spec
|
30
|
+
|-
|
31
|
+
| *match* | Check if the path matches any spec
|
32
|
+
|-
|
33
|
+
|
34
|
+
## OPTIONS
|
35
|
+
|
36
|
+
`-f <FILENAME>`, `--file <FILENAME>`
|
37
|
+
: Load path specs from the file passed in as argument. If this option is not specified, `pathspec-rb` defaults to loading `.gitignore`.
|
38
|
+
|
39
|
+
`-t [git|regex]`, `--type [git|regex]`
|
40
|
+
: Type of spec expected in the loaded specs file (see `-f` option). Defaults to `git`.
|
41
|
+
|
42
|
+
`-v`, `--verbose`
|
43
|
+
: Only output if there are matches.
|
44
|
+
|
45
|
+
## EXAMPLE
|
46
|
+
|
47
|
+
Find all files ignored by git under your source directory:
|
48
|
+
|
49
|
+
$ pathspec-rb tree src/
|
50
|
+
|
51
|
+
List all spec rules that would match for the specified path:
|
52
|
+
|
53
|
+
$ pathspec-rb specs_match build/
|
54
|
+
|
55
|
+
Check that a path matches at least one of the specs in a new version of a
|
56
|
+
gitignore file:
|
57
|
+
|
58
|
+
$ pathspec-rb match -f .gitignore.new spec/fixtures/
|
59
|
+
|
60
|
+
## AUTHOR
|
61
|
+
|
62
|
+
Brandon High highb@users.noreply.github.com
|
63
|
+
|
64
|
+
Gabriel Filion
|
data/lib/pathspec.rb
CHANGED
@@ -63,7 +63,7 @@ class PathSpec
|
|
63
63
|
end
|
64
64
|
|
65
65
|
def drive_letter_to_path(path)
|
66
|
-
path.gsub(%r{^([a-zA-Z])
|
66
|
+
path.gsub(%r{^([a-zA-Z]):/}, '/\1/')
|
67
67
|
end
|
68
68
|
|
69
69
|
# Generate specs from a filename, such as a .gitignore
|
@@ -101,9 +101,10 @@ class PathSpec
|
|
101
101
|
end
|
102
102
|
|
103
103
|
def spec_type(type)
|
104
|
-
|
104
|
+
case type
|
105
|
+
when :git
|
105
106
|
GitIgnoreSpec
|
106
|
-
|
107
|
+
when :regex
|
107
108
|
RegexSpec
|
108
109
|
else
|
109
110
|
raise "Unknown spec type #{type}"
|
@@ -3,10 +3,9 @@ require 'pathspec/regexspec'
|
|
3
3
|
class PathSpec
|
4
4
|
# Class for parsing a .gitignore spec
|
5
5
|
class GitIgnoreSpec < RegexSpec
|
6
|
-
attr_reader :regex
|
7
|
-
attr_reader :pattern
|
6
|
+
attr_reader :regex, :pattern
|
8
7
|
|
9
|
-
def initialize(original_pattern)
|
8
|
+
def initialize(original_pattern) # rubocop:disable Metrics/CyclomaticComplexity
|
10
9
|
pattern = original_pattern.strip unless original_pattern.nil?
|
11
10
|
|
12
11
|
# A pattern starting with a hash ('#') serves as a comment
|
@@ -18,19 +17,19 @@ class PathSpec
|
|
18
17
|
|
19
18
|
# A blank pattern is a null-operation (neither includes nor
|
20
19
|
# excludes files).
|
21
|
-
elsif pattern.empty?
|
20
|
+
elsif pattern.empty? # rubocop:disable Lint/DuplicateBranch
|
22
21
|
@regex = nil
|
23
22
|
@inclusive = nil
|
24
23
|
|
25
24
|
# Patterns containing three or more consecutive stars are invalid and
|
26
25
|
# will be ignored.
|
27
|
-
elsif pattern
|
26
|
+
elsif /\*\*\*+/.match?(pattern) # rubocop:disable Lint/DuplicateBranch
|
28
27
|
@regex = nil
|
29
28
|
@inclusive = nil
|
30
29
|
|
31
30
|
# EDGE CASE: According to git check-ignore (v2.4.1)), a single '/'
|
32
31
|
# does not match any file
|
33
|
-
elsif pattern == '/'
|
32
|
+
elsif pattern == '/' # rubocop:disable Lint/DuplicateBranch
|
34
33
|
@regex = nil
|
35
34
|
@inclusive = nil
|
36
35
|
|
@@ -43,14 +42,14 @@ class PathSpec
|
|
43
42
|
if pattern.start_with?('!')
|
44
43
|
@inclusive = false
|
45
44
|
# Remove leading exclamation mark.
|
46
|
-
pattern = pattern[1
|
45
|
+
pattern = pattern[1..]
|
47
46
|
else
|
48
47
|
@inclusive = true
|
49
48
|
end
|
50
49
|
|
51
50
|
# Remove leading back-slash escape for escaped hash ('#') or
|
52
51
|
# exclamation mark ('!').
|
53
|
-
pattern = pattern[1
|
52
|
+
pattern = pattern[1..] if pattern.start_with?('\\')
|
54
53
|
|
55
54
|
# Split pattern into segments. -1 to allow trailing slashes.
|
56
55
|
pattern_segs = pattern.split('/', -1)
|
@@ -94,7 +93,8 @@ class PathSpec
|
|
94
93
|
pattern_segs.each_index do |i|
|
95
94
|
seg = pattern_segs[i]
|
96
95
|
|
97
|
-
|
96
|
+
case seg
|
97
|
+
when '**'
|
98
98
|
# A pattern consisting solely of double-asterisks ('**')
|
99
99
|
# will match every path.
|
100
100
|
if i == 0 && i == regex_end
|
@@ -119,7 +119,7 @@ class PathSpec
|
|
119
119
|
end
|
120
120
|
|
121
121
|
# Match single path segment.
|
122
|
-
|
122
|
+
when '*'
|
123
123
|
regex.concat(path_sep) if need_slash
|
124
124
|
|
125
125
|
regex.concat("[^#{path_sep}]+")
|
@@ -146,16 +146,12 @@ class PathSpec
|
|
146
146
|
|
147
147
|
regex.concat('$')
|
148
148
|
super(regex)
|
149
|
-
|
149
|
+
|
150
150
|
# Copy original pattern
|
151
151
|
@pattern = original_pattern.dup
|
152
152
|
end
|
153
153
|
end
|
154
154
|
|
155
|
-
def match(path)
|
156
|
-
super(path)
|
157
|
-
end
|
158
|
-
|
159
155
|
def translate_segment_glob(pattern)
|
160
156
|
''"
|
161
157
|
Translates the glob pattern to a regular expression. This is used in
|
@@ -220,7 +216,8 @@ class PathSpec
|
|
220
216
|
expr = '['
|
221
217
|
|
222
218
|
# Braket expression needs to be negated.
|
223
|
-
|
219
|
+
case pattern[i].chr
|
220
|
+
when '!'
|
224
221
|
expr += '^'
|
225
222
|
i += 1
|
226
223
|
|
@@ -229,7 +226,7 @@ class PathSpec
|
|
229
226
|
# `fnmatch.translate()` escapes the caret ('^') as a
|
230
227
|
# literal. To maintain consistency with undefined behavior,
|
231
228
|
# I am escaping the '^' as well.
|
232
|
-
|
229
|
+
when '^'
|
233
230
|
expr += '\\^'
|
234
231
|
i += 1
|
235
232
|
end
|
data/lib/pathspec/regexspec.rb
CHANGED
data/lib/pathspec/spec.rb
CHANGED
data/spec/unit/pathspec_spec.rb
CHANGED
@@ -20,9 +20,10 @@ describe PathSpec do
|
|
20
20
|
it { is_expected.to match('abc/def.rb') }
|
21
21
|
it { is_expected.not_to match('abc/important.txt') }
|
22
22
|
it do
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
expect(subject.match_paths(['/abc/123', '/abc/important.txt', '/abc/'])).to contain_exactly(
|
24
|
+
'/abc/123',
|
25
|
+
'/abc/'
|
26
|
+
)
|
26
27
|
end
|
27
28
|
end
|
28
29
|
|
metadata
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pathspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon High
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
date: 2018-01-11 00:00:00.000000000 Z
|
@@ -16,86 +16,100 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '2.2'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '2.2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: fakefs
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '1.3'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: kramdown
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.3'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rake
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
59
|
- - "~>"
|
46
60
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
61
|
+
version: '13.0'
|
48
62
|
type: :development
|
49
63
|
prerelease: false
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
66
|
- - "~>"
|
53
67
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
68
|
+
version: '13.0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: rspec
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
73
|
- - "~>"
|
60
74
|
- !ruby/object:Gem::Version
|
61
|
-
version: '3.
|
75
|
+
version: '3.10'
|
62
76
|
type: :development
|
63
77
|
prerelease: false
|
64
78
|
version_requirements: !ruby/object:Gem::Requirement
|
65
79
|
requirements:
|
66
80
|
- - "~>"
|
67
81
|
- !ruby/object:Gem::Version
|
68
|
-
version: '3.
|
82
|
+
version: '3.10'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: rubocop
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
72
86
|
requirements:
|
73
87
|
- - "~>"
|
74
88
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
89
|
+
version: '1.7'
|
76
90
|
type: :development
|
77
91
|
prerelease: false
|
78
92
|
version_requirements: !ruby/object:Gem::Requirement
|
79
93
|
requirements:
|
80
94
|
- - "~>"
|
81
95
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
96
|
+
version: '1.7'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: simplecov
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
86
100
|
requirements:
|
87
101
|
- - "~>"
|
88
102
|
- !ruby/object:Gem::Version
|
89
|
-
version: '0.
|
103
|
+
version: '0.21'
|
90
104
|
type: :development
|
91
105
|
prerelease: false
|
92
106
|
version_requirements: !ruby/object:Gem::Requirement
|
93
107
|
requirements:
|
94
108
|
- - "~>"
|
95
109
|
- !ruby/object:Gem::Version
|
96
|
-
version: '0.
|
110
|
+
version: '0.21'
|
97
111
|
description: Use to match path patterns such as gitignore
|
98
|
-
email:
|
112
|
+
email: highb@users.noreply.github.com
|
99
113
|
executables:
|
100
114
|
- pathspec-rb
|
101
115
|
extensions: []
|
@@ -105,6 +119,9 @@ files:
|
|
105
119
|
- LICENSE
|
106
120
|
- README.md
|
107
121
|
- bin/pathspec-rb
|
122
|
+
- docs/html/pathspec-rb.html
|
123
|
+
- docs/man/pathspec-rb.man.1
|
124
|
+
- docs/pathspec-rb.md
|
108
125
|
- lib/pathspec.rb
|
109
126
|
- lib/pathspec/gitignorespec.rb
|
110
127
|
- lib/pathspec/regexspec.rb
|
@@ -121,7 +138,7 @@ homepage: https://github.com/highb/pathspec-ruby
|
|
121
138
|
licenses:
|
122
139
|
- Apache-2.0
|
123
140
|
metadata: {}
|
124
|
-
post_install_message:
|
141
|
+
post_install_message:
|
125
142
|
rdoc_options: []
|
126
143
|
require_paths:
|
127
144
|
- lib
|
@@ -129,16 +146,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
129
146
|
requirements:
|
130
147
|
- - ">="
|
131
148
|
- !ruby/object:Gem::Version
|
132
|
-
version:
|
149
|
+
version: 2.6.0
|
133
150
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
134
151
|
requirements:
|
135
152
|
- - ">="
|
136
153
|
- !ruby/object:Gem::Version
|
137
154
|
version: '0'
|
138
155
|
requirements: []
|
139
|
-
|
140
|
-
|
141
|
-
signing_key:
|
156
|
+
rubygems_version: 3.1.4
|
157
|
+
signing_key:
|
142
158
|
specification_version: 4
|
143
159
|
summary: 'PathSpec: for matching path patterns'
|
144
160
|
test_files:
|