file-find 0.5.2 → 0.5.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0febb67274c45e862fa242e53bda0d97895817bf6ff98fd055f769afaa5d0e60
4
- data.tar.gz: 20a42458a0f3b70e7bdffc6afd446be9b70e7417197ebbd3e4c9c1302d473559
3
+ metadata.gz: f14f3ba41e3f587f6a7f5206d8a1e6111d5b160b3e8dd5bb8126077def8a6ad9
4
+ data.tar.gz: dc7baffb76c1e1aff783944e3185b05e0a605ff379a23dd0fc826c21cddf6b5d
5
5
  SHA512:
6
- metadata.gz: 51cabd736d8aeb6c35cd1e7bb38de0ee4ccd96a79ccbe0b9a08a657e69d0d9250afc1e7680986721de5cd33f20ff459bd3afbff9e47c0960d4b47b666a02bc00
7
- data.tar.gz: 6ec15535aa08d5f78f81decbf7678f0c05f6ebd8978b5bb3eaef83c3fa315ed6414d696458008d1d2832bb3413747a0a21a0882f56019602064f859a8a82d0d4
6
+ metadata.gz: 7bba2f630c22ff5221e59a4a6128776e834c55200bea17aa355c85ffb21c0a96eb910b4bfb2d01f6e84e49071baa3aeda01d8046f70b76d344178c3e200f10aa
7
+ data.tar.gz: 59c2635c6da46debbbadf874121577b2c1d9a2149369df7976cfaa86d50a36a35f842ef365f76d5a6ae729f6879d0fea9b2c780a8c65b0ba8609403830e8a03e
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGES.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 0.5.3 - 4-Jan-2026
2
+ * Internal refactoring, some performance improvements.
3
+ * Dependency updates for Windows since Ruby 4+ no longer includes win32ole
4
+ in its stdlib. Use the gem instead.
5
+ * Some specs restored for Windows, and specs run with warnings enabled by default.
6
+
1
7
  ## 0.5.2 - 22-Nov-2025
2
8
  * Use fnmatch instead of some overworked checks for Windows paths using glob.
3
9
  * Minor refactoring improvements for atime/ctime/mtime checks.
data/README.md CHANGED
@@ -115,7 +115,7 @@ Apache-2.0
115
115
 
116
116
  ## Copyright
117
117
 
118
- (C) 2007-2025, Daniel J. Berger, All Rights Reserved
118
+ (C) 2007-2026, Daniel J. Berger, All Rights Reserved
119
119
 
120
120
  ## Author
121
121
 
data/Rakefile CHANGED
@@ -26,7 +26,7 @@ RuboCop::RakeTask.new
26
26
 
27
27
  RSpec::Core::RakeTask.new(:spec) do |t|
28
28
  t.pattern = ['spec/file_find_spec.rb']
29
- t.rspec_opts = '-f documentation'
29
+ t.rspec_opts = '-f documentation -w'
30
30
  end
31
31
 
32
32
  # Clean up afterwards
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.2'
5
+ spec.version = '0.5.3'
6
6
  spec.author = 'Daniel Berger'
7
7
  spec.license = 'Apache-2.0'
8
8
  spec.summary = 'A better way to find files'
@@ -25,6 +25,12 @@ Gem::Specification.new do |spec|
25
25
  }
26
26
 
27
27
  spec.add_dependency('sys-admin', '~> 1.7')
28
+
29
+ if Gem.win_platform?
30
+ spec.add_dependency('win32ole')
31
+ spec.add_dependency('win32-registry') # Until sys-admin gets updated properly
32
+ end
33
+
28
34
  spec.add_development_dependency('rspec', '~> 3.9')
29
35
  spec.add_development_dependency('fakefs', '~> 3.0')
30
36
  spec.add_development_dependency('rake')
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.2'
16
+ VERSION = '0.5.3'
17
17
 
18
18
  # :stopdoc:
