file-find 0.3.6 → 0.3.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +9 -9
- data/CHANGES +4 -0
- data/file-find.gemspec +1 -1
- data/lib/file/find.rb +3 -3
- data/test/test_file_find.rb +38 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ODkxZjA0Y2IyNjQwOGJiMjVhYzBlOWM2MDJmNTU2YTA3YmRiNGVmZg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
7
|
-
|
6
|
+
MTlkYmUzYzBmOWE2Nzk0ZTVkMzk3OGU0NDZlZDg4MGM2MjRiN2I5OA==
|
7
|
+
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MjY4YzA4Y2I3ZTdkNWZmYWJmYTc1M2ZhMzQxOTk2MGJhOTllNmZjMzljMDUz
|
10
|
+
ZmZhYTVlNTk4MDMwYjkwYjA1N2ZiNmE3ODllNDBjMjU3YjcxMmFjZDg5MTU2
|
11
|
+
NWI3ZjkwMWQ5NjkyMDI4YzMxNjBiZjZkMjFjNDc5YzI3MTQ5NTk=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YjYyYTNmZGUyODI2OGZiZTA0MGJmYTg1OWFhOGFkMWY5Yjg5MjkyNmJkYjI1
|
14
|
+
MjI3NzcwM2VkMzc5YTkwYmY0MmE2ZTlkYWQ4NTU1ZDBmN2YyZTA1MzYwYTY1
|
15
|
+
NGQ2MmI3NmY4OWE4N2Q1MTk2NTM1OTI3YTQ2NjhjNWE5OTQ5MWM=
|
data/CHANGES
CHANGED
data/file-find.gemspec
CHANGED
data/lib/file/find.rb
CHANGED
@@ -10,7 +10,7 @@ end
|
|
10
10
|
|
11
11
|
class File::Find
|
12
12
|
# The version of the file-find library
|
13
|
-
VERSION = '0.3.
|
13
|
+
VERSION = '0.3.7'
|
14
14
|
|
15
15
|
# :stopdoc:
|
16
16
|
VALID_OPTIONS = %w/
|
@@ -236,7 +236,6 @@ class File::Find
|
|
236
236
|
file = File.join(path, file)
|
237
237
|
|
238
238
|
stat_method = @follow ? :stat : :lstat
|
239
|
-
|
240
239
|
# Skip files we cannot access, stale links, etc.
|
241
240
|
begin
|
242
241
|
stat_info = File.send(stat_method, file)
|
@@ -247,7 +246,8 @@ class File::Find
|
|
247
246
|
retry if stat_method.to_s != 'lstat'
|
248
247
|
end
|
249
248
|
|
250
|
-
|
249
|
+
# We need to escape any brackets in the directory name.
|
250
|
+
glob = File.join(File.dirname(file).gsub(/([\[\]])/,'\\\\\1'), @name)
|
251
251
|
|
252
252
|
# Dir[] doesn't like backslashes
|
253
253
|
if File::ALT_SEPARATOR
|
data/test/test_file_find.rb
CHANGED
@@ -63,7 +63,7 @@ class TC_File_Find < Test::Unit::TestCase
|
|
63
63
|
end
|
64
64
|
|
65
65
|
def test_version
|
66
|
-
assert_equal('0.3.
|
66
|
+
assert_equal('0.3.7', File::Find::VERSION)
|
67
67
|
end
|
68
68
|
|
69
69
|
def test_path
|
@@ -229,6 +229,41 @@ class TC_File_Find < Test::Unit::TestCase
|
|
229
229
|
assert_nil(@rule1.maxdepth)
|
230
230
|
end
|
231
231
|
|
232
|
+
# This test is a little uglier because we actually check to make sure
|
233
|
+
# we're looking at the right subdir, not just a filename shows up.
|
234
|
+
# I did this because I'm a little paranoid about the directory
|
235
|
+
# not getting mangled. - jlawler.
|
236
|
+
#
|
237
|
+
def test_dirs_with_brackets
|
238
|
+
omit_if(@@windows, 'dirs with brackets test skipped on MS Windows')
|
239
|
+
|
240
|
+
bracket_files = [ 'bracket/a[1]/a.foo', 'bracket/a [2] /b.foo', 'bracket/[a] b [c]/d.foo' ].sort
|
241
|
+
bracket_paths = [ 'bracket/a[1]', 'bracket/a [2] ', 'bracket/[a] b [c]', 'bracket/[z] x' ].sort
|
242
|
+
|
243
|
+
bracket_paths.each{ |e| mkpath(e) }
|
244
|
+
bracket_files.each{ |e| touch(e) }
|
245
|
+
|
246
|
+
@file_rule = File::Find.new(
|
247
|
+
:ftype => 'file',
|
248
|
+
:path => ['bracket']
|
249
|
+
)
|
250
|
+
|
251
|
+
@dir_rule = File::Find.new(
|
252
|
+
:path => ['bracket'],
|
253
|
+
:ftype => 'directory'
|
254
|
+
)
|
255
|
+
|
256
|
+
file_results = @file_rule.find.sort
|
257
|
+
|
258
|
+
assert_equal(bracket_files.size,file_results.size)
|
259
|
+
path = file_results.first.chomp(bracket_files.first)
|
260
|
+
|
261
|
+
# Confirm the first thing in results is the first thing in bracket_paths
|
262
|
+
assert_not_equal(path, file_results.first)
|
263
|
+
assert_equal(bracket_files, file_results.map{ |e| e.sub(path,'') }.sort )
|
264
|
+
assert_equal(bracket_paths, @dir_rule.find.sort )
|
265
|
+
end
|
266
|
+
|
232
267
|
def test_maxdepth_file
|
233
268
|
mkpath('a1/a2/a3')
|
234
269
|
touch('a1/a.foo')
|
@@ -246,7 +281,7 @@ class TC_File_Find < Test::Unit::TestCase
|
|
246
281
|
assert_equal(['a.foo'], @rule2.find.map{ |e| File.basename(e) })
|
247
282
|
|
248
283
|
@rule2.maxdepth = 3
|
249
|
-
assert_equal(['a.foo', 'b.foo', 'c.foo'], @rule2.find.map{ |e| File.basename(e) })
|
284
|
+
assert_equal(['a.foo', 'b.foo', 'c.foo'], @rule2.find.map{ |e| File.basename(e) }.sort)
|
250
285
|
|
251
286
|
@rule2.maxdepth = nil
|
252
287
|
assert_equal(
|
@@ -444,6 +479,7 @@ class TC_File_Find < Test::Unit::TestCase
|
|
444
479
|
rm_rf(@link1) unless @@windows
|
445
480
|
rm_rf('a')
|
446
481
|
rm_rf('a1')
|
482
|
+
rm_rf('bracket')
|
447
483
|
rm_rf('z.min') if File.exists?('z.min')
|
448
484
|
|
449
485
|
@rule1 = nil
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: file-find
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Berger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-01-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: test-unit
|
@@ -105,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
105
105
|
version: '0'
|
106
106
|
requirements: []
|
107
107
|
rubyforge_project: shards
|
108
|
-
rubygems_version: 2.
|
108
|
+
rubygems_version: 2.1.9
|
109
109
|
signing_key:
|
110
110
|
specification_version: 4
|
111
111
|
summary: A better way to find files
|