pathspec 0.1.2 → 1.1.3

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.
@@ -4,30 +4,48 @@ require 'pathspec'
4
4
  require 'fakefs/spec_helpers'
5
5
 
6
6
  describe PathSpec do
7
- shared_examples "standard gitignore negation" do
8
- it { is_expected.to_not match('important.txt') }
9
- it { is_expected.to_not match('foo/important.txt') }
10
- it { is_expected.to match('foo/bar/') }
7
+ shared_examples 'standard gitignore negation' do
8
+ it { is_expected.not_to match('important.txt') }
9
+ it { is_expected.not_to match('abc/important.txt') }
10
+ it { is_expected.to match('bar/baz/') }
11
+ it { is_expected.to match('foo/file') }
12
+ it { is_expected.not_to match('foo/important.txt') }
13
+ it { is_expected.to match('foo/subdir/file') }
11
14
  end
12
15
 
13
- context "initialization" do
14
- context "from multilines" do
15
- context "#new" do
16
- subject { PathSpec.new <<-IGNORELINES
16
+ # Specs that should be kept up to date with the README
17
+ context 'README.md' do
18
+ subject { PathSpec.from_filename 'spec/files/gitignore_readme' }
19
+
20
+ it { is_expected.to match('abc/def.rb') }
21
+ it { is_expected.not_to match('abc/important.txt') }
22
+ it do
23
+ expect(subject.match_paths(['/abc/123', '/abc/important.txt', '/abc/'])).to contain_exactly(
24
+ '/abc/123',
25
+ '/abc/'
26
+ )
27
+ end
28
+ end
29
+
30
+ context 'initialization' do
31
+ context 'from multilines' do
32
+ context '#new' do
33
+ subject {
34
+ PathSpec.new <<-IGNORELINES
17
35
  !important.txt
18
36
  foo/**
19
37
  /bar/baz
20
38
  IGNORELINES
21
39
  }
22
40
 
23
- it_behaves_like "standard gitignore negation"
41
+ it_behaves_like 'standard gitignore negation'
24
42
  end
25
43
  end
26
44
 
27
- context "from a string with no newlines" do
28
- let(:str) { "foo/**" }
45
+ context 'from a string with no newlines' do
46
+ let(:str) { 'foo/**' }
29
47
 
30
- context "#new" do
48
+ context '#new' do
31
49
  subject { PathSpec.new str }
32
50
 
33
51
  it { is_expected.to match('foo/important.txt') }
@@ -35,67 +53,67 @@ IGNORELINES
35
53
  end
36
54
  end
37
55
 
38
- context "from a non-string/non-enumerable" do
39
- it "throws an exception" do
40
- expect { PathSpec.new Object.new }.to raise_error
56
+ context 'from a non-string/non-enumerable' do
57
+ it 'throws an exception' do
58
+ expect { PathSpec.new Object.new }.to raise_error(/Cannot make Pathspec/)
41
59
  end
42
60
  end
43
61
 
44
- context "from array of gitignore strings" do
45
- let(:arr) { ["!important.txt", "foo/**", "/bar/baz"] }
62
+ context 'from array of gitignore strings' do
63
+ let(:arr) { ['!important.txt', 'foo/**', '/bar/baz'] }
46
64
 
47
- context "#new" do
65
+ context '#new' do
48
66
  subject { PathSpec.new arr }
49
67
 
50
- it_behaves_like "standard gitignore negation"
68
+ it_behaves_like 'standard gitignore negation'
51
69
  end
52
70
 
53
- context "#from_lines" do
71
+ context '#from_lines' do
54
72
  subject {
55
73
  PathSpec.from_lines(arr)
56
74
  }
57
75
 
58
- it_behaves_like "standard gitignore negation"
76
+ it_behaves_like 'standard gitignore negation'
59
77
  end
60
78
 
61
- context "#add array" do
79
+ context '#add array' do
62
80
  subject {
63
81
  ps = PathSpec.new []
64
82
  ps.add arr
65
83
  }
66
84
 
67
- it_behaves_like "standard gitignore negation"
85
+ it_behaves_like 'standard gitignore negation'
68
86
  end
69
87
  end
70
88
 
71
- context "from linedelimited gitignore string" do
89
+ context 'from linedelimited gitignore string' do
72
90
  let(:line) { "!important.txt\nfoo/**\n/bar/baz\n" }
73
91
 
74
- context "#new" do
92
+ context '#new' do
75
93
  subject { PathSpec.new line }
76
94
 
77
- it_behaves_like "standard gitignore negation"
95
+ it_behaves_like 'standard gitignore negation'
78
96
  end
79
97
 
80
- context "#from_lines" do
98
+ context '#from_lines' do
81
99
  subject {
82
100
  PathSpec.from_lines(line)
83
101
  }
84
102
 
85
- it_behaves_like "standard gitignore negation"
103
+ it_behaves_like 'standard gitignore negation'
86
104
  end
87
105
 
88
- context "#add" do
106
+ context '#add' do
89
107
  subject {
90
108
  ps = PathSpec.new
91
109
  ps.add line
92
110
  }
93
111
 
94
- it_behaves_like "standard gitignore negation"
112
+ it_behaves_like 'standard gitignore negation'
95
113
  end
96
114
  end
97
115
 
98
- context "from a gitignore file" do
116
+ context 'from a gitignore file' do
99
117
  include FakeFS::SpecHelpers
100
118
 
101
119
  let(:filename) { '.gitignore' }
@@ -107,24 +125,24 @@ IGNORELINES
107
125
  }
108
126
  end
109
127
 
110
- context "#new" do
128
+ context '#new' do
111
129
  subject {
112
130
  PathSpec.new File.open(filename, 'r')
113
131
  }
114
132
 
115
- it_behaves_like "standard gitignore negation"
133
+ it_behaves_like 'standard gitignore negation'
116
134
  end
117
135
 
118
- context "#from_filename" do
136
+ context '#from_filename' do
119
137
  subject {
120
138
  PathSpec.from_filename(filename)
121
139
  }
122
140
 
123
- it_behaves_like "standard gitignore negation"
141
+ it_behaves_like 'standard gitignore negation'
124
142
  end
125
143
  end
126
144
 
127
- context "from multiple gitignore files" do
145
+ context 'from multiple gitignore files' do
128
146
  include FakeFS::SpecHelpers
129
147
 
130
148
  let(:filenames) { ['.gitignore', '.otherignore'] }
@@ -141,26 +159,26 @@ IGNORELINES
141
159
  }
142
160
  end
143
161
 
144
- context "#new" do
162
+ context '#new' do
145
163
  subject {
146
164
  arr = filenames.collect { |f| File.open(f, 'r') }
147
165
  PathSpec.new arr
148
166
  }
149
167
 
150
- it_behaves_like "standard gitignore negation"
168
+ it_behaves_like 'standard gitignore negation'
151
169
 
152
170
  it { is_expected.to_not match('banana') }
153
171
  it { is_expected.to match('banananananana') }
154
172
  end
155
173
 
156
- context "#add" do
174
+ context '#add' do
157
175
  subject {
158
176
  arr = filenames.collect { |f| File.open(f, 'r') }
159
177
  ps = PathSpec.new
160
178
  ps.add arr
161
179
  }
162
180
 
163
- it_behaves_like "standard gitignore negation"
181
+ it_behaves_like 'standard gitignore negation'
164
182
 
165
183
  it { is_expected.to_not match('banana') }
166
184
  it { is_expected.to match('banananananana') }
@@ -168,12 +186,13 @@ IGNORELINES
168
186
  end
169
187
  end
170
188
 
171
- context "#match_tree" do
189
+ context '#match_tree' do
172
190
  include FakeFS::SpecHelpers
173
191
 
174
- context "unix" do
192
+ context 'unix' do
175
193
  let(:root) {'/tmp/project'}
176
- let(:gitignore) { <<-GITIGNORE
194
+ let(:gitignore) {
195
+ <<-GITIGNORE
177
196
  !**/important.txt
178
197
  abc/**
179
198
  GITIGNORE
@@ -194,12 +213,13 @@ IGNORELINES
194
213
  it { is_expected.to include "#{root}/abc".to_s }
195
214
  it { is_expected.to include "#{root}/abc/1".to_s }
196
215
  it { is_expected.not_to include "#{root}/abc/important.txt".to_s }
197
- it { is_expected.not_to include "#{root}".to_s }
216
+ it { is_expected.not_to include root.to_s.to_s }
198
217
  end
199
218
 
200
- context "windows" do
219
+ context 'windows' do
201
220
  let(:root) {'C:/project'}
202
- let(:gitignore) { <<-GITIGNORE
221
+ let(:gitignore) {
222
+ <<-GITIGNORE
203
223
  !**/important.txt
204
224
  abc/**
205
225
  GITIGNORE
@@ -220,53 +240,59 @@ IGNORELINES
220
240
  it { is_expected.to include "#{root}/abc".to_s }
221
241
  it { is_expected.to include "#{root}/abc/1".to_s }
222
242
  it { is_expected.not_to include "#{root}/abc/important.txt".to_s }
223
- it { is_expected.not_to include "#{root}".to_s }
243
+ it { is_expected.not_to include root.to_s.to_s }
224
244
  end
225
245
  end
226
246
 
227
- context "#match_paths" do
228
- let(:gitignore) { <<-GITIGNORE
247
+ context '#match_paths' do
248
+ let(:gitignore) {
249
+ <<-GITIGNORE
229
250
  !**/important.txt
230
251
  /abc/**
231
252
  GITIGNORE
232
253
  }
233
254
 
234
- context "with no root arg" do
255
+ context 'with no root arg' do
235
256
  subject { PathSpec.new(gitignore).match_paths(['/abc/important.txt', '/abc/', '/abc/1']) }
236
257
 
237
- it { is_expected.to include "/abc/" }
238
- it { is_expected.to include "/abc/1" }
239
- it { is_expected.not_to include "/abc/important.txt" }
258
+ it { is_expected.to include '/abc/' }
259
+ it { is_expected.to include '/abc/1' }
260
+ it { is_expected.not_to include '/abc/important.txt' }
240
261
  end
241
262
 
242
263
  context 'relative to non-root dir' do
243
- subject { PathSpec.new(gitignore).match_paths([
244
- '/def/abc/important.txt',
245
- '/def/abc/',
246
- '/def/abc/1'], '/def') }
247
-
248
- it { is_expected.to include "/def/abc/" }
249
- it { is_expected.to include "/def/abc/1" }
250
- it { is_expected.not_to include "/def/abc/important.txt" }
264
+ subject {
265
+ PathSpec.new(gitignore).match_paths([
266
+ '/def/abc/important.txt',
267
+ '/def/abc/',
268
+ '/def/abc/1'
269
+ ], '/def') }
270
+
271
+ it { is_expected.to include '/def/abc/' }
272
+ it { is_expected.to include '/def/abc/1' }
273
+ it { is_expected.not_to include '/def/abc/important.txt' }
251
274
  end
252
275
 
253
276
  context 'relative to windows drive letter' do
254
- subject { PathSpec.new(gitignore).match_paths([
255
- 'C:/def/abc/important.txt',
256
- 'C:/def/abc/',
257
- 'C:/def/abc/1'], 'C:/def/') }
258
-
259
- it { is_expected.to include "C:/def/abc/" }
260
- it { is_expected.to include "C:/def/abc/1" }
261
- it { is_expected.not_to include "C:/def/abc/important.txt" }
277
+ subject {
278
+ PathSpec.new(gitignore).match_paths([
279
+ 'C:/def/abc/important.txt',
280
+ 'C:/def/abc/',
281
+ 'C:/def/abc/1'
282
+ ], 'C:/def/') }
283
+
284
+ it { is_expected.to include 'C:/def/abc/' }
285
+ it { is_expected.to include 'C:/def/abc/1' }
286
+ it { is_expected.not_to include 'C:/def/abc/important.txt' }
262
287
  end
263
288
  end
264
289
 
265
290
  # Example to exclude everything except a specific directory foo/bar (note
266
291
  # the /* - without the slash, the wildcard would also exclude everything
267
292
  # within foo/bar): (from git-scm.com)
268
- context "very specific gitignore" do
269
- let(:gitignore) { <<-GITIGNORE
293
+ context 'very specific gitignore' do
294
+ let(:gitignore) {
295
+ <<-GITIGNORE
270
296
  # exclude everything except directory foo/bar
271
297
  /*
272
298
  !/foo
@@ -277,13 +303,14 @@ GITIGNORE
277
303
 
278
304
  subject { PathSpec.new(gitignore) }
279
305
 
280
- it { is_expected.not_to match("foo/bar") }
281
- it { is_expected.to match("anything") }
282
- it { is_expected.to match("foo/otherthing") }
306
+ it { is_expected.not_to match('foo/bar') }
307
+ it { is_expected.to match('anything') }
308
+ it { is_expected.to match('foo/otherthing') }
283
309
  end
284
310
 
285
- context "#empty" do
286
- let(:gitignore) { <<-GITIGNORE
311
+ context '#empty' do
312
+ let(:gitignore) {
313
+ <<-GITIGNORE
287
314
  # A comment
288
315
  GITIGNORE
289
316
  }
@@ -295,39 +322,65 @@ GITIGNORE
295
322
  end
296
323
  end
297
324
 
298
- context "regex file" do
299
- let(:regexfile) { <<-REGEX
325
+ context 'regex file' do
326
+ let(:regexfile) {
327
+ <<-REGEX
300
328
  ab*a
301
329
  REGEX
302
330
  }
303
331
 
304
332
  subject { PathSpec.new regexfile, :regex}
305
333
 
306
- it "matches the regex" do
334
+ it 'matches the regex' do
307
335
  expect(subject.match('anna')).to be false
308
336
  expect(subject.match('abba')).to be true
309
337
  end
310
338
 
311
- context "#from_filename" do
312
- it "forwards the type argument" do
339
+ context '#from_filename' do
340
+ it 'forwards the type argument' do
313
341
  io = double
314
342
 
315
343
  expect(File).to receive(:open).and_yield(io)
316
344
  expect(PathSpec).to receive(:from_lines).with(io, :regex)
317
345
 
318
- PathSpec.from_filename "/some/file", :regex
346
+ PathSpec.from_filename '/some/file', :regex
347
+ end
348
+
349
+ it 'reads a simple regex file' do
350
+ spec = PathSpec.from_filename 'spec/files/regex_simple', :regex
351
+
352
+ expect(spec.match('artifact.md')).to be true
353
+ expect(spec.match('code.rb')).to be false
354
+ end
355
+
356
+ it 'reads a simple gitignore file' do
357
+ spec = PathSpec.from_filename 'spec/files/gitignore_simple', :git
358
+
359
+ expect(spec.match('artifact.md')).to be true
360
+ expect(spec.match('code.rb')).to be false
361
+ end
362
+
363
+ it 'reads an example ruby gitignore file' do
364
+ spec = PathSpec.from_filename 'spec/files/gitignore_ruby', :git
365
+
366
+ expect(spec.match('coverage/')).to be true
367
+ expect(spec.match('coverage/index.html')).to be true
368
+ expect(spec.match('pathspec-0.0.1.gem')).to be true
369
+ expect(spec.match('lib/pathspec')).to be false
370
+ expect(spec.match('Gemfile')).to be false
319
371
  end
320
372
  end
321
373
  end
322
374
 
323
- context "unsuppored spec type" do
324
- let(:file) { <<-REGEX
375
+ context 'unsuppored spec type' do
376
+ let(:file) {
377
+ <<-REGEX
325
378
  This is some kind of nonsense.
326
379
  REGEX
327
380
  }
328
381
 
329
- it "does not allow an unknown spec type" do
330
- expect { PathSpec.new file, :foo}.to raise_error
382
+ it 'does not allow an unknown spec type' do
383
+ expect { PathSpec.new file, :foo}.to raise_error(/Unknown/)
331
384
  end
332
385
  end
333
386
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pathspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon High
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-11 00:00:00.000000000 Z
11
+ date: 2022-01-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,49 +16,130 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.0'
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: '1.0'
26
+ version: '2.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: fakefs
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::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'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '13.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '13.0'
27
69
  - !ruby/object:Gem::Dependency
28
70
  name: rspec
29
71
  requirement: !ruby/object:Gem::Requirement
30
72
  requirements:
31
73
  - - "~>"
32
74
  - !ruby/object:Gem::Version
33
- version: '3.0'
75
+ version: '3.10'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.10'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.7'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.7'
97
+ - !ruby/object:Gem::Dependency
98
+ name: simplecov
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '0.21'
34
104
  type: :development
35
105
  prerelease: false
36
106
  version_requirements: !ruby/object:Gem::Requirement
37
107
  requirements:
38
108
  - - "~>"
39
109
  - !ruby/object:Gem::Version
40
- version: '3.0'
110
+ version: '0.21'
41
111
  description: Use to match path patterns such as gitignore
42
- email: bh@brandon-high.com
43
- executables: []
112
+ email: highb@users.noreply.github.com
113
+ executables:
114
+ - pathspec-rb
44
115
  extensions: []
45
116
  extra_rdoc_files: []
46
117
  files:
47
118
  - CHANGELOG.md
48
119
  - LICENSE
49
120
  - README.md
121
+ - bin/pathspec-rb
122
+ - docs/index.html
123
+ - docs/man/pathspec-rb.man.1
124
+ - docs/pathspec-rb.md
50
125
  - lib/pathspec.rb
51
126
  - lib/pathspec/gitignorespec.rb
52
127
  - lib/pathspec/regexspec.rb
53
128
  - lib/pathspec/spec.rb
129
+ - spec/files/gitignore_readme
130
+ - spec/files/gitignore_ruby
131
+ - spec/files/gitignore_simple
132
+ - spec/files/regex_simple
54
133
  - spec/spec_helper.rb
55
134
  - spec/unit/pathspec/gitignorespec_spec.rb
56
135
  - spec/unit/pathspec/spec_spec.rb
57
136
  - spec/unit/pathspec_spec.rb
58
137
  homepage: https://github.com/highb/pathspec-ruby
59
138
  licenses:
60
- - Apache
61
- metadata: {}
139
+ - Apache-2.0
140
+ metadata:
141
+ allowed_push_host: https://rubygems.org
142
+ rubygems_mfa_required: 'true'
62
143
  post_install_message:
63
144
  rdoc_options: []
64
145
  require_paths:
@@ -67,19 +148,22 @@ required_ruby_version: !ruby/object:Gem::Requirement
67
148
  requirements:
68
149
  - - ">="
69
150
  - !ruby/object:Gem::Version
70
- version: '0'
151
+ version: 2.6.9
71
152
  required_rubygems_version: !ruby/object:Gem::Requirement
72
153
  requirements:
73
154
  - - ">="
74
155
  - !ruby/object:Gem::Version
75
156
  version: '0'
76
157
  requirements: []
77
- rubyforge_project:
78
- rubygems_version: 2.2.2
158
+ rubygems_version: 3.1.4
79
159
  signing_key:
80
160
  specification_version: 4
81
161
  summary: 'PathSpec: for matching path patterns'
82
162
  test_files:
163
+ - spec/files/gitignore_readme
164
+ - spec/files/gitignore_ruby
165
+ - spec/files/gitignore_simple
166
+ - spec/files/regex_simple
83
167
  - spec/spec_helper.rb
84
168
  - spec/unit/pathspec/gitignorespec_spec.rb
85
169
  - spec/unit/pathspec/spec_spec.rb