19
19
  VALID_OPTIONS = %w[
@@ -225,16 +225,15 @@ class File::Find
225
225
  until queue.empty?
226
226
  path = queue.shift
227
227
  begin
228
- Dir.foreach(path) do |file|
229
- next if file == '.'
230
- next if file == '..'
228
+ Dir.children(path).each do |basename|
229
+ # Fast rejections before expensive operations
230
+ next if prune_regex && prune_regex.match(basename)
231
231
 
232
- if prune_regex && prune_regex.match(file)
233
- next
234
- end
235
-
236
- file = File.join(path, file)
232
+ # Check name pattern early to potentially skip stat
233
+ # (but we still need to stat directories to add them to queue)
234
+ matches_name = File.fnmatch?(@name, basename)
237
235
 
236
+ file = File.join(path, basename)
238
237
  stat_method = @follow ? :stat : :lstat
239
238
 
240
239
  # Skip files we cannot access, stale links, etc.
@@ -243,45 +242,47 @@ class File::Find
243
242
  rescue Errno::ENOENT, Errno::EACCES
244
243
  next
245
244
  rescue Errno::ELOOP
246
- if stat_method.to_s != 'lstat'
245
+ if stat_method != :lstat
247
246
  stat_method = :lstat # Handle recursive symlinks
248
247
  retry
249
248
  end
250
249
  end
251
250
 
251
+ # Skip non-directories that don't match name pattern early
252
+ next if !stat_info.directory? && !matches_name
253
+
252
254
  next if @mount && stat_info.dev != @filesystem
253
255
  next if @links && stat_info.nlink != @links
254
256
 
257
+ # Calculate depth early if needed for maxdepth/mindepth checks
255
258
  if @maxdepth || @mindepth
256
259
  file_depth = file.split(File::SEPARATOR).reject(&:empty?).length
257
260
  current_base_path = [@path].flatten.find{ |tpath| file.include?(tpath) }
258
261
  path_depth = current_base_path.split(File::SEPARATOR).length
259
-
260
262
  depth = file_depth - path_depth
263
+ end
261
264
 
262
- if @maxdepth && depth > @maxdepth
263
- if stat_info.directory? && !paths.include?(file)
264
- queue << file
265
- end
266
- next
265
+ # Early termination: don't even add directories to queue if beyond maxdepth
266
+ if stat_info.directory? && !paths.include?(file)
267
+ if @maxdepth && depth && depth >= @maxdepth
268
+ # At maxdepth, don't traverse into this directory
269
+ else
270
+ queue << file
267
271
  end
272
+ end
268
273
 
269
- if @mindepth && depth < @mindepth
270
- if stat_info.directory? && !paths.include?(file)
271
- queue << file
272
- end
273
- next
274
- end
274
+ # Skip files that are beyond maxdepth or before mindepth
275
+ if @maxdepth && depth && depth > @maxdepth
276
+ next
275
277
  end
276
278
 
277
- # Add directories back onto the list of paths to search unless
278
- # they've already been added
279
- #
280
- if stat_info.directory? && !paths.include?(file)
281
- queue << file
279
+ if @mindepth && depth && depth < @mindepth
280
+ next
282
281
  end
283
282
 
284
- next unless File.fnmatch?(@name, File.basename(file))
283
+ # For directories, always traverse but only yield if name matches
284
+ # For regular files, we already checked name above
285
+ next if stat_info.directory? && !matches_name
285
286
 
286
287
  if !@filetest.empty? && !@filetest.all? { |meth, bool| File.send(meth, file) == bool }
287
288
  next
@@ -34,7 +34,7 @@ RSpec.describe File::Find do
34
34
 
35
35
  context 'constants', :constants do
36
36
  example 'version constant is set to expected value' do
37
- expect(File::Find::VERSION).to eq('0.5.2')
37
+ expect(File::Find::VERSION).to eq('0.5.3')
38
38
  expect(File::Find::VERSION).to be_frozen
39
39
  end
40
40
  end
@@ -336,19 +336,16 @@ RSpec.describe File::Find do
336
336
  end
337
337
 
338
338
  example 'find with maxdepth 2 returns expected results' do
339
- pending if windows
340
339
  rule.maxdepth = 2
341
340
  expect(rule.find.map{ |e| File.basename(e) }).to eq(['a.foo'])
342
341
  end
343
342
 
344
343
  example 'find with maxdepth 3 returns expected results' do
345
- pending if windows
346
344
  rule.maxdepth = 3
347
345
  expect(rule.find.map{ |e| File.basename(e) }).to contain_exactly('a.foo', 'b.foo', 'c.foo')
348
346
  end
349
347
 
350
348
  example 'find with nil maxdepth option returns everything' do
351
- pending if windows
352
349
  rule.maxdepth = nil
353
350
  results = ['a.foo', 'b.foo', 'c.foo', 'd.foo', 'e.foo', 'f.foo']
354
351
  expect(rule.find.map{ |e| File.basename(e) }).to match_array(results)
@@ -367,7 +364,6 @@ RSpec.describe File::Find do
367
364
  end
368
365
 
369
366
  example 'find with maxdepth 3 returns expected results for directories' do
370
- pending if windows
371
367
  rule.pattern = 'a3'
372
368
  rule.maxdepth = 3
373
369
  expect(rule.find.map{ |e| File.basename(e) }).to eq(['a3'])
@@ -399,35 +395,30 @@ RSpec.describe File::Find do
399
395
  end
400
396
 
401
397
  example 'find with mindepth option returns expected results at depth 0' do
402
- pending if windows
403
398
  rule.mindepth = 0
404
399
  array = ['a.min', 'b.min', 'c.min', 'd.min', 'e.min', 'f.min', 'z.min']
405
400
  expect(rule.find.map{ |e| File.basename(e) }).to match_array(array)
406
401
  end
407
402
 
408
403
  example 'find with mindepth option returns expected results at depth 1' do
409
- pending if windows
410
404
  rule.mindepth = 1
411
405
  array = ['a.min', 'b.min', 'c.min', 'd.min', 'e.min', 'f.min', 'z.min']
412
406
  expect(rule.find.map{ |e| File.basename(e) }).to match_array(array)
413
407
  end
414
408
 
415
409
  example 'find with mindepth option returns expected results at depth 2' do
416
- pending if windows
417
410
  rule.mindepth = 2
418
411
  array = ['a.min', 'b.min', 'c.min', 'd.min', 'e.min', 'f.min']
419
412
  expect(rule.find.map{ |e| File.basename(e) }).to match_array(array)
420
413
  end
421
414
 
422
415
  example 'find with mindepth option returns expected results at depth 3' do
423
- pending if windows
424
416
  rule.mindepth = 3
425
417
  array = ['b.min', 'c.min', 'd.min', 'e.min', 'f.min']
426
418
  expect(rule.find.map{ |e| File.basename(e) }).to match_array(array)
427
419
  end
428
420
 
429
421
  example 'find with mindepth option returns expected results at depth 4' do
430
- pending if windows
431
422
  rule.mindepth = 4
432
423
  array = ['d.min', 'e.min', 'f.min']
433
424
  expect(rule.find.map{ |e| File.basename(e) }).to match_array(array)
@@ -583,7 +574,6 @@ RSpec.describe File::Find do
583
574
  end
584
575
 
585
576
  example 'user method works with string as expected' do
586
- pending if windows # TODO: Get this working on Windows
587
577
  skip 'user example skipped on Mac in CI' if macos && ENV['CI']
588
578
 
589
579
  skip if windows && elevated
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.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Berger
metadata.gz.sig CHANGED
Binary file