pathname2 1.8.4 → 2.0.0

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.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/CHANGES.md +7 -0
  4. data/Gemfile +2 -3
  5. data/MANIFEST.md +2 -2
  6. data/README.md +6 -0
  7. data/Rakefile +227 -222
  8. data/benchmarks/bench_pathname2.rb +127 -0
  9. data/examples/{example_pathname.rb → example_pathname2.rb} +7 -7
  10. data/lib/pathname2.rb +160 -169
  11. data/pathname2.gemspec +13 -9
  12. data/test/{test_pathname.rb → test_pathname2.rb} +67 -63
  13. data/test/test_version.rb +3 -3
  14. data/test/windows/test_append.rb +7 -7
  15. data/test/windows/test_aref.rb +3 -3
  16. data/test/windows/test_ascend.rb +5 -5
  17. data/test/windows/test_children.rb +7 -7
  18. data/test/windows/test_clean.rb +17 -17
  19. data/test/windows/test_clean_bang.rb +17 -17
  20. data/test/windows/test_constructor.rb +12 -12
  21. data/test/windows/test_descend.rb +5 -5
  22. data/test/windows/test_drive_number.rb +13 -13
  23. data/test/windows/test_each.rb +3 -3
  24. data/test/windows/test_facade.rb +6 -6
  25. data/test/windows/test_is_absolute.rb +8 -8
  26. data/test/windows/test_is_relative.rb +7 -7
  27. data/test/windows/test_is_root.rb +8 -8
  28. data/test/windows/test_is_unc.rb +18 -18
  29. data/test/windows/test_join.rb +8 -8
  30. data/test/windows/test_long_path.rb +6 -6
  31. data/test/windows/test_misc.rb +7 -7
  32. data/test/windows/test_parent.rb +9 -9
  33. data/test/windows/test_pstrip.rb +9 -9
  34. data/test/windows/test_pstrip_bang.rb +10 -10
  35. data/test/windows/test_realpath.rb +5 -5
  36. data/test/windows/test_relative_path_from.rb +4 -4
  37. data/test/windows/test_root.rb +14 -14
  38. data/test/windows/test_short_path.rb +6 -6
  39. data/test/windows/test_to_a.rb +12 -12
  40. data/test/windows/test_undecorate.rb +12 -12
  41. data/test/windows/test_undecorate_bang.rb +13 -13
  42. data.tar.gz.sig +0 -0
  43. metadata +61 -54
  44. metadata.gz.sig +0 -0
  45. data/benchmarks/bench_pathname.rb +0 -127
data/pathname2.gemspec CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'pathname2'
5
- spec.version = '1.8.4'
5
+ spec.version = '2.0.0'
6
6
  spec.author = 'Daniel J. Berger'
7
7
  spec.license = 'Apache-2.0'
8
8
  spec.email = 'djberg96@gmail.com'
@@ -11,17 +11,21 @@ Gem::Specification.new do |spec|
11
11
  spec.files = Dir['**/*'].reject{ |f| f.include?('git') }
12
12
  spec.cert_chain = ['certs/djberg96_pub.pem']
13
13
 
14
- spec.add_dependency('facade')
15
- spec.add_development_dependency('test-unit')
14
+ spec.add_dependency('facade', '~> 1.2')
15
+ spec.add_dependency('addressable', '~> 2.8')
16
+ spec.add_development_dependency('test-unit', '~> 3.4')
16
17
  spec.add_development_dependency('rake')
17
18
 
18
19
  spec.metadata = {
19
- 'homepage_uri' => 'https://github.com/djberg96/pathname2',
20
- 'bug_tracker_uri' => 'https://github.com/djberg96/pathname2/issues',
21
- 'changelog_uri' => 'https://github.com/djberg96/pathname2/blob/ffi/CHANGES.md',
22
- 'documentation_uri' => 'https://github.com/djberg96/pathname2/wiki',
23
- 'source_code_uri' => 'https://github.com/djberg96/pathname2',
24
- 'wiki_uri' => 'https://github.com/djberg96/pathname2/wiki'
20
+ 'homepage_uri' => 'https://github.com/djberg96/pathname2',
21
+ 'bug_tracker_uri' => 'https://github.com/djberg96/pathname2/issues',
22
+ 'changelog_uri' => 'https://github.com/djberg96/pathname2/blob/main/CHANGES.md',
23
+ 'documentation_uri' => 'https://github.com/djberg96/pathname2/wiki',
24
+ 'source_code_uri' => 'https://github.com/djberg96/pathname2',
25
+ 'wiki_uri' => 'https://github.com/djberg96/pathname2/wiki',
26
+ 'rubygems_mfa_required' => 'true',
27
+ 'github_repo' => 'https://github.com/djberg96/pathname2',
28
+ 'funding_uri' => 'https://github.com/sponsors/djberg96'
25
29
  }
