file-find 0.5.0 → 0.5.1
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 +4 -4
- checksums.yaml.gz.sig +1 -2
- data/CHANGES.md +8 -0
- data/Gemfile +2 -3
- data/README.md +14 -1
- data/Rakefile +11 -3
- data/file-find.gemspec +13 -8
- data/lib/file/find.rb +39 -37
- data/lib/file-find.rb +2 -0
- data/spec/file_find_spec.rb +181 -160
- data.tar.gz.sig +0 -0
- metadata +42 -15
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f1b89ade1ff89a891f6aa2a44fa801fa9d2758b3784074f8868a5b3319dc68a5
|
4
|
+
data.tar.gz: 52f17946eb45f73bd98b0804a9696e5e4d7c2f17d9ea002a20fa109fde7e10f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e6d0e1a56de403c2e7327f2d9af3ec6c68528d53f0cb0b83e40362b1ab8dddda020212cc726428ea0791130c098c1a41f53f22a65fad314d8dd9fee05fdc7fa3
|
7
|
+
data.tar.gz: 6c68a1b0e85905844b44feb04036834bb39e3ccaff5b732bb64d6280bb3eb86248f92f74570e60d37704fbc4d42ea4f99f2406c6d4be61ce7c9a8e3f89f1f1bb
|
checksums.yaml.gz.sig
CHANGED
@@ -1,2 +1 @@
|
|
1
|
-
|
2
|
-
)�f�Y_C�4��#a���a'|%*�CiimuƄhz
|
1
|
+
]����j��]i�<ǝ�ٲ�Ԕ�X�|sN��l�!ʋ��TT�%wtF�W�8�g�s�]����Էâ�g�Z!1y`���|���."qe'V�?���$W�n���)��RNf�ʍ��ޠ�2���qiN�6_��Si^/q��A?�~��Θ����=$�O�"���-���VB���$����|�����xc����פ6h�WZnc��{�P���ܲ0��w����N]�/:ݧ%����:�ω�#��O��.�X�D2+��o`V��9�D.㫐���>d���p�_2@t�6�ԧ���S·�=�ea1$-T��3|_��woP��BJ��g|�P�x�au��l���a�T�3��5�x.��5��_�
|
data/CHANGES.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
## 0.5.1 - 17-Jun-2025
|
2
|
+
* Updated, fixed or skipped some specs on Windows.
|
3
|
+
* Some rubocop cleanup and minor refactors.
|
4
|
+
* Added a github workflow matrix to the repo.
|
5
|
+
* Added a rubocop config to the repo.
|
6
|
+
* Minor tweaks to the Rakefile.
|
7
|
+
* Added more information to the README.
|
8
|
+
|
1
9
|
## 0.5.0 - 19-Jan-2021
|
2
10
|
* Switched from test-unit to rspec, with an added development
|
3
11
|
dependency on the fakefs gem.
|
data/Gemfile
CHANGED
@@ -1,3 +1,2 @@
|
|
1
|
-
source 'https://rubygems.org'
|
2
|
-
|
3
|
-
end
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
gemspec
|
data/README.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
[](https://github.com/djberg96/file-find/actions/workflows/ruby.yml)
|
2
|
+
|
1
3
|
## Description
|
2
4
|
|
3
5
|
This is a drop-in replacement for the find module currently in the standard
|
@@ -7,6 +9,14 @@ library. It is modeled on a typical 'find' command found on most Unix systems.
|
|
7
9
|
|
8
10
|
`gem install file-find`
|
9
11
|
|
12
|
+
## Specs
|
13
|
+
|
14
|
+
Although this gem will work with Ruby 2.x or 3.x, you will need Ruby 3.x to
|
15
|
+
run the specs locally because of development dependencies.
|
16
|
+
|
17
|
+
## Adding the trusted cert
|
18
|
+
`gem cert --add <(curl -Ls https://raw.githubusercontent.com/djberg96/file-find/main/certs/djberg96_pub.pem)`
|
19
|
+
|
10
20
|
## Synopsis
|
11
21
|
```ruby
|
12
22
|
require 'file/find' # 'file-find' also works
|
@@ -82,6 +92,9 @@ The `:perm` option is limited to 0644 and 0444 on MS Windows.
|
|
82
92
|
The `:user`, `:group`, and `:inum` options require the win32-file gem to work
|
83
93
|
properly on MS Windows. However, win32-file is not officially a dependency.
|
84
94
|
|
95
|
+
Some specs on Windows are marked pending for now because there's some issue
|
96
|
+
interacting with the FakeFS gem on Windows.
|
97
|
+
|
85
98
|
## Bugs
|
86
99
|
|
87
100
|
None that I'm aware of beyond the ones mentioned in the Known Issues. Please
|
@@ -102,7 +115,7 @@ Apache-2.0
|
|
102
115
|
|
103
116
|
## Copyright
|
104
117
|
|
105
|
-
(C) 2007-
|
118
|
+
(C) 2007-2025, Daniel J. Berger, All Rights Reserved
|
106
119
|
|
107
120
|
## Author
|
108
121
|
|
data/Rakefile
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
require 'rake'
|
2
2
|
require 'rake/clean'
|
3
3
|
require 'rspec/core/rake_task'
|
4
|
+
require 'rubocop/rake_task'
|
4
5
|
|
5
|
-
CLEAN.include("**/*.gem", "**/*.rbc", "**/link*")
|
6
|
+
CLEAN.include("**/*.gem", "**/*.rbc", "**/link*", "*.lock")
|
6
7
|
|
7
8
|
namespace :gem do
|
8
9
|
desc 'Create the file-find gem'
|
9
10
|
task :create => [:clean] do
|
10
11
|
require 'rubygems/package'
|
11
|
-
spec =
|
12
|
+
spec = Gem::Specification.load('file-find.gemspec')
|
12
13
|
spec.signing_key = File.join(Dir.home, '.ssh', 'gem-private_key.pem')
|
13
|
-
Gem::Package.build(spec
|
14
|
+
Gem::Package.build(spec)
|
14
15
|
end
|
15
16
|
|
16
17
|
desc "Install the file-find gem"
|
@@ -21,8 +22,15 @@ namespace :gem do
|
|
21
22
|
end
|
22
23
|
end
|
23
24
|
|
25
|
+
RuboCop::RakeTask.new
|
26
|
+
|
24
27
|
RSpec::Core::RakeTask.new(:spec) do |t|
|
25
28
|
t.pattern = ['spec/file_find_spec.rb']
|
26
29
|
end
|
27
30
|
|
31
|
+
# Clean up afterwards
|
32
|
+
Rake::Task[:spec].enhance do
|
33
|
+
Rake::Task[:clean].invoke
|
34
|
+
end
|
35
|
+
|
28
36
|
task :default => :spec
|
data/file-find.gemspec
CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = 'file-find'
|
5
|
-
spec.version = '0.5.
|
5
|
+
spec.version = '0.5.1'
|
6
6
|
spec.author = 'Daniel Berger'
|
7
7
|
spec.license = 'Apache-2.0'
|
8
8
|
spec.summary = 'A better way to find files'
|
@@ -13,18 +13,23 @@ Gem::Specification.new do |spec|
|
|
13
13
|
spec.cert_chain = Dir['certs/*']
|
14
14
|
|
15
15
|
spec.metadata = {
|
16
|
-
'homepage_uri'
|
17
|
-
'bug_tracker_uri'
|
18
|
-
'changelog_uri'
|
19
|
-
'documentation_uri'
|
20
|
-
'source_code_uri'
|
21
|
-
'wiki_uri'
|
16
|
+
'homepage_uri' => 'https://github.com/djberg96/file-find',
|
17
|
+
'bug_tracker_uri' => 'https://github.com/djberg96/file-find/issues',
|
18
|
+
'changelog_uri' => 'https://github.com/djberg96/file-find/blob/main/CHANGES.md',
|
19
|
+
'documentation_uri' => 'https://github.com/djberg96/file-find/wiki',
|
20
|
+
'source_code_uri' => 'https://github.com/djberg96/file-find',
|
21
|
+
'wiki_uri' => 'https://github.com/djberg96/file-find/wiki',
|
22
|
+
'rubygems_mfa_required' => 'true',
|
23
|
+
'github_repo' => 'https://github.com/djberg96/file-find',
|
24
|
+
'funding_uri' => 'https://github.com/sponsors/djberg96'
|
22
25
|
}
|
23
26
|
|
24
27
|
spec.add_dependency('sys-admin', '~> 1.7')
|
25
28
|
spec.add_development_dependency('rspec', '~> 3.9')
|
26
|
-
spec.add_development_dependency('fakefs', '~>
|
29
|
+
spec.add_development_dependency('fakefs', '~> 3.0')
|
27
30
|
spec.add_development_dependency('rake')
|
31
|
+
spec.add_development_dependency('rubocop')
|
32
|
+
spec.add_development_dependency('rubocop-rspec')
|
28
33
|
|
29
34
|
spec.description = <<-EOF
|
30
35
|
The file-find library provides a better, more object oriented approach
|
data/lib/file/find.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'date'
|
2
4
|
require 'sys/admin'
|
3
5
|
|
@@ -7,9 +9,11 @@ rescue LoadError
|
|
7
9
|
# Do nothing, not required, just nicer.
|
8
10
|
end
|
9
11
|
|
12
|
+
# The File::Find class encapsulates 'rules' that you create and use to find
|
13
|
+
# files on your filesystem.
|
10
14
|
class File::Find
|
11
15
|
# The version of the file-find library
|
12
|
-
VERSION = '0.5.
|
16
|
+
VERSION = '0.5.1'
|
13
17
|
|
14
18
|
# :stopdoc:
|
15
19
|
VALID_OPTIONS = %w[
|
@@ -31,7 +35,7 @@ class File::Find
|
|
31
35
|
prune
|
32
36
|
size
|
33
37
|
user
|
34
|
-
]
|
38
|
+
].freeze
|
35
39
|
# :startdoc:
|
36
40
|
|
37
41
|
# The starting path(s) for the search. The default is the current directory.
|
@@ -209,6 +213,7 @@ class File::Find
|
|
209
213
|
def find
|
210
214
|
results = [] unless block_given?
|
211
215
|
paths = @path.is_a?(String) ? [@path] : @path # Ruby 1.9.x compatibility
|
216
|
+
queue = paths.dup
|
212
217
|
|
213
218
|
if @prune
|
214
219
|
prune_regex = Regexp.new(@prune)
|
@@ -216,14 +221,16 @@ class File::Find
|
|
216
221
|
prune_regex = nil
|
217
222
|
end
|
218
223
|
|
219
|
-
|
224
|
+
# rubocop:disable Metrics/BlockLength
|
225
|
+
until queue.empty?
|
226
|
+
path = queue.shift
|
220
227
|
begin
|
221
|
-
Dir.foreach(path)
|
228
|
+
Dir.foreach(path) do |file|
|
222
229
|
next if file == '.'
|
223
230
|
next if file == '..'
|
224
231
|
|
225
|
-
if prune_regex
|
226
|
-
next
|
232
|
+
if prune_regex && prune_regex.match(file)
|
233
|
+
next
|
227
234
|
end
|
228
235
|
|
229
236
|
file = File.join(path, file)
|
@@ -251,38 +258,32 @@ class File::Find
|
|
251
258
|
glob.tr!(File::ALT_SEPARATOR, File::SEPARATOR)
|
252
259
|
end
|
253
260
|
|
254
|
-
if @mount
|
255
|
-
next
|
261
|
+
if @mount && stat_info.dev != @filesystem
|
262
|
+
next
|
256
263
|
end
|
257
264
|
|
258
|
-
if @links
|
259
|
-
next
|
265
|
+
if @links && stat_info.nlink != @links
|
266
|
+
next
|
260
267
|
end
|
261
268
|
|
262
269
|
if @maxdepth || @mindepth
|
263
|
-
file_depth = file.split(File::SEPARATOR).reject
|
270
|
+
file_depth = file.split(File::SEPARATOR).reject(&:empty?).length
|
264
271
|
current_base_path = [@path].flatten.find{ |tpath| file.include?(tpath) }
|
265
272
|
path_depth = current_base_path.split(File::SEPARATOR).length
|
266
273
|
|
267
274
|
depth = file_depth - path_depth
|
268
275
|
|
269
276
|
if @maxdepth && (depth > @maxdepth)
|
270
|
-
if File.directory?(file)
|
271
|
-
|
272
|
-
paths << file
|
273
|
-
end
|
277
|
+
if File.directory?(file) && !(paths.include?(file) && depth > @maxdepth)
|
278
|
+
queue << file
|
274
279
|
end
|
275
|
-
|
276
280
|
next
|
277
281
|
end
|
278
282
|
|
279
283
|
if @mindepth && (depth < @mindepth)
|
280
|
-
if File.directory?(file)
|
281
|
-
|
282
|
-
paths << file
|
283
|
-
end
|
284
|
+
if File.directory?(file) && !(paths.include?(file) && depth < @mindepth)
|
285
|
+
queue << file
|
284
286
|
end
|
285
|
-
|
286
287
|
next
|
287
288
|
end
|
288
289
|
end
|
@@ -290,8 +291,8 @@ class File::Find
|
|
290
291
|
# Add directories back onto the list of paths to search unless
|
291
292
|
# they've already been added
|
292
293
|
#
|
293
|
-
if stat_info.directory?
|
294
|
-
|
294
|
+
if stat_info.directory? && !paths.include?(file)
|
295
|
+
queue << file
|
295
296
|
end
|
296
297
|
|
297
298
|
next unless Dir[glob].include?(file)
|
@@ -299,7 +300,7 @@ class File::Find
|
|
299
300
|
unless @filetest.empty?
|
300
301
|
file_test = true
|
301
302
|
|
302
|
-
@filetest.each
|
303
|
+
@filetest.each do |array|
|
303
304
|
meth = array[0]
|
304
305
|
bool = array[1]
|
305
306
|
|
@@ -307,7 +308,7 @@ class File::Find
|
|
307
308
|
file_test = false
|
308
309
|
break
|
309
310
|
end
|
310
|
-
|
311
|
+
end
|
311
312
|
|
312
313
|
next unless file_test
|
313
314
|
end
|
@@ -331,8 +332,8 @@ class File::Find
|
|
331
332
|
end
|
332
333
|
end
|
333
334
|
|
334
|
-
if @ftype
|
335
|
-
next
|
335
|
+
if @ftype && File.ftype(file) != @ftype
|
336
|
+
next
|
336
337
|
end
|
337
338
|
|
338
339
|
if @group
|
@@ -355,8 +356,8 @@ class File::Find
|
|
355
356
|
end
|
356
357
|
end
|
357
358
|
|
358
|
-
if @inum
|
359
|
-
next
|
359
|
+
if @inum && stat_info.ino != @inum
|
360
|
+
next
|
360
361
|
end
|
361
362
|
|
362
363
|
# Note that only 0644 and 0444 are supported on MS Windows.
|
@@ -365,7 +366,7 @@ class File::Find
|
|
365
366
|
octal_perm = sym2oct(@perm)
|
366
367
|
next unless stat_info.mode & octal_perm == octal_perm
|
367
368
|
else
|
368
|
-
next unless
|
369
|
+
next unless format('%o', stat_info.mode & 07777) == format('%o', @perm)
|
369
370
|
end
|
370
371
|
end
|
371
372
|
|
@@ -415,11 +416,12 @@ class File::Find
|
|
415
416
|
end
|
416
417
|
|
417
418
|
@previous = file unless @previous == file
|
418
|
-
|
419
|
+
end
|
419
420
|
rescue Errno::EACCES
|
420
421
|
next # Skip inaccessible directories
|
421
422
|
end
|
422
|
-
|
423
|
+
end
|
424
|
+
# rubocop:enable Metrics/BlockLength
|
423
425
|
|
424
426
|
block_given? ? nil : results
|
425
427
|
end
|
@@ -476,17 +478,17 @@ class File::Find
|
|
476
478
|
match = cmd.match(regex)
|
477
479
|
raise "Invalid symbolic permissions: '#{str}'" if match.nil?
|
478
480
|
|
479
|
-
who, what, how = match.to_a[1
|
481
|
+
who, what, how = match.to_a[1..]
|
480
482
|
|
481
|
-
who = who.
|
482
|
-
how = how.
|
483
|
+
who = who.chars.inject(0){ |num, b| num | left[b] }
|
484
|
+
how = how.chars.inject(0){ |num, b| num | right[b] }
|
483
485
|
mask = who & how
|
484
486
|
|
485
487
|
case what
|
486
488
|
when '+'
|
487
|
-
perm
|
489
|
+
perm |= mask
|
488
490
|
when '-'
|
489
|
-
perm
|
491
|
+
perm &= ~mask
|
490
492
|
when '='
|
491
493
|
perm = mask
|
492
494
|
end
|
data/lib/file-find.rb
CHANGED
data/spec/file_find_spec.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
######################################################################
|
2
4
|
# file_find_spec.rb
|
3
5
|
#
|
@@ -7,136 +9,136 @@
|
|
7
9
|
require 'rspec'
|
8
10
|
require 'file-find'
|
9
11
|
require 'sys-admin'
|
10
|
-
require 'pp' # stops fakefs class mismatch errors
|
11
12
|
require 'tmpdir'
|
13
|
+
require 'pp' # Goofy workaround for FakeFS bug
|
12
14
|
require 'fakefs/spec_helpers'
|
13
15
|
|
14
16
|
RSpec.describe File::Find do
|
15
17
|
include FakeFS::SpecHelpers
|
16
18
|
|
17
19
|
let(:windows) { File::ALT_SEPARATOR }
|
20
|
+
let(:elevated) { windows and Win32::Security.elevated_security? }
|
18
21
|
let(:ruby_file) { 'file_find_test.rb' }
|
19
22
|
let(:doc_file) { 'file_find_test.doc' }
|
20
|
-
let(:text_file1) { 'file_find_test1.txt' }
|
21
|
-
let(:text_file2) { 'file_find_test2.txt' }
|
22
23
|
|
23
|
-
let(:rule) {
|
24
|
-
let(:txt_rule) {
|
24
|
+
let(:rule) { described_class.new }
|
25
|
+
let(:txt_rule) { described_class.new(:name => '*.txt') }
|
25
26
|
|
26
27
|
before(:all) do
|
27
28
|
@loguser = Sys::Admin.get_user(Sys::Admin.get_login)
|
28
|
-
|
29
|
+
group = File::ALT_SEPARATOR ? 'Users' : @loguser.gid
|
30
|
+
@logroup = Sys::Admin.get_group(group)
|
29
31
|
end
|
30
32
|
|
31
|
-
context
|
32
|
-
example
|
33
|
-
expect(File::Find::VERSION).to eq('0.5.
|
33
|
+
context 'constants', :constants do
|
34
|
+
example 'version constant is set to expected value' do
|
35
|
+
expect(File::Find::VERSION).to eq('0.5.1')
|
34
36
|
expect(File::Find::VERSION).to be_frozen
|
35
37
|
end
|
36
38
|
end
|
37
39
|
|
38
|
-
context
|
39
|
-
example
|
40
|
+
context 'path', :path do
|
41
|
+
example 'path accessor basic functionality' do
|
40
42
|
expect(rule).to respond_to(:path)
|
41
43
|
expect(rule).to respond_to(:path=)
|
42
44
|
end
|
43
45
|
|
44
|
-
example
|
46
|
+
example 'path method returns expected value' do
|
45
47
|
expect(rule.path).to eq(Dir.pwd)
|
46
48
|
end
|
47
49
|
end
|
48
50
|
|
49
|
-
context
|
50
|
-
example
|
51
|
+
context 'options', :options do
|
52
|
+
example 'options accessor basic functionality' do
|
51
53
|
expect(rule).to respond_to(:options)
|
52
54
|
expect(rule).to respond_to(:options=)
|
53
55
|
end
|
54
56
|
|
55
|
-
example
|
57
|
+
example 'options method returns expected value' do
|
56
58
|
expect(txt_rule.options).to eq({:name => '*.txt'})
|
57
59
|
end
|
58
60
|
end
|
59
61
|
|
60
|
-
context
|
62
|
+
context 'atime', :atime do
|
61
63
|
before do
|
62
64
|
FileUtils.touch(ruby_file)
|
63
65
|
end
|
64
66
|
|
65
|
-
example
|
67
|
+
example 'atime accessor basic functionality' do
|
66
68
|
expect(rule).to respond_to(:atime)
|
67
69
|
expect(rule).to respond_to(:atime=)
|
68
70
|
end
|
69
71
|
|
70
|
-
example
|
72
|
+
example 'atime method returns expected default value' do
|
71
73
|
expect(rule.atime).to be_nil
|
72
74
|
end
|
73
75
|
|
74
|
-
example
|
75
|
-
rule1 =
|
76
|
-
rule2 =
|
76
|
+
example 'find with atime option works as expected' do
|
77
|
+
rule1 = described_class.new(:name => '*.rb', :atime => 0)
|
78
|
+
rule2 = described_class.new(:name => '*.rb', :atime => 1)
|
77
79
|
|
78
80
|
expect(rule1.find.empty?).to be false
|
79
81
|
expect(rule2.find.empty?).to be true
|
80
82
|
end
|
81
83
|
end
|
82
84
|
|
83
|
-
context
|
85
|
+
context 'ctime', :ctime do
|
84
86
|
before do
|
85
87
|
FileUtils.touch(ruby_file)
|
86
88
|
end
|
87
89
|
|
88
|
-
example
|
90
|
+
example 'ctime accessor basic functionality' do
|
89
91
|
expect(rule).to respond_to(:ctime)
|
90
92
|
expect(rule).to respond_to(:ctime=)
|
91
93
|
end
|
92
94
|
|
93
|
-
example
|
95
|
+
example 'ctime method returns expected default value' do
|
94
96
|
expect(rule.ctime).to be_nil
|
95
97
|
end
|
96
98
|
|
97
|
-
example
|
98
|
-
rule1 =
|
99
|
-
rule2 =
|
99
|
+
example 'find with ctime option works as expected' do
|
100
|
+
rule1 = described_class.new(:name => '*.rb', :ctime => 0)
|
101
|
+
rule2 = described_class.new(:name => '*.rb', :ctime => 1)
|
100
102
|
|
101
103
|
expect(rule1.find.empty?).to be false
|
102
104
|
expect(rule2.find.empty?).to be true
|
103
105
|
end
|
104
106
|
end
|
105
107
|
|
106
|
-
context
|
107
|
-
example
|
108
|
+
context 'find', :find do
|
109
|
+
example 'find method basic functionality' do
|
108
110
|
expect(rule).to respond_to(:find)
|
109
111
|
expect{ rule.find }.not_to raise_error
|
110
112
|
end
|
111
113
|
|
112
|
-
example
|
113
|
-
expect(rule.find).to
|
114
|
+
example 'find method returns expected value' do
|
115
|
+
expect(rule.find).to be_a(Array)
|
114
116
|
expect(rule.find{}).to be_nil
|
115
117
|
end
|
116
118
|
end
|
117
119
|
|
118
|
-
context
|
120
|
+
context 'filetest', :filetest do
|
119
121
|
before do
|
120
122
|
FileUtils.touch(doc_file, :mode => 0644)
|
121
123
|
end
|
122
124
|
|
123
|
-
example
|
125
|
+
example 'filetest accessor basic functionality' do
|
124
126
|
expect(rule).to respond_to(:filetest)
|
125
127
|
expect(rule).to respond_to(:filetest=)
|
126
128
|
expect{ rule.filetest }.not_to raise_error
|
127
129
|
end
|
128
130
|
|
129
|
-
example
|
130
|
-
expect(rule.filetest).to
|
131
|
+
example 'filetest method returns expected value' do
|
132
|
+
expect(rule.filetest).to be_a(Array)
|
131
133
|
end
|
132
134
|
|
133
|
-
example
|
134
|
-
expect{
|
135
|
-
expect{
|
135
|
+
example 'valid filetest options work as expected' do
|
136
|
+
expect{ described_class.new(:readable? => true) }.not_to raise_error
|
137
|
+
expect{ described_class.new(:writable? => true) }.not_to raise_error
|
136
138
|
end
|
137
139
|
|
138
|
-
example
|
139
|
-
rule =
|
140
|
+
example 'find method works with filetest option' do
|
141
|
+
rule = described_class.new(:name => '*.doc', :writable? => true)
|
140
142
|
|
141
143
|
expect(rule.find.map{ |f| File.basename(f) }).to eq([doc_file])
|
142
144
|
FileUtils.chmod(0444, doc_file)
|
@@ -144,165 +146,158 @@ RSpec.describe File::Find do
|
|
144
146
|
end
|
145
147
|
end
|
146
148
|
|
147
|
-
context
|
149
|
+
context 'mtime', :mtime do
|
148
150
|
before do
|
149
151
|
FileUtils.touch(ruby_file)
|
150
152
|
end
|
151
153
|
|
152
|
-
example
|
154
|
+
example 'mtime accessor basic functionality' do
|
153
155
|
expect(rule).to respond_to(:mtime)
|
154
156
|
expect(rule).to respond_to(:mtime=)
|
155
157
|
end
|
156
158
|
|
157
|
-
example
|
159
|
+
example 'mtime method returns expected default value' do
|
158
160
|
expect(rule.mtime).to be_nil
|
159
161
|
end
|
160
162
|
|
161
|
-
example
|
162
|
-
rule1 =
|
163
|
-
rule2 =
|
163
|
+
example 'find with mtime option works as expected' do
|
164
|
+
rule1 = described_class.new(:name => '*.rb', :mtime => 0)
|
165
|
+
rule2 = described_class.new(:name => '*.rb', :mtime => 1)
|
164
166
|
|
165
167
|
expect(rule1.find.empty?).to be false
|
166
168
|
expect(rule2.find.empty?).to be true
|
167
169
|
end
|
168
170
|
end
|
169
171
|
|
170
|
-
context
|
172
|
+
context 'ftype', :ftype do
|
171
173
|
before do
|
172
174
|
FileUtils.touch(ruby_file)
|
173
175
|
end
|
174
176
|
|
175
|
-
example
|
177
|
+
example 'ftype accessor basic functionality' do
|
176
178
|
expect(rule).to respond_to(:ftype)
|
177
179
|
expect(rule).to respond_to(:ftype=)
|
178
180
|
end
|
179
181
|
|
180
|
-
example
|
182
|
+
example 'ftype method returns expected default value' do
|
181
183
|
expect(rule.ftype).to be_nil
|
182
184
|
end
|
183
185
|
|
184
|
-
example
|
185
|
-
rule1 =
|
186
|
-
rule2 =
|
186
|
+
example 'ftype method works as expected' do
|
187
|
+
rule1 = described_class.new(:name => '*.rb', :ftype => 'file')
|
188
|
+
rule2 = described_class.new(:name => '*.rb', :ftype => 'characterSpecial')
|
187
189
|
|
188
190
|
expect(rule1.find.empty?).to be false
|
189
191
|
expect(rule2.find.empty?).to be true
|
190
192
|
end
|
191
193
|
end
|
192
194
|
|
193
|
-
context
|
195
|
+
context 'group', :group do
|
194
196
|
before do
|
195
197
|
FileUtils.touch(doc_file)
|
196
198
|
end
|
197
199
|
|
198
|
-
example
|
200
|
+
example 'group accessor basic functionality' do
|
199
201
|
expect(rule).to respond_to(:group)
|
200
202
|
expect(rule).to respond_to(:group=)
|
201
203
|
end
|
202
204
|
|
203
|
-
example
|
205
|
+
example 'group method returns expected default value' do
|
204
206
|
expect(rule.group).to be_nil
|
205
207
|
end
|
206
208
|
|
207
209
|
# TODO: Update example for Windows
|
208
|
-
example
|
210
|
+
example 'find with numeric group id works as expected' do
|
209
211
|
skip 'group example skipped on MS Windows' if windows
|
210
|
-
rule =
|
212
|
+
rule = described_class.new(:name => '*.doc', :group => @loguser.gid)
|
211
213
|
expect(rule.find).to eq([File.expand_path(doc_file)])
|
212
214
|
end
|
213
215
|
|
214
216
|
# TODO: Update example for Windows
|
215
|
-
example
|
217
|
+
example 'find with string group id works as expected' do
|
216
218
|
skip 'group example skipped on MS Windows' if windows
|
217
219
|
|
218
|
-
rule =
|
220
|
+
rule = described_class.new(:name => '*.doc', :group => @logroup.name)
|
219
221
|
expect(rule.find).to eq([File.expand_path(doc_file)])
|
220
222
|
end
|
221
223
|
|
222
|
-
example
|
224
|
+
example 'find with bogus group returns empty results' do
|
223
225
|
skip 'group test skipped on MS Windows' if windows
|
224
226
|
|
225
|
-
rule1 =
|
226
|
-
rule2 =
|
227
|
+
rule1 = described_class.new(:name => '*.doc', :group => 'totallybogus')
|
228
|
+
rule2 = described_class.new(:name => '*.doc', :group => 99999999)
|
227
229
|
expect(rule1.find).to eq([])
|
228
230
|
expect(rule2.find).to eq([])
|
229
231
|
end
|
230
232
|
end
|
231
233
|
|
232
|
-
context
|
233
|
-
example
|
234
|
+
context 'inum', :inum do
|
235
|
+
example 'inum accessor basic functionality' do
|
234
236
|
expect(rule).to respond_to(:inum)
|
235
237
|
expect(rule).to respond_to(:inum=)
|
236
238
|
end
|
237
239
|
|
238
|
-
example
|
240
|
+
example 'inum method returns expected default value' do
|
239
241
|
expect(rule.inum).to be_nil
|
240
242
|
end
|
241
243
|
end
|
242
244
|
|
243
|
-
context
|
244
|
-
example
|
245
|
+
context 'follow', :follow do
|
246
|
+
example 'follow accessor basic functionality' do
|
245
247
|
expect(rule).to respond_to(:follow)
|
246
248
|
expect(rule).to respond_to(:follow=)
|
247
249
|
end
|
248
250
|
|
249
|
-
example
|
251
|
+
example 'follow method returns expected default value' do
|
250
252
|
expect(rule.follow).to be true
|
251
253
|
end
|
252
254
|
end
|
253
255
|
|
254
|
-
context
|
256
|
+
context 'links', :links do
|
255
257
|
before do
|
256
258
|
FileUtils.touch(ruby_file)
|
257
259
|
FileUtils.touch(doc_file)
|
258
260
|
end
|
259
261
|
|
260
|
-
example
|
262
|
+
example 'links accessor basic functionality' do
|
261
263
|
expect(rule).to respond_to(:links)
|
262
264
|
expect(rule).to respond_to(:links=)
|
263
265
|
end
|
264
266
|
|
265
|
-
example
|
267
|
+
example 'links method returns expected default value' do
|
266
268
|
expect(rule.links).to be_nil
|
267
269
|
end
|
268
270
|
|
269
|
-
example
|
270
|
-
|
271
|
+
example 'links method returns expected result' do
|
272
|
+
skip if windows && !elevated
|
271
273
|
|
272
|
-
rule1 =
|
273
|
-
rule2 =
|
274
|
+
rule1 = described_class.new(:name => '*.rb', :links => 2)
|
275
|
+
rule2 = described_class.new(:name => '*.doc', :links => 1)
|
274
276
|
|
275
277
|
expect(rule1.find).to eq([])
|
276
278
|
expect(rule2.find).to eq([File.expand_path(doc_file)])
|
277
279
|
end
|
278
280
|
end
|
279
281
|
|
280
|
-
context
|
282
|
+
context 'brackets', :brackets do
|
283
|
+
let(:file_rule){ described_class.new(:ftype => 'file', :path => ['/bracket']) }
|
284
|
+
let(:dir_rule){ described_class.new(:ftype => 'directory', :path => ['/bracket']) }
|
285
|
+
|
281
286
|
before do
|
282
287
|
allow(FakeFS::FileSystem).to receive(:find).and_call_original
|
283
288
|
allow(FakeFS::FileSystem).to receive(:find).with(anything, 0, false)
|
284
289
|
end
|
285
290
|
|
286
|
-
example
|
291
|
+
example 'find method works on dirs that contain brackets' do
|
287
292
|
skip 'dirs with brackets example skipped on MS Windows' if windows
|
288
293
|
|
289
294
|
# We use absolute paths here because of fakefs, which converts it anyway
|
290
|
-
bracket_files = ['/bracket/a[1]/a.foo', '/bracket/a [2] /b.foo', '/bracket/[a] b [c]/d.foo'
|
291
|
-
bracket_paths = ['/bracket/a[1]', '/bracket/a [2] ', '/bracket/[a] b [c]', '/bracket/[z] x'
|
295
|
+
bracket_files = ['/bracket/a[1]/a.foo', '/bracket/a [2] /b.foo', '/bracket/[a] b [c]/d.foo']
|
296
|
+
bracket_paths = ['/bracket/a[1]', '/bracket/a [2] ', '/bracket/[a] b [c]', '/bracket/[z] x']
|
292
297
|
|
293
298
|
bracket_paths.each{ |e| FakeFS::FileSystem.add(e) }
|
294
299
|
bracket_files.each{ |e| FileUtils.touch(e) }
|
295
300
|
|
296
|
-
file_rule = File::Find.new(
|
297
|
-
:ftype => 'file',
|
298
|
-
:path => ['/bracket']
|
299
|
-
)
|
300
|
-
|
301
|
-
dir_rule = File::Find.new(
|
302
|
-
:ftype => 'directory',
|
303
|
-
:path => ['/bracket']
|
304
|
-
)
|
305
|
-
|
306
301
|
file_results = file_rule.find
|
307
302
|
dir_results = dir_rule.find
|
308
303
|
|
@@ -311,10 +306,10 @@ RSpec.describe File::Find do
|
|
311
306
|
end
|
312
307
|
end
|
313
308
|
|
314
|
-
context
|
309
|
+
context 'maxdepth', :maxdepth do
|
315
310
|
before do
|
316
|
-
|
317
|
-
rule.pattern =
|
311
|
+
FakeFS::FileSystem.add('a1/a2/a3')
|
312
|
+
rule.pattern = '*.foo'
|
318
313
|
|
319
314
|
FileUtils.touch('a1/a.foo')
|
320
315
|
FileUtils.touch('a1/a2/b.foo')
|
@@ -324,48 +319,60 @@ RSpec.describe File::Find do
|
|
324
319
|
FileUtils.touch('a1/a2/a3/f.foo')
|
325
320
|
end
|
326
321
|
|
327
|
-
example
|
322
|
+
example 'maxdepth_basic' do
|
328
323
|
expect(rule).to respond_to(:maxdepth)
|
329
324
|
expect(rule).to respond_to(:maxdepth=)
|
330
325
|
expect(rule.maxdepth).to be_nil
|
331
326
|
end
|
332
327
|
|
333
|
-
example
|
328
|
+
example 'find with maxdepth 1 returns expected results' do
|
334
329
|
rule.maxdepth = 1
|
335
|
-
|
336
330
|
expect(rule.find).to eq([])
|
331
|
+
end
|
337
332
|
|
333
|
+
example 'find with maxdepth 2 returns expected results' do
|
334
|
+
pending if windows
|
338
335
|
rule.maxdepth = 2
|
339
336
|
expect(rule.find.map{ |e| File.basename(e) }).to eq(['a.foo'])
|
337
|
+
end
|
340
338
|
|
339
|
+
example 'find with maxdepth 3 returns expected results' do
|
340
|
+
pending if windows
|
341
341
|
rule.maxdepth = 3
|
342
|
-
expect(rule.find.map{ |e| File.basename(e) }).to
|
342
|
+
expect(rule.find.map{ |e| File.basename(e) }).to contain_exactly('a.foo', 'b.foo', 'c.foo')
|
343
343
|
end
|
344
344
|
|
345
|
-
example
|
345
|
+
example 'find with nil maxdepth option returns everything' do
|
346
|
+
pending if windows
|
346
347
|
rule.maxdepth = nil
|
347
348
|
results = ['a.foo', 'b.foo', 'c.foo', 'd.foo', 'e.foo', 'f.foo']
|
348
349
|
expect(rule.find.map{ |e| File.basename(e) }).to match_array(results)
|
349
350
|
end
|
350
351
|
|
351
|
-
example
|
352
|
-
rule.pattern =
|
353
|
-
|
352
|
+
example 'find with maxdepth 1 returns expected results for directories' do
|
353
|
+
rule.pattern = 'a3'
|
354
354
|
rule.maxdepth = 1
|
355
355
|
expect(rule.find).to eq([])
|
356
|
+
end
|
356
357
|
|
358
|
+
example 'find with maxdepth 2 returns expected results for directories' do
|
359
|
+
rule.pattern = 'a3'
|
357
360
|
rule.maxdepth = 2
|
358
361
|
expect(rule.find).to eq([])
|
362
|
+
end
|
359
363
|
|
364
|
+
example 'find with maxdepth 3 returns expected results for directories' do
|
365
|
+
pending if windows
|
366
|
+
rule.pattern = 'a3'
|
360
367
|
rule.maxdepth = 3
|
361
368
|
expect(rule.find.map{ |e| File.basename(e) }).to eq(['a3'])
|
362
369
|
end
|
363
370
|
end
|
364
371
|
|
365
|
-
context
|
372
|
+
context 'mindepth', :mindepth do
|
366
373
|
before do
|
367
|
-
|
368
|
-
rule.pattern =
|
374
|
+
FakeFS::FileSystem.add('a1/a2/a3')
|
375
|
+
rule.pattern = '*.min'
|
369
376
|
|
370
377
|
FileUtils.touch('z.min')
|
371
378
|
FileUtils.touch('a1/a.min')
|
@@ -376,52 +383,57 @@ RSpec.describe File::Find do
|
|
376
383
|
FileUtils.touch('a1/a2/a3/f.min')
|
377
384
|
end
|
378
385
|
|
379
|
-
example
|
386
|
+
example 'mindepth accessor basic functionality' do
|
380
387
|
expect(rule).to respond_to(:mindepth)
|
381
388
|
expect(rule).to respond_to(:mindepth=)
|
382
389
|
expect(rule.mindepth).to be_nil
|
383
390
|
end
|
384
391
|
|
385
|
-
example
|
392
|
+
example 'mindepth method returns expected default value' do
|
386
393
|
expect(rule.mindepth).to be_nil
|
387
394
|
end
|
388
395
|
|
389
|
-
example
|
396
|
+
example 'find with mindepth option returns expected results at depth 0' do
|
397
|
+
pending if windows
|
390
398
|
rule.mindepth = 0
|
391
399
|
array = ['a.min', 'b.min', 'c.min', 'd.min', 'e.min', 'f.min', 'z.min']
|
392
400
|
expect(rule.find.map{ |e| File.basename(e) }).to match_array(array)
|
393
401
|
end
|
394
402
|
|
395
|
-
example
|
403
|
+
example 'find with mindepth option returns expected results at depth 1' do
|
404
|
+
pending if windows
|
396
405
|
rule.mindepth = 1
|
397
406
|
array = ['a.min', 'b.min', 'c.min', 'd.min', 'e.min', 'f.min', 'z.min']
|
398
407
|
expect(rule.find.map{ |e| File.basename(e) }).to match_array(array)
|
399
408
|
end
|
400
409
|
|
401
|
-
example
|
410
|
+
example 'find with mindepth option returns expected results at depth 2' do
|
411
|
+
pending if windows
|
402
412
|
rule.mindepth = 2
|
403
413
|
array = ['a.min', 'b.min', 'c.min', 'd.min', 'e.min', 'f.min']
|
404
414
|
expect(rule.find.map{ |e| File.basename(e) }).to match_array(array)
|
405
415
|
end
|
406
416
|
|
407
|
-
example
|
417
|
+
example 'find with mindepth option returns expected results at depth 3' do
|
418
|
+
pending if windows
|
408
419
|
rule.mindepth = 3
|
409
420
|
array = ['b.min', 'c.min', 'd.min', 'e.min', 'f.min']
|
410
421
|
expect(rule.find.map{ |e| File.basename(e) }).to match_array(array)
|
411
422
|
end
|
412
423
|
|
413
|
-
example
|
424
|
+
example 'find with mindepth option returns expected results at depth 4' do
|
425
|
+
pending if windows
|
414
426
|
rule.mindepth = 4
|
415
427
|
array = ['d.min', 'e.min', 'f.min']
|
416
428
|
expect(rule.find.map{ |e| File.basename(e) }).to match_array(array)
|
417
429
|
end
|
418
430
|
|
419
|
-
example
|
431
|
+
example 'find with mindepth option returns expected results at depth 5' do
|
420
432
|
rule.mindepth = 5
|
421
433
|
expect(rule.find.map{ |e| File.basename(e) }).to eq([])
|
422
434
|
end
|
423
435
|
|
424
|
-
example
|
436
|
+
example 'find with mindepth option returns expected results for directories' do
|
425
437
|
rule.pattern = 'a1'
|
426
438
|
rule.mindepth = 1
|
427
439
|
|
@@ -435,34 +447,37 @@ RSpec.describe File::Find do
|
|
435
447
|
end
|
436
448
|
end
|
437
449
|
|
438
|
-
context
|
439
|
-
example
|
450
|
+
context 'mount', :mount do
|
451
|
+
example 'mount accessor basic functionality' do
|
440
452
|
expect(rule).to respond_to(:mount)
|
441
453
|
expect(rule).to respond_to(:mount=)
|
442
454
|
end
|
443
455
|
|
444
|
-
example
|
456
|
+
example 'mount method returns expected default value' do
|
445
457
|
expect(rule.mount).to be_nil
|
446
458
|
end
|
447
459
|
end
|
448
460
|
|
449
|
-
context
|
450
|
-
example
|
461
|
+
context 'name', :name do
|
462
|
+
example 'name accessor basic functionality' do
|
451
463
|
expect(rule).to respond_to(:name)
|
452
464
|
expect(rule).to respond_to(:name=)
|
453
465
|
end
|
454
466
|
|
455
|
-
example
|
467
|
+
example 'name method returns expected default value' do
|
456
468
|
expect(txt_rule.name).to eq('*.txt')
|
457
469
|
end
|
458
470
|
|
459
|
-
example
|
471
|
+
example 'pattern is an alias for name' do
|
460
472
|
expect(rule.method(:name)).to eq(rule.method(:pattern))
|
461
473
|
expect(rule.method(:name=)).to eq(rule.method(:pattern=))
|
462
474
|
end
|
463
475
|
end
|
464
476
|
|
465
|
-
context
|
477
|
+
context 'perm', :perm do
|
478
|
+
let(:text_file1) { 'file_find_test1.txt' }
|
479
|
+
let(:text_file2) { 'file_find_test2.txt' }
|
480
|
+
|
466
481
|
before do
|
467
482
|
FileUtils.touch(ruby_file)
|
468
483
|
FileUtils.touch(text_file1)
|
@@ -472,27 +487,27 @@ RSpec.describe File::Find do
|
|
472
487
|
File.chmod(0644, text_file2)
|
473
488
|
end
|
474
489
|
|
475
|
-
example
|
490
|
+
example 'perm accessor basic functionality' do
|
476
491
|
expect(rule).to respond_to(:perm)
|
477
492
|
expect(rule).to respond_to(:perm=)
|
478
493
|
end
|
479
494
|
|
480
|
-
example
|
495
|
+
example 'perm method returns expected default value' do
|
481
496
|
expect(rule.perm).to be_nil
|
482
497
|
end
|
483
498
|
|
484
|
-
example
|
485
|
-
results =
|
499
|
+
example 'perm method returns expected results' do
|
500
|
+
results = described_class.new(:name => '*test1*', :perm => 0644).find
|
486
501
|
|
487
502
|
expect(results.length).to eq(1)
|
488
503
|
expect(File.basename(results.first)).to eq(text_file1)
|
489
504
|
end
|
490
505
|
|
491
|
-
example
|
506
|
+
example 'perm method works with symbolic permissions' do
|
492
507
|
skip 'symbolic perm spec skipped on MS Windows' if windows
|
493
508
|
|
494
|
-
results1 =
|
495
|
-
results2 =
|
509
|
+
results1 = described_class.new(:name => 'file*', :perm => 'g=rw').find
|
510
|
+
results2 = described_class.new(:name => 'file*', :perm => 'u=rw').find
|
496
511
|
|
497
512
|
expect(results1.length).to eq(1)
|
498
513
|
expect(results2.length).to eq(2)
|
@@ -501,97 +516,107 @@ RSpec.describe File::Find do
|
|
501
516
|
end
|
502
517
|
end
|
503
518
|
|
504
|
-
context
|
519
|
+
context 'prune', :prune do
|
520
|
+
let(:prune_file) { 'file_find_test_prune.txt' }
|
521
|
+
|
505
522
|
before do
|
506
|
-
FileUtils.touch(
|
523
|
+
FileUtils.touch(prune_file)
|
507
524
|
end
|
508
525
|
|
509
|
-
example
|
526
|
+
example 'prune accessor basic functionality' do
|
510
527
|
expect(rule).to respond_to(:prune)
|
511
528
|
expect(rule).to respond_to(:prune=)
|
512
529
|
end
|
513
530
|
|
514
|
-
example
|
531
|
+
example 'prune method returns expected default value' do
|
515
532
|
expect(rule.prune).to be_nil
|
516
533
|
end
|
517
534
|
|
518
|
-
example
|
519
|
-
rule =
|
520
|
-
expect(File.basename(rule.find.first)).to eq(
|
535
|
+
example 'find method with prune option works as expected' do
|
536
|
+
rule = described_class.new(:name => '*.txt', :prune => 'foo')
|
537
|
+
expect(File.basename(rule.find.first)).to eq(prune_file)
|
521
538
|
end
|
522
539
|
end
|
523
540
|
|
524
|
-
context
|
525
|
-
example
|
541
|
+
context 'size', :size do
|
542
|
+
example 'size accessor basic functionality' do
|
526
543
|
expect(rule).to respond_to(:size)
|
527
544
|
expect(rule).to respond_to(:size=)
|
528
545
|
end
|
529
546
|
|
530
|
-
example
|
547
|
+
example 'size method returns expected default value' do
|
531
548
|
expect(rule.size).to be_nil
|
532
549
|
end
|
533
550
|
end
|
534
551
|
|
535
|
-
context
|
552
|
+
context 'user', :user do
|
536
553
|
before do
|
537
554
|
FileUtils.touch(doc_file)
|
538
555
|
end
|
539
556
|
|
540
|
-
example
|
557
|
+
example 'user accessor basic functionality' do
|
541
558
|
expect(rule).to respond_to(:user)
|
542
559
|
expect(rule).to respond_to(:user=)
|
543
560
|
end
|
544
561
|
|
545
|
-
example
|
562
|
+
example 'user method returns expected default value' do
|
546
563
|
expect(rule.user).to be_nil
|
547
564
|
end
|
548
565
|
|
549
|
-
example
|
566
|
+
example 'user method works with numeric id as expected' do
|
567
|
+
pending if windows # TODO: Get this working on Windows
|
568
|
+
|
550
569
|
if windows && elevated
|
551
570
|
uid = @loguser.gid # Windows assigns the group if any member is an admin
|
552
571
|
else
|
553
572
|
uid = @loguser.uid
|
554
573
|
end
|
555
574
|
|
556
|
-
rule =
|
575
|
+
rule = described_class.new(:name => '*.doc', :user => uid)
|
557
576
|
expect(rule.find).to eq([File.expand_path(doc_file)])
|
558
577
|
end
|
559
578
|
|
560
|
-
example
|
579
|
+
example 'user method works with string as expected' do
|
580
|
+
pending if windows # TODO: Get this working on Windows
|
581
|
+
|
561
582
|
skip if windows && elevated
|
562
|
-
rule =
|
583
|
+
rule = described_class.new(:name => '*.doc', :user => @loguser.name)
|
563
584
|
expect(rule.find).to eq([File.expand_path(doc_file)])
|
564
585
|
end
|
565
586
|
|
566
|
-
example
|
567
|
-
rule1 =
|
568
|
-
rule2 =
|
587
|
+
example 'find method with user option using invalid user returns expected results' do
|
588
|
+
rule1 = described_class.new(:name => '*.doc', :user => 'totallybogus')
|
589
|
+
rule2 = described_class.new(:name => '*.doc', :user => 99999999)
|
569
590
|
expect(rule1.find).to eq([])
|
570
591
|
expect(rule2.find).to eq([])
|
571
592
|
end
|
572
593
|
end
|
573
594
|
|
574
|
-
context
|
575
|
-
example
|
595
|
+
context 'previous', :previous do
|
596
|
+
example 'previous method basic functionality' do
|
576
597
|
expect(rule).to respond_to(:previous)
|
577
598
|
end
|
578
599
|
end
|
579
600
|
|
580
|
-
example
|
581
|
-
expect{
|
601
|
+
example 'an error is raised if the path does not exist' do
|
602
|
+
expect{ described_class.new(:path => '/bogus/dir').find }.to raise_error(Errno::ENOENT)
|
582
603
|
end
|
583
604
|
|
584
|
-
example
|
585
|
-
expect{
|
586
|
-
expect{
|
605
|
+
example 'an error is raised if an invalid option is passed' do
|
606
|
+
expect{ described_class.new(:bogus => 1) }.to raise_error(ArgumentError)
|
607
|
+
expect{ described_class.new(:bogus? => true) }.to raise_error(ArgumentError)
|
587
608
|
end
|
588
609
|
|
589
|
-
context
|
610
|
+
context 'eloop', :eloop do
|
590
611
|
# Have to disable fakefs for this test because of bug: https://github.com/fakefs/fakefs/issues/459
|
591
612
|
before do
|
592
613
|
FakeFS.deactivate!
|
593
614
|
end
|
594
615
|
|
616
|
+
after do
|
617
|
+
FakeFS.activate!
|
618
|
+
end
|
619
|
+
|
595
620
|
# TODO: Update example for Windows
|
596
621
|
example 'eloop handling works as expected' do
|
597
622
|
skip 'eloop handling example skipped on MS Windows' if windows
|
@@ -601,13 +626,9 @@ RSpec.describe File::Find do
|
|
601
626
|
File.symlink('eloop1', 'eloop0')
|
602
627
|
expected = ['./eloop0', './eloop1']
|
603
628
|
|
604
|
-
results =
|
629
|
+
results = described_class.new(:path => '.', :follow => true).find
|
605
630
|
expect(results.sort).to eq(expected)
|
606
631
|
end
|
607
632
|
end
|
608
|
-
|
609
|
-
after do
|
610
|
-
FakeFS.activate!
|
611
|
-
end
|
612
633
|
end
|
613
634
|
end
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: file-find
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Berger
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
ORVCZpRuCPpmC8qmqxUnARDArzucjaclkxjLWvCVHeFa9UP7K3Nl9oTjJNv+7/jM
|
36
36
|
WZs4eecIcUc4tKdHxcAJ0MO/Dkqq7hGaiHpwKY76wQ1+8xAh
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date:
|
38
|
+
date: 2025-06-18 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: sys-admin
|
@@ -71,14 +71,14 @@ dependencies:
|
|
71
71
|
requirements:
|
72
72
|
- - "~>"
|
73
73
|
- !ruby/object:Gem::Version
|
74
|
-
version: '
|
74
|
+
version: '3.0'
|
75
75
|
type: :development
|
76
76
|
prerelease: false
|
77
77
|
version_requirements: !ruby/object:Gem::Requirement
|
78
78
|
requirements:
|
79
79
|
- - "~>"
|
80
80
|
- !ruby/object:Gem::Version
|
81
|
-
version: '
|
81
|
+
version: '3.0'
|
82
82
|
- !ruby/object:Gem::Dependency
|
83
83
|
name: rake
|
84
84
|
requirement: !ruby/object:Gem::Requirement
|
@@ -93,6 +93,34 @@ dependencies:
|
|
93
93
|
- - ">="
|
94
94
|
- !ruby/object:Gem::Version
|
95
95
|
version: '0'
|
96
|
+
- !ruby/object:Gem::Dependency
|
97
|
+
name: rubocop
|
98
|
+
requirement: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
type: :development
|
104
|
+
prerelease: false
|
105
|
+
version_requirements: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: rubocop-rspec
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
type: :development
|
118
|
+
prerelease: false
|
119
|
+
version_requirements: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
96
124
|
description: |2
|
97
125
|
The file-find library provides a better, more object oriented approach
|
98
126
|
to finding files. It allows you to find files based on a variety of
|
@@ -103,31 +131,30 @@ executables: []
|
|
103
131
|
extensions: []
|
104
132
|
extra_rdoc_files: []
|
105
133
|
files:
|
134
|
+
- CHANGES.md
|
135
|
+
- Gemfile
|
106
136
|
- LICENSE
|
107
|
-
-
|
108
|
-
- spec
|
109
|
-
- spec/file_find_spec.rb
|
137
|
+
- MANIFEST.md
|
110
138
|
- README.md
|
111
139
|
- Rakefile
|
112
|
-
- MANIFEST.md
|
113
|
-
- certs
|
114
140
|
- certs/djberg96_pub.pem
|
115
|
-
-
|
141
|
+
- file-find.gemspec
|
116
142
|
- lib/file-find.rb
|
117
|
-
- lib/file
|
118
143
|
- lib/file/find.rb
|
119
|
-
-
|
120
|
-
- CHANGES.md
|
144
|
+
- spec/file_find_spec.rb
|
121
145
|
homepage: http://github.com/djberg96/file-find
|
122
146
|
licenses:
|
123
147
|
- Apache-2.0
|
124
148
|
metadata:
|
125
149
|
homepage_uri: https://github.com/djberg96/file-find
|
126
150
|
bug_tracker_uri: https://github.com/djberg96/file-find/issues
|
127
|
-
changelog_uri: https://github.com/djberg96/file-find/blob/
|
151
|
+
changelog_uri: https://github.com/djberg96/file-find/blob/main/CHANGES.md
|
128
152
|
documentation_uri: https://github.com/djberg96/file-find/wiki
|
129
153
|
source_code_uri: https://github.com/djberg96/file-find
|
130
154
|
wiki_uri: https://github.com/djberg96/file-find/wiki
|
155
|
+
rubygems_mfa_required: 'true'
|
156
|
+
github_repo: https://github.com/djberg96/file-find
|
157
|
+
funding_uri: https://github.com/sponsors/djberg96
|
131
158
|
post_install_message:
|
132
159
|
rdoc_options: []
|
133
160
|
require_paths:
|
@@ -143,7 +170,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
143
170
|
- !ruby/object:Gem::Version
|
144
171
|
version: '0'
|
145
172
|
requirements: []
|
146
|
-
rubygems_version: 3.
|
173
|
+
rubygems_version: 3.5.22
|
147
174
|
signing_key:
|
148
175
|
specification_version: 4
|
149
176
|
summary: A better way to find files
|
metadata.gz.sig
CHANGED
Binary file
|