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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MTNmNWQwYTQ0NDdjNzQ5NDI4YjFjZWY0YjFmZjUzMmY0ZDJmZDNlZA==
4
+ ODkxZjA0Y2IyNjQwOGJiMjVhYzBlOWM2MDJmNTU2YTA3YmRiNGVmZg==
5
5
  data.tar.gz: !binary |-
6
- YzU0Mzg2ZjA1ZGE2ZDcyOTAxMDZkNWI5YWE3MzI3MDYxNGViYTJmYw==
7
- !binary "U0hBNTEy":
6
+ MTlkYmUzYzBmOWE2Nzk0ZTVkMzk3OGU0NDZlZDg4MGM2MjRiN2I5OA==
7
+ SHA512:
8
8
  metadata.gz: !binary |-
9
- YjM2Mjk1YTFlNmIwMzQ3YTNkNmIxOWNlZDE1YjEzOWFjOTVjMzBjNzMzZGYz
10
- YTJjNTJjYmQ0ZGYyM2ViYWY4YWJiNTg4YzFmNGUzNTBkNjQyNTUxYWZmNjRk
11
- ZGYxZDU3YTdjNDA1YjJmNWU0MjVkOTU4YzcwZjljNGMyZTMwNzA=
9
+ MjY4YzA4Y2I3ZTdkNWZmYWJmYTc1M2ZhMzQxOTk2MGJhOTllNmZjMzljMDUz
10
+ ZmZhYTVlNTk4MDMwYjkwYjA1N2ZiNmE3ODllNDBjMjU3YjcxMmFjZDg5MTU2
11
+ NWI3ZjkwMWQ5NjkyMDI4YzMxNjBiZjZkMjFjNDc5YzI3MTQ5NTk=
12
12
  data.tar.gz: !binary |-
13
- MDg3NjA3OGRiOWFhYzZmZjVkYTk5YjQ5MjRkMDQxZDYyNzZlOGIxMjVmNTUz
14
- MjZmMWMxZWY1ZWRhZWFlYzUzMGIxMGRhZTE0ODMxZGYyMjFhM2M4NDRmMjBh
15
- YTNkMTQ4MjhmMzQwN2RhNjg3ZDc4NmI2YmExNTJmOWMzOTgwMjU=
13
+ YjYyYTNmZGUyODI2OGZiZTA0MGJmYTg1OWFhOGFkMWY5Yjg5MjkyNmJkYjI1
14
+ MjI3NzcwM2VkMzc5YTkwYmY0MmE2ZTlkYWQ4NTU1ZDBmN2YyZTA1MzYwYTY1
15
+ NGQ2MmI3NmY4OWE4N2Q1MTk2NTM1OTI3YTQ2NjhjNWE5OTQ5MWM=
data/CHANGES CHANGED
@@ -1,3 +1,7 @@
1
+ == 0.3.7 - 15-Jan-2014
2
+ * Fixed a bug with brackets in the path name. Thanks go to Jeremy Lawler
3
+ for the spot and the patch.
4
+
1
5
  == 0.3.6 - 6-Sep-2013
2
6
  * Removed rbconfig from library and test file. Just use File::ALT_SEPARATOR
3
7
  to check for Windows instead.
@@ -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.3.6'
5
+ spec.version = '0.3.7'
6
6
  spec.author = 'Daniel Berger'
7
7
  spec.license = 'Artistic 2.0'
8
8
  spec.summary = 'A better way to find files'
@@ -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.6'
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
- glob = File.join(File.dirname(file), @name)
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
@@ -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.6', File::Find::VERSION)
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.6
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: 2013-09-06 00:00:00.000000000 Z
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.0.3
108
+ rubygems_version: 2.1.9
109
109
  signing_key:
110
110
  specification_version: 4
111
111
  summary: A better way to find files