26
30
 
27
31
  if File::ALT_SEPARATOR
@@ -10,27 +10,27 @@ require 'rbconfig'
10
10
  require 'test-unit'
11
11
  include RbConfig
12
12
 
13
- class MyPathname < Pathname; end
13
+ class MyPathname2 < Pathname2; end
14
14
 
15
- class TC_Pathname < Test::Unit::TestCase
15
+ class TC_Pathname2 < Test::Unit::TestCase
16
16
  def self.startup
17
17
  Dir.chdir(File.expand_path(File.dirname(__FILE__)))
18
18
  @@pwd = Dir.pwd
19
19
  end
20
20
 
21
21
  def setup
22
- @abs_path = Pathname.new('/usr/local/bin')
23
- @rel_path = Pathname.new('usr/local/bin')
24
- @trl_path = Pathname.new('/usr/local/bin/')
25
- @mul_path = Pathname.new('/usr/local/lib/local/lib')
26
- @rul_path = Pathname.new('usr/local/lib/local/lib')
27
- @url_path = Pathname.new('file:///foo%20bar/baz')
28
- @cur_path = Pathname.new(@@pwd)
22
+ @abs_path = Pathname2.new('/usr/local/bin')
23
+ @rel_path = Pathname2.new('usr/local/bin')
24
+ @trl_path = Pathname2.new('/usr/local/bin/')
25
+ @mul_path = Pathname2.new('/usr/local/lib/local/lib')
26
+ @rul_path = Pathname2.new('usr/local/lib/local/lib')
27
+ @url_path = Pathname2.new('file:///foo%20bar/baz')
28
+ @cur_path = Pathname2.new(@@pwd)
29
29
 
30
30
  @abs_array = []
31
31
  @rel_array = []
32
32
 
33
- @mypath = MyPathname.new('/usr/bin')
33
+ @mypath = MyPathname2.new('/usr/bin')
34
34
 
35
35
  @test_file = 'realpath_test.txt'
36
36
  @link_file = 'realpath_symlink.txt'
@@ -46,28 +46,32 @@ class TC_Pathname < Test::Unit::TestCase
46
46
 
47
47
  # Convenience method for test_plus
48
48
  def assert_pathname_plus(a, b, c)
49
- a = Pathname.new(a)
50
- b = Pathname.new(b)
51
- c = Pathname.new(c)
49
+ a = Pathname2.new(a)
50
+ b = Pathname2.new(b)
51
+ c = Pathname2.new(c)
52
52
  assert_equal(a, b + c)
53
53
  end
54
54
 
55
55
  # Convenience method for test_spaceship operator
56
56
  def assert_pathname_cmp(int, s1, s2)
57
- p1 = Pathname.new(s1)
58
- p2 = Pathname.new(s2)
57
+ p1 = Pathname2.new(s1)
58
+ p2 = Pathname2.new(s2)
59
59
  result = p1 <=> p2
60
60
  assert_equal(int, result)
61
61
  end
62
62
 
63
63
  # Convenience method for test_relative_path_from
64
64
  def assert_relpath(result, dest, base)
65
- assert_equal(result, Pathname.new(dest).relative_path_from(base))
65
+ assert_equal(result, Pathname2.new(dest).relative_path_from(base))
66
66
  end
67
67
 
68
68
  # Convenience method for test_relative_path_from_expected_errors
69
69
  def assert_relpath_err(to, from)
70
- assert_raise(ArgumentError) { Pathname.new(to).relative_path_from(from) }
70
+ assert_raise(ArgumentError) { Pathname2.new(to).relative_path_from(from) }
71
+ end
72
+
73
+ test "VERSION constant is set to expected value" do
74
+ assert_equal("2.0.0", Pathname2::VERSION)
71
75
  end
72
76
 
73
77
  test "url_path returns expected result" do
@@ -77,20 +81,20 @@ class TC_Pathname < Test::Unit::TestCase
77
81
  test "realpath basic functionality" do
78
82
  FileUtils.touch(@test_file) && File.symlink(@test_file, @link_file)
79
83
  assert_respond_to(@abs_path, :realpath)
80
- assert_equal(@@pwd, Pathname.new('.').realpath)
81
- assert_kind_of(Pathname, Pathname.new(@link_file).realpath)
84
+ assert_equal(@@pwd, Pathname2.new('.').realpath)
85
+ assert_kind_of(Pathname2, Pathname2.new(@link_file).realpath)
82
86
  end
