file-find 0.5.1 → 0.5.2
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 +3 -1
- data/CHANGES.md +8 -0
- data/MANIFEST.md +1 -1
- data/Rakefile +1 -0
- data/file-find.gemspec +2 -1
- data/lib/file/find.rb +18 -58
- data/spec/file_find_spec.rb +14 -7
- data.tar.gz.sig +0 -0
- metadata +17 -6
- 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: 0febb67274c45e862fa242e53bda0d97895817bf6ff98fd055f769afaa5d0e60
|
|
4
|
+
data.tar.gz: 20a42458a0f3b70e7bdffc6afd446be9b70e7417197ebbd3e4c9c1302d473559
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 51cabd736d8aeb6c35cd1e7bb38de0ee4ccd96a79ccbe0b9a08a657e69d0d9250afc1e7680986721de5cd33f20ff459bd3afbff9e47c0960d4b47b666a02bc00
|
|
7
|
+
data.tar.gz: 6ec15535aa08d5f78f81decbf7678f0c05f6ebd8978b5bb3eaef83c3fa315ed6414d696458008d1d2832bb3413747a0a21a0882f56019602064f859a8a82d0d4
|
checksums.yaml.gz.sig
CHANGED
|
@@ -1 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
����8�۵��
|
|
2
|
+
x�'�^g���V�t/��o�T���6�H�AềQ\.��ح�ڴ��M�4`9�D�cY�q���4�a�Aaʝ64S3"�r�l��얜�Oz���M�c���P�q�M�L/I�k��� �N������b����nO���!�{���ԗ�l�T���%�MT����麅�L�lv���ŷ�_���4�/�w�H������qi���Ju�4jL��i�
|
|
3
|
+
�g��_�e�r�ӳ���ӑn�@����'P���KV�V�oL�K�n��ն+���
|
data/CHANGES.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
## 0.5.2 - 22-Nov-2025
|
|
2
|
+
* Use fnmatch instead of some overworked checks for Windows paths using glob.
|
|
3
|
+
* Minor refactoring improvements for atime/ctime/mtime checks.
|
|
4
|
+
* Minor refactoring improvement for ftype check.
|
|
5
|
+
* Minor refactoring improvement for filetest check.
|
|
6
|
+
* Added MacOS and FreeBSD to the test matrix.
|
|
7
|
+
* The specs now run in documentation mode by default.
|
|
8
|
+
|
|
1
9
|
## 0.5.1 - 17-Jun-2025
|
|
2
10
|
* Updated, fixed or skipped some specs on Windows.
|
|
3
11
|
* Some rubocop cleanup and minor refactors.
|
data/MANIFEST.md
CHANGED
data/Rakefile
CHANGED
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.2'
|
|
6
6
|
spec.author = 'Daniel Berger'
|
|
7
7
|
spec.license = 'Apache-2.0'
|
|
8
8
|
spec.summary = 'A better way to find files'
|
|
@@ -30,6 +30,7 @@ Gem::Specification.new do |spec|
|
|
|
30
30
|
spec.add_development_dependency('rake')
|
|
31
31
|
spec.add_development_dependency('rubocop')
|
|
32
32
|
spec.add_development_dependency('rubocop-rspec')
|
|
33
|
+
spec.add_development_dependency('sys-uname')
|
|
33
34
|
|
|
34
35
|
spec.description = <<-EOF
|
|
35
36
|
The file-find library provides a better, more object oriented approach
|
data/lib/file/find.rb
CHANGED
|
@@ -13,7 +13,7 @@ end
|
|
|
13
13
|
# files on your filesystem.
|
|
14
14
|
class File::Find
|
|
15
15
|
# The version of the file-find library
|
|
16
|
-
VERSION = '0.5.
|
|
16
|
+
VERSION = '0.5.2'
|
|
17
17
|
|
|
18
18
|
# :stopdoc:
|
|
19
19
|
VALID_OPTIONS = %w[
|
|
@@ -111,7 +111,7 @@ class File::Find
|
|
|
111
111
|
attr_accessor :mtime
|
|
112
112
|
|
|
113
113
|
# The name pattern used to limit file searches. The patterns that are legal
|
|
114
|
-
# for
|
|
114
|
+
# for File.fnmatch are legal here. The default is '*', i.e. everything.
|
|
115
115
|
#
|
|
116
116
|
attr_accessor :name
|
|
117
117
|
|
|
@@ -212,7 +212,7 @@ class File::Find
|
|
|
212
212
|
#
|
|
213
213
|
def find
|
|
214
214
|
results = [] unless block_given?
|
|
215
|
-
paths = @path
|
|
215
|
+
paths = Array(@path)
|
|
216
216
|
queue = paths.dup
|
|
217
217
|
|
|
218
218
|
if @prune
|
|
@@ -236,6 +236,7 @@ class File::Find
|
|
|
236
236
|
file = File.join(path, file)
|
|
237
237
|
|
|
238
238
|
stat_method = @follow ? :stat : :lstat
|
|
239
|
+
|
|
239
240
|
# Skip files we cannot access, stale links, etc.
|
|
240
241
|
begin
|
|
241
242
|
stat_info = File.send(stat_method, file)
|
|
@@ -248,23 +249,8 @@ class File::Find
|
|
|
248
249
|
end
|
|
249
250
|
end
|
|
250
251
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
glob = File.join(temp, @name)
|
|
254
|
-
|
|
255
|
-
# Dir[] doesn't like backslashes
|
|
256
|
-
if File::ALT_SEPARATOR
|
|
257
|
-
file.tr!(File::ALT_SEPARATOR, File::SEPARATOR)
|
|
258
|
-
glob.tr!(File::ALT_SEPARATOR, File::SEPARATOR)
|
|
259
|
-
end
|
|
260
|
-
|
|
261
|
-
if @mount && stat_info.dev != @filesystem
|
|
262
|
-
next
|
|
263
|
-
end
|
|
264
|
-
|
|
265
|
-
if @links && stat_info.nlink != @links
|
|
266
|
-
next
|
|
267
|
-
end
|
|
252
|
+
next if @mount && stat_info.dev != @filesystem
|
|
253
|
+
next if @links && stat_info.nlink != @links
|
|
268
254
|
|
|
269
255
|
if @maxdepth || @mindepth
|
|
270
256
|
file_depth = file.split(File::SEPARATOR).reject(&:empty?).length
|
|
@@ -273,15 +259,15 @@ class File::Find
|
|
|
273
259
|
|
|
274
260
|
depth = file_depth - path_depth
|
|
275
261
|
|
|
276
|
-
if @maxdepth &&
|
|
277
|
-
if
|
|
262
|
+
if @maxdepth && depth > @maxdepth
|
|
263
|
+
if stat_info.directory? && !paths.include?(file)
|
|
278
264
|
queue << file
|
|
279
265
|
end
|
|
280
266
|
next
|
|
281
267
|
end
|
|
282
268
|
|
|
283
|
-
if @mindepth &&
|
|
284
|
-
if
|
|
269
|
+
if @mindepth && depth < @mindepth
|
|
270
|
+
if stat_info.directory? && !paths.include?(file)
|
|
285
271
|
queue << file
|
|
286
272
|
end
|
|
287
273
|
next
|
|
@@ -295,46 +281,20 @@ class File::Find
|
|
|
295
281
|
queue << file
|
|
296
282
|
end
|
|
297
283
|
|
|
298
|
-
next unless
|
|
284
|
+
next unless File.fnmatch?(@name, File.basename(file))
|
|
299
285
|
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
@filetest.each do |array|
|
|
304
|
-
meth = array[0]
|
|
305
|
-
bool = array[1]
|
|
306
|
-
|
|
307
|
-
unless File.send(meth, file) == bool
|
|
308
|
-
file_test = false
|
|
309
|
-
break
|
|
310
|
-
end
|
|
311
|
-
end
|
|
312
|
-
|
|
313
|
-
next unless file_test
|
|
286
|
+
if !@filetest.empty? && !@filetest.all? { |meth, bool| File.send(meth, file) == bool }
|
|
287
|
+
next
|
|
314
288
|
end
|
|
315
289
|
|
|
316
290
|
if @atime || @ctime || @mtime
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
if @
|
|
320
|
-
|
|
321
|
-
next unless (date1 - date2).numerator == @atime
|
|
322
|
-
end
|
|
323
|
-
|
|
324
|
-
if @ctime
|
|
325
|
-
date2 = Date.parse(stat_info.ctime.to_s)
|
|
326
|
-
next unless (date1 - date2).numerator == @ctime
|
|
327
|
-
end
|
|
328
|
-
|
|
329
|
-
if @mtime
|
|
330
|
-
date2 = Date.parse(stat_info.mtime.to_s)
|
|
331
|
-
next unless (date1 - date2).numerator == @mtime
|
|
332
|
-
end
|
|
291
|
+
now = Date.today
|
|
292
|
+
next if @atime && (now - stat_info.atime.to_date).to_i != @atime
|
|
293
|
+
next if @ctime && (now - stat_info.ctime.to_date).to_i != @ctime
|
|
294
|
+
next if @mtime && (now - stat_info.mtime.to_date).to_i != @mtime
|
|
333
295
|
end
|
|
334
296
|
|
|
335
|
-
if @ftype &&
|
|
336
|
-
next
|
|
337
|
-
end
|
|
297
|
+
next if @ftype && stat_info.ftype != @ftype
|
|
338
298
|
|
|
339
299
|
if @group
|
|
340
300
|
if @group.is_a?(String)
|
data/spec/file_find_spec.rb
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
require 'rspec'
|
|
10
10
|
require 'file-find'
|
|
11
11
|
require 'sys-admin'
|
|
12
|
+
require 'sys-uname'
|
|
12
13
|
require 'tmpdir'
|
|
13
14
|
require 'pp' # Goofy workaround for FakeFS bug
|
|
14
15
|
require 'fakefs/spec_helpers'
|
|
@@ -16,23 +17,24 @@ require 'fakefs/spec_helpers'
|
|
|
16
17
|
RSpec.describe File::Find do
|
|
17
18
|
include FakeFS::SpecHelpers
|
|
18
19
|
|
|
19
|
-
let(:windows)
|
|
20
|
-
let(:
|
|
21
|
-
let(:
|
|
22
|
-
let(:
|
|
20
|
+
let(:windows) { Sys::Platform.windows? }
|
|
21
|
+
let(:macos) { Sys::Platform.mac? }
|
|
22
|
+
let(:elevated) { windows and Win32::Security.elevated_security? }
|
|
23
|
+
let(:ruby_file) { 'file_find_test.rb' }
|
|
24
|
+
let(:doc_file) { 'file_find_test.doc' }
|
|
23
25
|
|
|
24
26
|
let(:rule) { described_class.new }
|
|
25
27
|
let(:txt_rule) { described_class.new(:name => '*.txt') }
|
|
26
28
|
|
|
27
29
|
before(:all) do
|
|
28
30
|
@loguser = Sys::Admin.get_user(Sys::Admin.get_login)
|
|
29
|
-
group =
|
|
31
|
+
group = Sys::Platform.windows? ? 'Users' : @loguser.gid
|
|
30
32
|
@logroup = Sys::Admin.get_group(group)
|
|
31
33
|
end
|
|
32
34
|
|
|
33
35
|
context 'constants', :constants do
|
|
34
36
|
example 'version constant is set to expected value' do
|
|
35
|
-
expect(File::Find::VERSION).to eq('0.5.
|
|
37
|
+
expect(File::Find::VERSION).to eq('0.5.2')
|
|
36
38
|
expect(File::Find::VERSION).to be_frozen
|
|
37
39
|
end
|
|
38
40
|
end
|
|
@@ -209,6 +211,8 @@ RSpec.describe File::Find do
|
|
|
209
211
|
# TODO: Update example for Windows
|
|
210
212
|
example 'find with numeric group id works as expected' do
|
|
211
213
|
skip 'group example skipped on MS Windows' if windows
|
|
214
|
+
skip 'group example skipped on Mac in CI' if macos && ENV['CI']
|
|
215
|
+
|
|
212
216
|
rule = described_class.new(:name => '*.doc', :group => @loguser.gid)
|
|
213
217
|
expect(rule.find).to eq([File.expand_path(doc_file)])
|
|
214
218
|
end
|
|
@@ -216,6 +220,7 @@ RSpec.describe File::Find do
|
|
|
216
220
|
# TODO: Update example for Windows
|
|
217
221
|
example 'find with string group id works as expected' do
|
|
218
222
|
skip 'group example skipped on MS Windows' if windows
|
|
223
|
+
skip 'group example skipped on Mac in CI' if macos && ENV['CI']
|
|
219
224
|
|
|
220
225
|
rule = described_class.new(:name => '*.doc', :group => @logroup.name)
|
|
221
226
|
expect(rule.find).to eq([File.expand_path(doc_file)])
|
|
@@ -269,7 +274,7 @@ RSpec.describe File::Find do
|
|
|
269
274
|
end
|
|
270
275
|
|
|
271
276
|
example 'links method returns expected result' do
|
|
272
|
-
skip if windows && !elevated
|
|
277
|
+
skip if windows # && !elevated # TODO: Adjust for drive letter.
|
|
273
278
|
|
|
274
279
|
rule1 = described_class.new(:name => '*.rb', :links => 2)
|
|
275
280
|
rule2 = described_class.new(:name => '*.doc', :links => 1)
|
|
@@ -565,6 +570,7 @@ RSpec.describe File::Find do
|
|
|
565
570
|
|
|
566
571
|
example 'user method works with numeric id as expected' do
|
|
567
572
|
pending if windows # TODO: Get this working on Windows
|
|
573
|
+
skip 'user example skipped on Mac in CI' if macos && ENV['CI']
|
|
568
574
|
|
|
569
575
|
if windows && elevated
|
|
570
576
|
uid = @loguser.gid # Windows assigns the group if any member is an admin
|
|
@@ -578,6 +584,7 @@ RSpec.describe File::Find do
|
|
|
578
584
|
|
|
579
585
|
example 'user method works with string as expected' do
|
|
580
586
|
pending if windows # TODO: Get this working on Windows
|
|
587
|
+
skip 'user example skipped on Mac in CI' if macos && ENV['CI']
|
|
581
588
|
|
|
582
589
|
skip if windows && elevated
|
|
583
590
|
rule = described_class.new(:name => '*.doc', :user => @loguser.name)
|
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
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.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Daniel Berger
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain:
|
|
11
10
|
- |
|
|
@@ -35,7 +34,7 @@ cert_chain:
|
|
|
35
34
|
ORVCZpRuCPpmC8qmqxUnARDArzucjaclkxjLWvCVHeFa9UP7K3Nl9oTjJNv+7/jM
|
|
36
35
|
WZs4eecIcUc4tKdHxcAJ0MO/Dkqq7hGaiHpwKY76wQ1+8xAh
|
|
37
36
|
-----END CERTIFICATE-----
|
|
38
|
-
date:
|
|
37
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
39
38
|
dependencies:
|
|
40
39
|
- !ruby/object:Gem::Dependency
|
|
41
40
|
name: sys-admin
|
|
@@ -121,6 +120,20 @@ dependencies:
|
|
|
121
120
|
- - ">="
|
|
122
121
|
- !ruby/object:Gem::Version
|
|
123
122
|
version: '0'
|
|
123
|
+
- !ruby/object:Gem::Dependency
|
|
124
|
+
name: sys-uname
|
|
125
|
+
requirement: !ruby/object:Gem::Requirement
|
|
126
|
+
requirements:
|
|
127
|
+
- - ">="
|
|
128
|
+
- !ruby/object:Gem::Version
|
|
129
|
+
version: '0'
|
|
130
|
+
type: :development
|
|
131
|
+
prerelease: false
|
|
132
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
133
|
+
requirements:
|
|
134
|
+
- - ">="
|
|
135
|
+
- !ruby/object:Gem::Version
|
|
136
|
+
version: '0'
|
|
124
137
|
description: |2
|
|
125
138
|
The file-find library provides a better, more object oriented approach
|
|
126
139
|
to finding files. It allows you to find files based on a variety of
|
|
@@ -155,7 +168,6 @@ metadata:
|
|
|
155
168
|
rubygems_mfa_required: 'true'
|
|
156
169
|
github_repo: https://github.com/djberg96/file-find
|
|
157
170
|
funding_uri: https://github.com/sponsors/djberg96
|
|
158
|
-
post_install_message:
|
|
159
171
|
rdoc_options: []
|
|
160
172
|
require_paths:
|
|
161
173
|
- lib
|
|
@@ -170,8 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
170
182
|
- !ruby/object:Gem::Version
|
|
171
183
|
version: '0'
|
|
172
184
|
requirements: []
|
|
173
|
-
rubygems_version: 3.
|
|
174
|
-
signing_key:
|
|
185
|
+
rubygems_version: 3.6.9
|
|
175
186
|
specification_version: 4
|
|
176
187
|
summary: A better way to find files
|
|
177
188
|
test_files:
|
metadata.gz.sig
CHANGED
|
Binary file
|