83
87
 
84
88
  test "realpath returns expected result for simple symlink" do
85
89
  FileUtils.touch(@test_file) && File.symlink(@test_file, @link_file)
86
- assert_true(Pathname.new(@link_file) != Pathname.new(@link_file).realpath)
87
- assert_raises(Errno::ENOENT){ Pathname.new('../bogus').realpath }
90
+ assert_true(Pathname2.new(@link_file) != Pathname2.new(@link_file).realpath)
91
+ assert_raises(Errno::ENOENT){ Pathname2.new('../bogus').realpath }
88
92
  end
89
93
 
90
94
  test "realpath returns expected result for nested symlink" do
91
95
  FileUtils.touch(@test_file) && File.symlink(@test_file, @link_file) && File.symlink(@link_file, @link_file2)
92
- assert_true(Pathname.new(@link_file) != Pathname.new(@link_file2).realpath)
93
- assert_equal(Pathname.new(@link_file).realpath, Pathname.new(@link_file2).realpath)
96
+ assert_true(Pathname2.new(@link_file) != Pathname2.new(@link_file2).realpath)
97
+ assert_equal(Pathname2.new(@link_file).realpath, Pathname2.new(@link_file2).realpath)
94
98
  end
95
99
 
96
100
  # These tests taken directly from Tanaka's pathname.rb. The one failure
@@ -144,7 +148,7 @@ class TC_Pathname < Test::Unit::TestCase
144
148
  assert_respond_to(@abs_path, :parent)
145
149
  assert_equal('/usr/local', @abs_path.parent)
146
150
  assert_equal('usr/local', @rel_path.parent)
147
- assert_equal('/', Pathname.new('/').parent)
151
+ assert_equal('/', Pathname2.new('/').parent)
148
152
  end
149
153
 
150
154
  def test_pstrip
@@ -211,7 +215,7 @@ class TC_Pathname < Test::Unit::TestCase
211
215
  children = @cur_path.children.sort.reject{ |f| f.include?('git') || f.include?('.swp') }
212
216
  assert_equal(
213
217
  [
214
- Dir.pwd + '/test_pathname.rb',
218
+ Dir.pwd + '/test_pathname2.rb',
215
219
  Dir.pwd + '/test_version.rb',
216
220
  Dir.pwd + '/windows'
217
221
  ],
@@ -223,7 +227,7 @@ class TC_Pathname < Test::Unit::TestCase
223
227
  assert_nothing_raised{ @cur_path.children(false) }
224
228
 
225
229
  children = @cur_path.children(false).reject{ |f| f.include?('git') || f.include?('.swp') }
226
- assert_equal(['test_pathname.rb', 'test_version.rb', 'windows'], children.sort)
230
+ assert_equal(['test_pathname2.rb', 'test_version.rb', 'windows'], children.sort)
227
231
  end
228
232
 
229
233
  def test_unc
@@ -250,8 +254,8 @@ class TC_Pathname < Test::Unit::TestCase
250
254
  assert_nothing_raised{ @abs_path.root? }
251
255
  assert_nothing_raised{ @rel_path.root? }
252
256
 
253
- path1 = Pathname.new('/')
254
- path2 = Pathname.new('a')
257
+ path1 = Pathname2.new('/')
258
+ path2 = Pathname2.new('a')
255
259
  assert_equal(true, path1.root?)
256
260
  assert_equal(false, path2.root?)
257
261
 
@@ -266,10 +270,10 @@ class TC_Pathname < Test::Unit::TestCase
266
270
  assert_equal(true, @abs_path.absolute?)
267
271
  assert_equal(false, @rel_path.absolute?)
268
272
 
269
- assert_equal(true, Pathname.new('/usr/bin/ruby').absolute?)
270
- assert_equal(false, Pathname.new('foo').absolute?)
271
- assert_equal(false, Pathname.new('foo/bar').absolute?)
272
- assert_equal(false, Pathname.new('../foo/bar').absolute?)
273
+ assert_equal(true, Pathname2.new('/usr/bin/ruby').absolute?)
274
+ assert_equal(false, Pathname2.new('foo').absolute?)
275
+ assert_equal(false, Pathname2.new('foo/bar').absolute?)
276
+ assert_equal(false, Pathname2.new('../foo/bar').absolute?)
273
277
 
274
278
  assert_non_destructive
275
279
  end
@@ -282,10 +286,10 @@ class TC_Pathname < Test::Unit::TestCase
282
286
  assert_equal(false, @abs_path.relative?)
283
287
  assert_equal(true, @rel_path.relative?)
284
288
 
285
- assert_equal(false, Pathname.new('/usr/bin/ruby').relative?)
286
- assert_equal(true, Pathname.new('foo').relative?)
287
- assert_equal(true, Pathname.new('foo/bar').relative?)
288
- assert_equal(true, Pathname.new('../foo/bar').relative?)
289
+ assert_equal(false, Pathname2.new('/usr/bin/ruby').relative?)
290
+ assert_equal(true, Pathname2.new('foo').relative?)
291
+ assert_equal(true, Pathname2.new('foo/bar').relative?)
292
+ assert_equal(true, Pathname2.new('../foo/bar').relative?)
289
293
 
290
294
  assert_non_destructive
291
295
  end
@@ -333,7 +337,7 @@ class TC_Pathname < Test::Unit::TestCase
333
337
  assert_pathname_plus('.', 'foo', '..')
334
338
 
335
339
  # Alias
336
- assert_equal('/foo/bar', Pathname.new('/foo') / Pathname.new('bar'))
340
+ assert_equal('/foo/bar', Pathname2.new('/foo') / Pathname2.new('bar'))
337
341
  end
338
342
 
339
343
  # Any tests marked with '***' mean that this behavior is different than
@@ -341,22 +345,22 @@ class TC_Pathname < Test::Unit::TestCase
341
345
  # implementation.
342
346
  def test_clean
343
347
  # Standard stuff
344
- assert_equal('/a/b/c', Pathname.new('/a/b/c').cleanpath)
345
- assert_equal('b/c', Pathname.new('./b/c').cleanpath)
346
- assert_equal('a', Pathname.new('a/.').cleanpath) # ***
347
- assert_equal('a/c', Pathname.new('a/./c').cleanpath)
348
- assert_equal('a/b', Pathname.new('a/b/.').cleanpath) # ***
349
- assert_equal('.', Pathname.new('a/../.').cleanpath) # ***
350
- assert_equal('/a', Pathname.new('/a/b/..').cleanpath)
351
- assert_equal('/b', Pathname.new('/a/../b').cleanpath)
352
- assert_equal('d', Pathname.new('a/../../d').cleanpath) # ***
348
+ assert_equal('/a/b/c', Pathname2.new('/a/b/c').cleanpath)
349
+ assert_equal('b/c', Pathname2.new('./b/c').cleanpath)
350
+ assert_equal('a', Pathname2.new('a/.').cleanpath) # ***
351
+ assert_equal('a/c', Pathname2.new('a/./c').cleanpath)
352
+ assert_equal('a/b', Pathname2.new('a/b/.').cleanpath) # ***
353
+ assert_equal('.', Pathname2.new('a/../.').cleanpath) # ***
354
+ assert_equal('/a', Pathname2.new('/a/b/..').cleanpath)
355
+ assert_equal('/b', Pathname2.new('/a/../b').cleanpath)
356
+ assert_equal('d', Pathname2.new('a/../../d').cleanpath) # ***
353
357
 
354
358
  # Edge cases
355
- assert_equal('', Pathname.new('').cleanpath)
356
- assert_equal('.', Pathname.new('.').cleanpath)
357
- assert_equal('..', Pathname.new('..').cleanpath)
358
- assert_equal('/', Pathname.new('/').cleanpath)
359
- assert_equal('/', Pathname.new('//').cleanpath)
359
+ assert_equal('', Pathname2.new('').cleanpath)
360
+ assert_equal('.', Pathname2.new('.').cleanpath)
361
+ assert_equal('..', Pathname2.new('..').cleanpath)
362
+ assert_equal('/', Pathname2.new('/').cleanpath)
363
+ assert_equal('/', Pathname2.new('//').cleanpath)
360
364
 
361
365
  assert_non_destructive
362
366
  end
@@ -419,20 +423,20 @@ class TC_Pathname < Test::Unit::TestCase
419
423
  assert_respond_to(@abs_path, :find)
420
424
  assert_nothing_raised{ @abs_path.find{} }
421
425
 
422
- Pathname.new(Dir.pwd).find{ |f|
426
+ Pathname2.new(Dir.pwd).find{ |f|
423
427
  Find.prune if f.match('CVS')
424
- assert_kind_of(Pathname, f)
428
+ assert_kind_of(Pathname2, f)
425
429
  }
426
430
  end
427
431
 
428
432
  # Ensures that subclasses return the subclass as the class, not a hard
429
- # coded Pathname.
433
+ # coded Pathname2.
430
434
  #
431
435
  def test_subclasses
432
- assert_kind_of(MyPathname, @mypath)
433
- assert_kind_of(MyPathname, @mypath + MyPathname.new('foo'))
434
- assert_kind_of(MyPathname, @mypath.realpath)
435
- assert_kind_of(MyPathname, @mypath.children.first)
436
+ assert_kind_of(MyPathname2, @mypath)
437
+ assert_kind_of(MyPathname2, @mypath + MyPathname2.new('foo'))
438
+ assert_kind_of(MyPathname2, @mypath.realpath)
439
+ assert_kind_of(MyPathname2, @mypath.children.first)
436
440
  end
437
441
 
438
442
  # Test to ensure that the pn{ } shortcut works
@@ -440,21 +444,21 @@ class TC_Pathname < Test::Unit::TestCase
440
444
  def test_kernel_method
441
445
  assert_respond_to(Kernel, :pn)
442
446
  assert_nothing_raised{ pn{'/foo'} }
443
- assert_kind_of(Pathname, pn{'/foo'})
447
+ assert_kind_of(Pathname2, pn{'/foo'})
444
448
  assert_equal('/foo', pn{'/foo'})
445
449
  end
446
450
 
447
451
  def test_pwd_singleton_method
448
- assert_respond_to(Pathname, :pwd)
449
- assert_kind_of(String, Pathname.pwd)
450
- assert_equal(@@pwd, Pathname.pwd)
452
+ assert_respond_to(Pathname2, :pwd)
453
+ assert_kind_of(String, Pathname2.pwd)
454
+ assert_equal(@@pwd, Pathname2.pwd)
451
455
  end
452
456
 
453
457
  test "String#to_path instance method is implemented" do
454
458
  string = "/usr/local/bin"
455
459
  assert_respond_to(string, :to_path)
456
460
  assert_nothing_raised{ string.to_path }
457
- assert_kind_of(Pathname, string.to_path)
461
+ assert_kind_of(Pathname2, string.to_path)
458
462
  end
459
463
 
460
464
  def teardown
data/test/test_version.rb CHANGED
@@ -6,12 +6,12 @@
6
6
  require 'pathname2'
7
7
  require 'test-unit'
8
8
 
9
- class TC_Pathname_Version < Test::Unit::TestCase
9
+ class TC_Pathname2_Version < Test::Unit::TestCase
10
10
  test "version is set to expected value" do
11
- assert_equal('1.8.4', Pathname::VERSION)
11
+ assert_equal('2.0.0', Pathname2::VERSION)
12
12
  end
13
13
 
14
14
  test "version is frozen" do
15
- assert_true(Pathname::VERSION.frozen?)
15
+ assert_true(Pathname2::VERSION.frozen?)
16
16
  end
17
17
  end
@@ -1,21 +1,21 @@
1
1
  ########################################################################
2
2
  # test_append.rb
3
3
  #
4
- # Test suite for the Pathname#append method.
4
+ # Test suite for the Pathname2#append method.
5
5
  ########################################################################
6
6
  require 'test-unit'
7
7
  require 'pathname2'
8
8
 
9
- class TC_Pathname_Append < Test::Unit::TestCase
9
+ class TC_Pathname2_Append < Test::Unit::TestCase
10
10
  def setup
11
- @abs_path = Pathname.new("C:\\foo\\bar")
12
- @rel_path = Pathname.new("foo\\bar\\baz")
11
+ @abs_path = Pathname2.new("C:\\foo\\bar")
12
+ @rel_path = Pathname2.new("foo\\bar\\baz")
13
13
  end
14
14
 
15
15
  def assert_pathname_plus(a, b, c)
16
- a = Pathname.new(a)
17
- b = Pathname.new(b)
18
- c = Pathname.new(c)
16
+ a = Pathname2.new(a)
17
+ b = Pathname2.new(b)
18
+ c = Pathname2.new(c)
19
19
  assert_equal(a, b + c)
20
20
  end
21
21
 
@@ -1,14 +1,14 @@
1
1
  ########################################################################
2
2
  # test_aref.rb
3
3
  #
4
- # Test suite for the Pathname#[] method.
4
+ # Test suite for the Pathname2#[] method.
5
5
  ########################################################################
6
6
  require 'test-unit'
7
7
  require 'pathname2'
8
8
 
9
- class TC_Pathname_Aref < Test::Unit::TestCase
9
+ class TC_Pathname2_Aref < Test::Unit::TestCase
10
10
  def setup
11
- @path = Pathname.new("C:/Program Files/Windows NT/Accessories")
11
+ @path = Pathname2.new("C:/Program Files/Windows NT/Accessories")
12
12
  end
13
13
 
14
14
  test "[] with index works as expected" do
@@ -1,14 +1,14 @@
1
1
  ########################################################################
2
2
  # test_ascend.rb
3
3
  #
4
- # Test suite for the Pathname#ascend method.
4
+ # Test suite for the Pathname2#ascend method.
5
5
  ########################################################################
6
6
  require 'pathname2'
7
7
  require 'test-unit'
8
8
 
9
- class TC_Pathname_Ascend < Test::Unit::TestCase
9
+ class TC_Pathname2_Ascend < Test::Unit::TestCase
10
10
  def setup
11
- @path = Pathname.new("C:\\foo\\bar\\baz")
11
+ @path = Pathname2.new("C:\\foo\\bar\\baz")
12
12
  end
13
13
 
14
14
  test "ascend basic functionality" do
@@ -27,14 +27,14 @@ class TC_Pathname_Ascend < Test::Unit::TestCase
27
27
 
28
28
  test "ascend works as expected on a UNC path" do
29
29
  array = []
30
- Pathname.new('//foo/bar/baz').ascend{ |e| array << e }
30
+ Pathname2.new('//foo/bar/baz').ascend{ |e| array << e }
31
31
  assert_equal("\\\\foo\\bar\\baz", array[0])
32
32
  assert_equal("\\\\foo\\bar", array[1])
33
33
  end
34
34
 
35
35
  test "ascend works as expected on a relative path" do
36
36
  array = []
37
- Pathname.new('foo/bar/baz').ascend{ |e| array << e }
37
+ Pathname2.new('foo/bar/baz').ascend{ |e| array << e }
38
38
  assert_equal('foo\bar\baz', array[0])
39
39
  assert_equal('foo\bar', array[1])
40
40
  assert_equal('foo', array[2])
@@ -1,15 +1,15 @@
1
1
  ########################################################################
2
2
  # test_children.rb
3
3
  #
4
- # Test suite for the Pathname#children method.
4
+ # Test suite for the Pathname2#children method.
5
5
  ########################################################################
6
6
  require 'pathname2'
7
7
  require 'test-unit'
8
8
 
9
- class TC_Pathname_Children < Test::Unit::TestCase
9
+ class TC_Pathname2_Children < Test::Unit::TestCase
10
10
  def setup
11
11
  @dir = 'foo'
12
- @path = Pathname.new(File.dirname(File.dirname(__FILE__)))
12
+ @path = Pathname2.new(File.dirname(File.dirname(__FILE__)))
13
13
 
14
14
  Dir.mkdir(@dir)
15
15
  Dir.chdir(@dir){
@@ -26,13 +26,13 @@ class TC_Pathname_Children < Test::Unit::TestCase
26
26
  end
27
27
 
28
28
  test "children method returns expected results" do
29
- path = Pathname.new(@dir)
29
+ path = Pathname2.new(@dir)
30
30
  assert_equal(%w[foo\alpha foo\beta foo\gamma], path.children)
31
31
  end
32
32
 
33
- test "each result of the children method is a Pathname object" do
34
- path = Pathname.new(@dir)
35
- assert_kind_of(Pathname, path.children.first)
33
+ test "each result of the children method is a Pathname2 object" do
34
+ path = Pathname2.new(@dir)
35
+ assert_kind_of(Pathname2, path.children.first)
36
36
  end
37
37
 
38
38
  def teardown
@@ -1,42 +1,42 @@
1
1
  ########################################################################
2
2
  # test_clean.rb
3
3
  #
4
- # Test suite for the Pathname#clean method.
4
+ # Test suite for the Pathname2#clean method.
5
5
  ########################################################################
6
6
  require 'test-unit'
7
7
  require 'pathname2'
8
8
 
9
- class TC_Pathname_Clean < Test::Unit::TestCase
9
+ class TC_Pathname2_Clean < Test::Unit::TestCase
10
10
  def setup
11
- @path = Pathname.new("C:\\foo\\..\\bar\\.\\baz")
11
+ @path = Pathname2.new("C:\\foo\\..\\bar\\.\\baz")
12
12
  end
13
13
 
14
14
  test "clean basic functionality" do
15
15
  assert_respond_to(@path, :clean)
16
16
  assert_nothing_raised{ @path.clean }
17
- assert_kind_of(Pathname, @path.clean)
17
+ assert_kind_of(Pathname2, @path.clean)
18
18
  end
19
19
 
20
20
  test "clean returns expected results for unclean paths" do
21
- assert_equal("C:\\a\\c", Pathname.new("C:\\a\\.\\b\\..\\c").clean)
22
- assert_equal("C:\\a", Pathname.new("C:\\.\\a").clean)
23
- assert_equal("C:\\a\\b", Pathname.new("C:\\a\\.\\b").clean)
24
- assert_equal("C:\\b", Pathname.new("C:\\a\\..\\b").clean)
25
- assert_equal("C:\\a", Pathname.new("C:\\a\\.").clean)
26
- assert_equal("C:\\d", Pathname.new("C:\\..\\..\\..\\d").clean)
21
+ assert_equal("C:\\a\\c", Pathname2.new("C:\\a\\.\\b\\..\\c").clean)
22
+ assert_equal("C:\\a", Pathname2.new("C:\\.\\a").clean)
23
+ assert_equal("C:\\a\\b", Pathname2.new("C:\\a\\.\\b").clean)
24
+ assert_equal("C:\\b", Pathname2.new("C:\\a\\..\\b").clean)
25
+ assert_equal("C:\\a", Pathname2.new("C:\\a\\.").clean)
26
+ assert_equal("C:\\d", Pathname2.new("C:\\..\\..\\..\\d").clean)
27
27
  end
28
28
 
29
29
  test "clean returns already clean paths unmodified" do
30
- assert_equal("C:\\", Pathname.new("C:\\").clean)
31
- assert_equal("C:\\a", Pathname.new("C:\\a").clean)
32
- assert_equal("C:\\a\\", Pathname.new("C:\\a\\").clean)
33
- assert_equal("\\\\foo\\bar", Pathname.new("\\\\foo\\bar").clean)
34
- assert_equal("a", Pathname.new("a").clean)
30
+ assert_equal("C:\\", Pathname2.new("C:\\").clean)
31
+ assert_equal("C:\\a", Pathname2.new("C:\\a").clean)
32
+ assert_equal("C:\\a\\", Pathname2.new("C:\\a\\").clean)
33
+ assert_equal("\\\\foo\\bar", Pathname2.new("\\\\foo\\bar").clean)
34
+ assert_equal("a", Pathname2.new("a").clean)
35
35
  end
36
36
 
37
37
  test "clean returns a slash for . and .." do
38
- assert_equal("\\", Pathname.new(".").clean)
39
- assert_equal("\\", Pathname.new("..").clean)
38
+ assert_equal("\\", Pathname2.new(".").clean)
39
+ assert_equal("\\", Pathname2.new("..").clean)
40
40
  end
41
41
 
42
42
  test "clean does not modify receiver" do
@@ -1,42 +1,42 @@
1
1
  ########################################################################
2
2
  # test_clean_bang.rb
3
3
  #
4
- # Test suite for the Pathname#clean! method.
4
+ # Test suite for the Pathname2#clean! method.
5
5
  ########################################################################
6
6
  require 'test-unit'
7
7
  require 'pathname2'
8
8
 
9
- class TC_Pathname_CleanBang < Test::Unit::TestCase
9
+ class TC_Pathname2_CleanBang < Test::Unit::TestCase
10
10
  def setup
11
- @path = Pathname.new("C:\\foo\\..\\bar\\.\\baz")
11
+ @path = Pathname2.new("C:\\foo\\..\\bar\\.\\baz")
12
12
  end
13
13
 
14
14
  test "clean basic functionality" do
15
15
  assert_respond_to(@path, :clean!)
16
16
  assert_nothing_raised{ @path.clean! }
17
- assert_kind_of(Pathname, @path.clean!)
17
+ assert_kind_of(Pathname2, @path.clean!)
18
18
  end
19
19
 
20
20
  test "clean returns expected results for unclean paths" do
21
- assert_equal("C:\\a\\c", Pathname.new("C:\\a\\.\\b\\..\\c").clean!)
22
- assert_equal("C:\\a", Pathname.new("C:\\.\\a").clean!)
23
- assert_equal("C:\\a\\b", Pathname.new("C:\\a\\.\\b").clean!)
24
- assert_equal("C:\\b", Pathname.new("C:\\a\\..\\b").clean!)
25
- assert_equal("C:\\a", Pathname.new("C:\\a\\.").clean!)
26
- assert_equal("C:\\d", Pathname.new("C:\\..\\..\\..\\d").clean!)
21
+ assert_equal("C:\\a\\c", Pathname2.new("C:\\a\\.\\b\\..\\c").clean!)
22
+ assert_equal("C:\\a", Pathname2.new("C:\\.\\a").clean!)
23
+ assert_equal("C:\\a\\b", Pathname2.new("C:\\a\\.\\b").clean!)
24
+ assert_equal("C:\\b", Pathname2.new("C:\\a\\..\\b").clean!)
25
+ assert_equal("C:\\a", Pathname2.new("C:\\a\\.").clean!)
26
+ assert_equal("C:\\d", Pathname2.new("C:\\..\\..\\..\\d").clean!)
27
27
  end
28
28
 
29
29
  test "clean returns already clean paths unmodified" do
30
- assert_equal("C:\\", Pathname.new("C:\\").clean!)
31
- assert_equal("C:\\a", Pathname.new("C:\\a").clean!)
32
- assert_equal("C:\\a\\", Pathname.new("C:\\a\\").clean!)
33
- assert_equal("\\\\foo\\bar", Pathname.new("\\\\foo\\bar").clean!)
34
- assert_equal("a", Pathname.new("a").clean!)
30
+ assert_equal("C:\\", Pathname2.new("C:\\").clean!)
31
+ assert_equal("C:\\a", Pathname2.new("C:\\a").clean!)
32
+ assert_equal("C:\\a\\", Pathname2.new("C:\\a\\").clean!)
33
+ assert_equal("\\\\foo\\bar", Pathname2.new("\\\\foo\\bar").clean!)
34
+ assert_equal("a", Pathname2.new("a").clean!)
35
35
  end
36
36
 
37
37
  test "clean returns a slash for . and .." do
38
- assert_equal("\\", Pathname.new(".").clean!)
39
- assert_equal("\\", Pathname.new("..").clean!)
38
+ assert_equal("\\", Pathname2.new(".").clean!)
39
+ assert_equal("\\", Pathname2.new("..").clean!)
40
40
  end
41
41
 
42
42
  test "clean! modifies receiver" do
@@ -1,12 +1,12 @@
1
1
  ########################################################################
2
2
  # test_constructor.rb
3
3
  #
4
- # Various tests for the Pathname.new method.
4
+ # Various tests for the Pathname2.new method.
5
5
  ########################################################################
6
6
  require 'pathname2'
7
7
  require 'test-unit'
8
8
 
9
- class TC_Pathname_Constructor < Test::Unit::TestCase
9
+ class TC_Pathname2_Constructor < Test::Unit::TestCase
10
10
  def setup
11
11
  @abs_path = "C:/Users"
12
12
  @rel_path = "Users"
@@ -14,30 +14,30 @@ class TC_Pathname_Constructor < Test::Unit::TestCase
14
14
  end
15
15
 
16
16
  test "constructor handles absolute paths properly" do
17
- assert_nothing_raised{ Pathname.new(@abs_path) }
18
- assert_equal("C:\\Users", Pathname.new(@abs_path).to_s)
17
+ assert_nothing_raised{ Pathname2.new(@abs_path) }
18
+ assert_equal("C:\\Users", Pathname2.new(@abs_path).to_s)
19
19
  end
20
20
 
21
21
  test "constructor handles relative paths properly" do
22
- assert_nothing_raised{ Pathname.new(@rel_path) }
23
- assert_equal("Users", Pathname.new(@rel_path).to_s)
22
+ assert_nothing_raised{ Pathname2.new(@rel_path) }
23
+ assert_equal("Users", Pathname2.new(@rel_path).to_s)
24
24
  end
25
25
 
26
26
  test "constructor handles file URL's properly" do
27
- assert_nothing_raised{ Pathname.new(@url_path) }
28
- assert_equal("C:\\Documents and Settings", Pathname.new(@url_path).to_s)
27
+ assert_nothing_raised{ Pathname2.new(@url_path) }
28
+ assert_equal("C:\\Documents and Settings", Pathname2.new(@url_path).to_s)
29
29
  end
30
30
 
31
- test "constructor returns a Pathname object" do
32
- assert_kind_of(Pathname, Pathname.new(@abs_path))
31
+ test "constructor returns a Pathname2 object" do
32
+ assert_kind_of(Pathname2, Pathname2.new(@abs_path))
33
33
  end
34
34
 
35
35
  test "constructor handles frozen arguments without issue" do
36
- assert_nothing_raised{ Pathname.new(@abs_path.freeze) }
36
+ assert_nothing_raised{ Pathname2.new(@abs_path.freeze) }
37
37
  end
38
38
 
39
39
  test "constructor raises an error if string argument is too long" do
40
- assert_raise(ArgumentError){ Pathname.new("foo" * 1000) }
40
+ assert_raise(ArgumentError){ Pathname2.new("foo" * 1000) }
41
41
  end
42
42
 
43
43
  def teardown