pathname2 1.5.2 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +16 -3
- data/MANIFEST +11 -18
- data/README +12 -11
- data/Rakefile +13 -55
- data/lib/pathname2.rb +53 -42
- data/test/{tc_pathname.rb → test_pathname.rb} +6 -2
- data/test/{tc_pathname_win.rb → test_pathname_windows.rb} +25 -39
- metadata +56 -45
data/CHANGES
CHANGED
@@ -1,11 +1,24 @@
|
|
1
|
+
== 1.6.0 - 13-July-2008
|
2
|
+
* The facade for ftools (and ftools itself) has been removed. The ftools
|
3
|
+
library is deprecated in favor of FileUtils.
|
4
|
+
* PathnameError is now Pathname::Error.
|
5
|
+
* Bug fix for Pathname#relative_path_from for MS Windows. Thanks go to an
|
6
|
+
anonymous user for the spot.
|
7
|
+
* Fixed a bug where frozen strings would raise an error on MS Windows.
|
8
|
+
* The code is now -w clean.
|
9
|
+
* Removed the C version as part of the release because it was just too
|
10
|
+
difficult to maintain both versions. The C code remains in CVS, however.
|
11
|
+
* Changed platform checking to use rbconfig instead of RUBY_PLATFORM to avoid
|
12
|
+
potential issues with other Ruby implementation.
|
13
|
+
|
1
14
|
== 1.5.2 - 9-Mar-2007
|
2
15
|
* Bug fix for the Pathname#realpath method where it was not handling recursive
|
3
|
-
|
4
|
-
|
16
|
+
symlinks. The C version was also fixed, but it only affected platforms that
|
17
|
+
don't have the realpath() function.
|
5
18
|
* Added a test for recursive symlinks (for Solaris, anyway).
|
6
19
|
* Updated the docs for Pathname#realpath.
|
7
20
|
* Minor speed enhancements for the C version and the elimination of one
|
8
|
-
|
21
|
+
(potential) segfault.
|
9
22
|
* Added a 'Future Plans' section to the README.
|
10
23
|
* Added a Rakefile. You can now build, clean, and test and install (both the
|
11
24
|
pure Ruby and C versions).
|
data/MANIFEST
CHANGED
@@ -1,18 +1,11 @@
|
|
1
|
-
CHANGES
|
2
|
-
MANIFEST
|
3
|
-
Rakefile
|
4
|
-
README
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
examples/
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
ext/extconf.rb
|
13
|
-
ext/pathname2.c
|
14
|
-
|
15
|
-
lib/pathname2.rb
|
16
|
-
|
17
|
-
test/tc_pathname.rb
|
18
|
-
test/tc_pathname_win.rb
|
1
|
+
* CHANGES
|
2
|
+
* MANIFEST
|
3
|
+
* Rakefile
|
4
|
+
* README
|
5
|
+
* pathname2.gempsec
|
6
|
+
* examples/bench_all.rb
|
7
|
+
* examples/bench_plus.rb
|
8
|
+
* examples/example_pathname.rb
|
9
|
+
* lib/pathname2.rb
|
10
|
+
* test/test_pathname.rb
|
11
|
+
* test/test_pathname_windows.rb
|
data/README
CHANGED
@@ -61,8 +61,8 @@
|
|
61
61
|
a canonical pathname. In addition, there is no special consideration
|
62
62
|
for symlinks (yet), though I'm not sure it warrants it.
|
63
63
|
* The Pathname#+ method auto cleans.
|
64
|
-
* It uses a facade for all File and Dir methods, as well as
|
65
|
-
methods
|
64
|
+
* It uses a facade for all File and Dir methods, as well as most FileUtils
|
65
|
+
methods.
|
66
66
|
* Pathname#clean works slightly differently. In the stdlib version,
|
67
67
|
Pathname#clean("../a") returns "../a". In this version, it returns "a".
|
68
68
|
This affects other methods, such as Pathname#relative_path_from.
|
@@ -70,20 +70,23 @@
|
|
70
70
|
file:///foo%20bar/baz becomes '/foo bar/baz'.
|
71
71
|
* Adds a Kernel level +pn+ method as a shortcut.
|
72
72
|
* Allows you to add paths together with the '/' operator.
|
73
|
+
|
74
|
+
== Differences between Unix platforms - C version
|
75
|
+
* On BSD systems, including OS X, the Pathname#realpath() method requires
|
76
|
+
that all components of a path *except the last* actually exist. Other
|
77
|
+
platforms require that the *entire* path actually exist. This is the
|
78
|
+
way the underlying realpath() C function works on these systems.
|
73
79
|
|
74
80
|
== Method Priority
|
75
|
-
Because there is some overlap in method names between File, Dir,
|
76
|
-
|
81
|
+
Because there is some overlap in method names between File, Dir, and
|
82
|
+
FileUtils, the priority is as follows:
|
77
83
|
|
78
84
|
* File
|
79
85
|
* Dir
|
80
|
-
* ftools
|
81
86
|
* FileUtils
|
82
87
|
|
83
88
|
In other words, whichever of these defines a given method first is the
|
84
|
-
method that is used by the pathname2 package.
|
85
|
-
Pathname#safe_unlink method used is the one defined in ftools.rb,
|
86
|
-
not the one defined in the FileUtils module.
|
89
|
+
method that is used by the pathname2 package.
|
87
90
|
|
88
91
|
== Known Issues
|
89
92
|
You cannot pass a frozen string to the constructor on Windows using the
|
@@ -98,9 +101,7 @@
|
|
98
101
|
supposed to be private. See ruby-core:7383.
|
99
102
|
|
100
103
|
== Future Plans
|
101
|
-
|
102
|
-
everything ftools can do, and better, I'm going to remove ftools in the
|
103
|
-
1.6.0 release.
|
104
|
+
Suggestions welcome.
|
104
105
|
|
105
106
|
== License
|
106
107
|
Ruby's
|
data/Rakefile
CHANGED
@@ -2,73 +2,31 @@ require 'rake'
|
|
2
2
|
require 'rake/clean'
|
3
3
|
require 'rake/testtask'
|
4
4
|
|
5
|
-
desc "
|
6
|
-
task :clean do
|
7
|
-
Dir.chdir('ext') do
|
8
|
-
if RUBY_PLATFORM.match('mswin')
|
9
|
-
sh 'nmake distclean' if File.exists?('pathname2.so')
|
10
|
-
else
|
11
|
-
sh 'make distclean' if File.exists?('pathname2.so')
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
desc "Build the pathname2 package on UNIX systems (but don't install it)"
|
17
|
-
task :build => [:clean] do
|
18
|
-
Dir.chdir('ext') do
|
19
|
-
ruby 'extconf.rb'
|
20
|
-
if RUBY_PLATFORM.match('mswin')
|
21
|
-
sh 'nmake'
|
22
|
-
else
|
23
|
-
sh 'make'
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
desc "Install the pure Ruby version of the pathname2 package"
|
5
|
+
desc "Install pathname2 library (non-gem)"
|
29
6
|
task :install do
|
30
7
|
cp 'lib/pathname2.rb', Config::CONFIG['sitelibdir']
|
31
8
|
end
|
32
9
|
|
33
|
-
desc "Install the
|
34
|
-
task :
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
else
|
39
|
-
sh 'make install'
|
40
|
-
end
|
41
|
-
end
|
10
|
+
desc "Install the pathname2 libarary as a gem"
|
11
|
+
task :install_gem do
|
12
|
+
ruby 'pathname2.gemspec'
|
13
|
+
file = Dir["*.gem"].first
|
14
|
+
sh "gem install #{file}"
|
42
15
|
end
|
43
16
|
|
44
17
|
desc "Run the test suite for the pure Ruby version"
|
45
18
|
Rake::TestTask.new('test') do |t|
|
46
|
-
t.
|
47
|
-
|
48
|
-
|
19
|
+
t.warning = true
|
20
|
+
t.verbose = true
|
21
|
+
|
22
|
+
if Config::CONFIG['host_os'] =~ /mswin/i
|
23
|
+
t.test_files = FileList['test/test_pathname_windows.rb']
|
49
24
|
else
|
50
|
-
t.test_files = FileList['test/
|
25
|
+
t.test_files = FileList['test/test_pathname.rb']
|
51
26
|
end
|
52
27
|
end
|
53
28
|
|
54
|
-
desc "Run the
|
55
|
-
Rake::TestTask.new('test_c') do |t|
|
56
|
-
task :test_c => :build
|
57
|
-
t.libs << 'ext'
|
58
|
-
t.libs.delete('lib')
|
59
|
-
if RUBY_PLATFORM.match('mswin')
|
60
|
-
t.test_files = FileList['test/tc_pathname_win.rb']
|
61
|
-
else
|
62
|
-
t.test_files = FileList['test/tc_pathname.rb']
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
desc "Run the benchmark suite for the pure Ruby version"
|
29
|
+
desc "Run the benchmark suite"
|
67
30
|
task :benchmark do
|
68
31
|
sh 'ruby -Ilib examples/bench_pathname.rb'
|
69
32
|
end
|
70
|
-
|
71
|
-
desc "Run the benchmark suite for the C version"
|
72
|
-
task :benchmark_c => [:build] do
|
73
|
-
sh 'ruby -Iext examples/bench_pathname.rb c'
|
74
|
-
end
|
data/lib/pathname2.rb
CHANGED
@@ -34,36 +34,48 @@
|
|
34
34
|
# imperator on IRC (irc.freenode.net)
|
35
35
|
#
|
36
36
|
# == Copyright
|
37
|
-
# Copyright (c) 2005-
|
37
|
+
# Copyright (c) 2005-2008 Daniel J. Berger.
|
38
38
|
# Licensed under the same terms as Ruby itself.
|
39
39
|
#
|
40
40
|
require 'facade'
|
41
|
-
require 'ftools'
|
42
41
|
require 'fileutils'
|
42
|
+
require 'rbconfig'
|
43
43
|
|
44
|
-
|
44
|
+
if Config::CONFIG['host_os'].match('mswin')
|
45
|
+
require 'windows/path'
|
46
|
+
require 'windows/file'
|
47
|
+
require 'windows/error'
|
48
|
+
require 'windows/limits'
|
49
|
+
end
|
45
50
|
|
46
51
|
class Pathname < String
|
52
|
+
class Error < StandardError; end
|
47
53
|
extend Facade
|
48
|
-
|
49
|
-
facade
|
54
|
+
|
55
|
+
facade File, File.methods(false) - [
|
56
|
+
'chmod', 'lchmod', 'chown', 'lchown', 'fnmatch', 'fnmatch?', 'link',
|
57
|
+
'open', 'rename', 'symlink', 'truncate', 'utime', 'basename',
|
58
|
+
'expand_path', 'join'
|
59
|
+
]
|
60
|
+
|
61
|
+
facade Dir, Dir.methods(false) - ['chdir','glob','foreach','mkdir','open']
|
50
62
|
|
51
63
|
alias :_plus_ :+ # Used to prevent infinite loops in some cases
|
52
64
|
|
53
|
-
if
|
54
|
-
require 'windows/path'
|
55
|
-
require 'windows/file'
|
65
|
+
if Config::CONFIG['host_os'].match('mswin')
|
56
66
|
include Windows::Path
|
57
67
|
include Windows::File
|
68
|
+
include Windows::Error
|
69
|
+
include Windows::Limits
|
58
70
|
end
|
59
71
|
|
60
|
-
VERSION
|
61
|
-
|
72
|
+
VERSION = '1.6.0'
|
73
|
+
MAXPATH = 260
|
62
74
|
|
63
75
|
# Creates and returns a new Pathname object.
|
64
76
|
#
|
65
77
|
# On platforms that define File::ALT_SEPARATOR, all forward slashes are
|
66
|
-
# replaced with the value of File::ALT_SEPARATOR.
|
78
|
+
# replaced with the value of File::ALT_SEPARATOR. On MS Windows, for
|
67
79
|
# example, all forward slashes are replaced with backslashes.
|
68
80
|
#
|
69
81
|
# File URL's will be converted to Pathname objects, e.g. the file URL
|
@@ -71,25 +83,25 @@ class Pathname < String
|
|
71
83
|
# 'C:\Documents and Settings'.
|
72
84
|
#
|
73
85
|
def initialize(path)
|
74
|
-
if path.length >
|
75
|
-
msg = "string too long. maximum string length is " +
|
76
|
-
raise
|
86
|
+
if path.length > MAXPATH
|
87
|
+
msg = "string too long. maximum string length is " + MAXPATH.to_s
|
88
|
+
raise Error, msg
|
77
89
|
end
|
78
90
|
|
79
91
|
@sep = File::ALT_SEPARATOR || File::SEPARATOR
|
80
|
-
@win =
|
92
|
+
@win = Config::CONFIG['host_os'].match('mswin')
|
81
93
|
|
82
|
-
# Handle File URL's.
|
94
|
+
# Handle File URL's. The separate methods for Windows are necessary
|
83
95
|
# because Ruby's URI class does not (currently) parse absolute file URL's
|
84
96
|
# properly when they include a drive letter.
|
85
97
|
if @win
|
86
|
-
if PathIsURL(path)
|
87
|
-
buf = 0.chr *
|
98
|
+
if PathIsURL(path.dup) # Dup to avoid frozen string issues
|
99
|
+
buf = 0.chr * MAXPATH
|
88
100
|
len = [buf.length].pack("l")
|
89
|
-
if PathCreateFromUrl(path, buf, len, 0)
|
101
|
+
if PathCreateFromUrl(path, buf, len, 0) == S_OK
|
90
102
|
path = buf.strip
|
91
103
|
else
|
92
|
-
raise
|
104
|
+
raise Error, "invalid file url: #{path}"
|
93
105
|
end
|
94
106
|
end
|
95
107
|
else
|
@@ -158,7 +170,7 @@ class Pathname < String
|
|
158
170
|
unless @win
|
159
171
|
raise NotImplementedError, "not supported on this platform"
|
160
172
|
end
|
161
|
-
buf = 0.chr *
|
173
|
+
buf = 0.chr * MAXPATH
|
162
174
|
buf[0..self.length-1] = self
|
163
175
|
PathUndecorate(buf)
|
164
176
|
self.class.new(buf.split(0.chr).first)
|
@@ -172,7 +184,7 @@ class Pathname < String
|
|
172
184
|
unless @win
|
173
185
|
raise NotImplementedError, "not supported on this platform"
|
174
186
|
end
|
175
|
-
buf = 0.chr *
|
187
|
+
buf = 0.chr * MAXPATH
|
176
188
|
buf[0..self.length-1] = self
|
177
189
|
PathUndecorate(buf)
|
178
190
|
replace(buf.split(0.chr).first)
|
@@ -188,7 +200,7 @@ class Pathname < String
|
|
188
200
|
unless @win
|
189
201
|
raise NotImplementedError, "not supported on this platform"
|
190
202
|
end
|
191
|
-
buf = 0.chr *
|
203
|
+
buf = 0.chr * MAXPATH
|
192
204
|
buf[0..self.length-1] = self
|
193
205
|
GetShortPathName(self, buf, buf.length)
|
194
206
|
self.class.new(buf.split(0.chr).first)
|
@@ -203,7 +215,7 @@ class Pathname < String
|
|
203
215
|
unless @win
|
204
216
|
raise NotImplementedError, "not supported on this platform"
|
205
217
|
end
|
206
|
-
buf = 0.chr *
|
218
|
+
buf = 0.chr * MAXPATH
|
207
219
|
buf[0..self.length-1] = self
|
208
220
|
GetLongPathName(self, buf, buf.length)
|
209
221
|
self.class.new(buf.split(0.chr).first)
|
@@ -340,7 +352,7 @@ class Pathname < String
|
|
340
352
|
def root
|
341
353
|
dir = "."
|
342
354
|
if @win
|
343
|
-
buf = 0.chr *
|
355
|
+
buf = 0.chr * MAXPATH
|
344
356
|
buf[0..self.length-1] = self
|
345
357
|
|
346
358
|
if PathStripToRoot(buf)
|
@@ -428,6 +440,10 @@ class Pathname < String
|
|
428
440
|
# Because of the way the Windows version handles Pathname#clean, we need
|
429
441
|
# a little extra help here.
|
430
442
|
if @win
|
443
|
+
if root != base.root
|
444
|
+
msg = 'cannot determine relative paths from different root paths'
|
445
|
+
raise ArgumentError, msg
|
446
|
+
end
|
431
447
|
if base == '..' && (self != '..' || self != '.')
|
432
448
|
raise ArgumentError, "base directory may not contain '..'"
|
433
449
|
end
|
@@ -481,7 +497,7 @@ class Pathname < String
|
|
481
497
|
|
482
498
|
# Use the builtin PathAppend() function if on Windows - much easier
|
483
499
|
if @win
|
484
|
-
buf = 0.chr *
|
500
|
+
buf = 0.chr * MAXPATH
|
485
501
|
buf[0..self.length-1] = self
|
486
502
|
PathAppend(buf, string)
|
487
503
|
buf = buf.split("\0").first
|
@@ -526,7 +542,7 @@ class Pathname < String
|
|
526
542
|
return self if self.empty?
|
527
543
|
|
528
544
|
if @win
|
529
|
-
path = 0.chr *
|
545
|
+
path = 0.chr * MAXPATH
|
530
546
|
if PathCanonicalize(path, self)
|
531
547
|
return self.class.new(path.split(0.chr).first)
|
532
548
|
else
|
@@ -556,7 +572,7 @@ class Pathname < String
|
|
556
572
|
return self if self.empty?
|
557
573
|
|
558
574
|
if @win
|
559
|
-
path = 0.chr *
|
575
|
+
path = 0.chr * MAXPATH
|
560
576
|
if PathCanonicalize(path, self)
|
561
577
|
replace(path.split(0.chr).first)
|
562
578
|
end
|
@@ -731,13 +747,9 @@ class Pathname < String
|
|
731
747
|
File.expand_path(self, *args)
|
732
748
|
end
|
733
749
|
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
# ftools File.copy
|
739
|
-
def copy(*args)
|
740
|
-
File.copy(self, *args)
|
750
|
+
# File.join
|
751
|
+
def join(*args)
|
752
|
+
File.join(self, *args)
|
741
753
|
end
|
742
754
|
|
743
755
|
#--
|
@@ -806,7 +818,11 @@ class Pathname < String
|
|
806
818
|
def rm_rf(*args)
|
807
819
|
FileUtils.rm_rf(self, *args)
|
808
820
|
end
|
809
|
-
|
821
|
+
|
822
|
+
# FileUtils.rmtree
|
823
|
+
def rmtree(*args)
|
824
|
+
FileUtils.rmtree(self, *args)
|
825
|
+
end
|
810
826
|
|
811
827
|
# FileUtils.install
|
812
828
|
def install(*args)
|
@@ -860,10 +876,5 @@ module Kernel
|
|
860
876
|
end
|
861
877
|
|
862
878
|
if $0 == __FILE__
|
863
|
-
|
864
|
-
path2 = 'link2'
|
865
|
-
|
866
|
-
path = Pathname.new(path1)
|
867
|
-
path = path.realpath
|
868
|
-
p path
|
879
|
+
path = Pathname.new(Dir.pwd)
|
869
880
|
end
|
@@ -63,7 +63,7 @@ class TC_Pathname < Test::Unit::TestCase
|
|
63
63
|
end
|
64
64
|
|
65
65
|
def test_version
|
66
|
-
assert_equal('1.
|
66
|
+
assert_equal('1.6.0', Pathname::VERSION)
|
67
67
|
end
|
68
68
|
|
69
69
|
def test_file_url_path
|
@@ -73,9 +73,13 @@ class TC_Pathname < Test::Unit::TestCase
|
|
73
73
|
def test_realpath
|
74
74
|
assert_respond_to(@abs_path, :realpath)
|
75
75
|
assert_equal(@pwd, Pathname.new('.').realpath)
|
76
|
-
assert_raises(Errno::ENOENT){ Pathname.new('../bogus').realpath }
|
77
76
|
assert_kind_of(Pathname, Pathname.new('/dev/stdin').realpath)
|
78
77
|
assert(Pathname.new('/dev/stdin') != Pathname.new('/dev/stdin').realpath)
|
78
|
+
if RUBY_PLATFORM =~ /bsd|darwin|mac/i
|
79
|
+
assert_raises(Errno::ENOENT){ Pathname.new('../blahblah/bogus').realpath }
|
80
|
+
else
|
81
|
+
assert_raises(Errno::ENOENT){ Pathname.new('../bogus').realpath }
|
82
|
+
end
|
79
83
|
end
|
80
84
|
|
81
85
|
def test_realpath_platform
|
@@ -1,27 +1,11 @@
|
|
1
1
|
##########################################################################
|
2
2
|
# tc_pathname_win.rb
|
3
3
|
#
|
4
|
-
# MS Windows test suite for the Pathname class.
|
5
|
-
# against the C extension pass the letter 'c' as an argument.
|
4
|
+
# MS Windows test suite for the Pathname class. To test explicitly
|
5
|
+
# against the C extension pass the letter 'c' as an argument. You should
|
6
|
+
# use the 'rake test' task to run this test suite.
|
6
7
|
###########################################################################
|
7
|
-
|
8
|
-
$LOAD_PATH.unshift Dir.pwd
|
9
|
-
$c_extension = false
|
10
|
-
|
11
|
-
# If the user passes a 'c', test against the C extension
|
12
|
-
if ARGV[0] && ARGV[0].downcase == "c"
|
13
|
-
$c_extension = true
|
14
|
-
$LOAD_PATH.unshift Dir.pwd + "/ext"
|
15
|
-
else
|
16
|
-
$LOAD_PATH.unshift Dir.pwd + "/lib"
|
17
|
-
end
|
18
|
-
|
19
|
-
unless RUBY_PLATFORM.match("mswin")
|
20
|
-
STDERR.puts("Please run 'tc_pathname.rb' instead.")
|
21
|
-
exit
|
22
|
-
end
|
23
|
-
|
24
|
-
require 'facade' # Avoids annoying gems issue
|
8
|
+
require 'facade'
|
25
9
|
require 'pathname2'
|
26
10
|
require 'test/unit'
|
27
11
|
|
@@ -56,7 +40,7 @@ class TC_Pathname_MSWin < Test::Unit::TestCase
|
|
56
40
|
end
|
57
41
|
|
58
42
|
def test_version
|
59
|
-
assert_equal("1.
|
43
|
+
assert_equal("1.6.0", Pathname::VERSION)
|
60
44
|
end
|
61
45
|
|
62
46
|
# Convenience method for test_plus
|
@@ -81,7 +65,7 @@ class TC_Pathname_MSWin < Test::Unit::TestCase
|
|
81
65
|
end
|
82
66
|
|
83
67
|
# Convenience method for test_relative_path_from_expected_errors
|
84
|
-
def
|
68
|
+
def assert_relative_path_error(to, from)
|
85
69
|
assert_raise(ArgumentError) {
|
86
70
|
Pathname.new(to).relative_path_from(from)
|
87
71
|
}
|
@@ -89,7 +73,7 @@ class TC_Pathname_MSWin < Test::Unit::TestCase
|
|
89
73
|
|
90
74
|
def test_file_urls
|
91
75
|
assert_equal("C:\\Documents and Settings", @url_path)
|
92
|
-
assert_raises(
|
76
|
+
assert_raises(Pathname::Error){ Pathname.new('http://rubyforge.org') }
|
93
77
|
end
|
94
78
|
|
95
79
|
def test_realpath
|
@@ -131,11 +115,15 @@ class TC_Pathname_MSWin < Test::Unit::TestCase
|
|
131
115
|
|
132
116
|
assert_relpath("a", "a", "b\\..")
|
133
117
|
assert_relpath("b\\c", "b\\c", "b\\..")
|
118
|
+
end
|
134
119
|
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
120
|
+
def test_relative_path_from_expected_errors
|
121
|
+
assert_relative_path_error("c:\\", ".")
|
122
|
+
assert_relative_path_error(".", "c:\\")
|
123
|
+
assert_relative_path_error("a", "..")
|
124
|
+
assert_relative_path_error(".", "..")
|
125
|
+
assert_relative_path_error("C:\\Temp", "D:\\Temp")
|
126
|
+
assert_relative_path_error("\\\\Server\\Temp", "D:\\Temp")
|
139
127
|
end
|
140
128
|
|
141
129
|
# Convenience method to verify that the receiver was not modified
|
@@ -332,14 +320,11 @@ class TC_Pathname_MSWin < Test::Unit::TestCase
|
|
332
320
|
assert_non_destructive
|
333
321
|
end
|
334
322
|
|
335
|
-
# Fails due to PathIsURL for some reason in pure Ruby
|
336
323
|
def test_immutability
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
assert_nothing_raised{ Pathname.new(path).root }
|
342
|
-
end
|
324
|
+
path = "C:\\Program Files\\foo\\bar".freeze
|
325
|
+
assert_equal(true, path.frozen?)
|
326
|
+
assert_nothing_raised{ Pathname.new(path) }
|
327
|
+
assert_nothing_raised{ Pathname.new(path).root }
|
343
328
|
end
|
344
329
|
|
345
330
|
def test_plus_operator
|
@@ -544,7 +529,6 @@ class TC_Pathname_MSWin < Test::Unit::TestCase
|
|
544
529
|
File.methods(false).each{ |method|
|
545
530
|
assert_respond_to(@fpath, method.to_sym)
|
546
531
|
}
|
547
|
-
assert_respond_to(@fpath, :catname) # ftools check
|
548
532
|
end
|
549
533
|
|
550
534
|
def test_facade_dir
|
@@ -586,32 +570,34 @@ class TC_Pathname_MSWin < Test::Unit::TestCase
|
|
586
570
|
children.delete_if{ |e| File.basename(e) == "CVS" }
|
587
571
|
children.delete_if{ |e| File.basename(e) == ".cvsignore" }
|
588
572
|
children.delete_if{ |e| File.basename(e) == ".project" }
|
573
|
+
children.delete_if{ |e| File.basename(e) == ".loadpath" }
|
589
574
|
|
590
575
|
assert_equal(
|
591
576
|
[
|
592
577
|
Dir.pwd + "/CHANGES",
|
593
578
|
Dir.pwd + "/examples",
|
594
579
|
Dir.pwd + "/ext",
|
595
|
-
Dir.pwd + "/install.rb",
|
596
580
|
Dir.pwd + "/lib",
|
597
581
|
Dir.pwd + "/MANIFEST",
|
598
582
|
Dir.pwd + "/pathname2.gemspec",
|
583
|
+
Dir.pwd + "/Rakefile",
|
599
584
|
Dir.pwd + "/README",
|
600
585
|
Dir.pwd + "/test"
|
601
|
-
].map{ |e| e.tr("/","\\") },
|
586
|
+
].map{ |e| e.tr("/", "\\") },
|
602
587
|
children
|
603
588
|
)
|
604
|
-
|
589
|
+
|
605
590
|
# Delete Eclipse related files
|
606
591
|
children = @cur_path.children(false)
|
607
592
|
children.delete("CVS")
|
608
593
|
children.delete(".cvsignore")
|
609
594
|
children.delete(".project")
|
595
|
+
children.delete(".loadpath")
|
610
596
|
|
611
597
|
assert_equal(
|
612
598
|
[
|
613
599
|
"CHANGES","examples","ext","install.rb","lib",
|
614
|
-
"MANIFEST", "pathname2.gemspec", "README", "test"
|
600
|
+
"MANIFEST", "pathname2.gemspec", "Rakefile", "README", "test"
|
615
601
|
],
|
616
602
|
children
|
617
603
|
)
|
metadata
CHANGED
@@ -1,61 +1,72 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.0
|
3
|
-
specification_version: 1
|
4
2
|
name: pathname2
|
5
3
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.
|
7
|
-
date: 2007-03-09 00:00:00 -07:00
|
8
|
-
summary: An alternate implementation of the Pathname class
|
9
|
-
require_paths:
|
10
|
-
- lib
|
11
|
-
email: djberg96@gmail.com
|
12
|
-
homepage: http://www.rubyforge.org/projects/shards
|
13
|
-
rubyforge_project:
|
14
|
-
description: An alternate implementation of the Pathname class
|
15
|
-
autorequire:
|
16
|
-
default_executable:
|
17
|
-
bindir: bin
|
18
|
-
has_rdoc: true
|
19
|
-
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
-
requirements:
|
21
|
-
- - ">"
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 0.0.0
|
24
|
-
version:
|
4
|
+
version: 1.6.0
|
25
5
|
platform: ruby
|
26
|
-
signing_key:
|
27
|
-
cert_chain:
|
28
|
-
post_install_message:
|
29
6
|
authors:
|
30
7
|
- Daniel J. Berger
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
- MANIFEST
|
35
|
-
- README
|
36
|
-
- Rakefile
|
37
|
-
- test/tc_pathname.rb
|
38
|
-
- test/tc_pathname_win.rb
|
39
|
-
test_files:
|
40
|
-
- test/tc_pathname.rb
|
41
|
-
rdoc_options: []
|
42
|
-
|
43
|
-
extra_rdoc_files:
|
44
|
-
- README
|
45
|
-
- CHANGES
|
46
|
-
executables: []
|
47
|
-
|
48
|
-
extensions: []
|
49
|
-
|
50
|
-
requirements: []
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
51
11
|
|
12
|
+
date: 2008-07-15 00:00:00 -06:00
|
13
|
+
default_executable:
|
52
14
|
dependencies:
|
53
15
|
- !ruby/object:Gem::Dependency
|
54
16
|
name: facade
|
17
|
+
type: :runtime
|
55
18
|
version_requirement:
|
56
|
-
version_requirements: !ruby/object:Gem::
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
20
|
requirements:
|
58
21
|
- - ">="
|
59
22
|
- !ruby/object:Gem::Version
|
60
23
|
version: 1.0.0
|
61
24
|
version:
|
25
|
+
description: An alternate implementation of the Pathname class
|
26
|
+
email: djberg96@gmail.com
|
27
|
+
executables: []
|
28
|
+
|
29
|
+
extensions: []
|
30
|
+
|
31
|
+
extra_rdoc_files:
|
32
|
+
- README
|
33
|
+
- CHANGES
|
34
|
+
- MANIFEST
|
35
|
+
files:
|
36
|
+
- lib/pathname2.rb
|
37
|
+
- CHANGES
|
38
|
+
- MANIFEST
|
39
|
+
- README
|
40
|
+
- Rakefile
|
41
|
+
- CVS
|
42
|
+
- test/test_pathname.rb
|
43
|
+
- test/test_pathname_windows.rb
|
44
|
+
- test/CVS
|
45
|
+
has_rdoc: true
|
46
|
+
homepage: http://www.rubyforge.org/projects/shards
|
47
|
+
post_install_message:
|
48
|
+
rdoc_options: []
|
49
|
+
|
50
|
+
require_paths:
|
51
|
+
- lib
|
52
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: "0"
|
57
|
+
version:
|
58
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: "0"
|
63
|
+
version:
|
64
|
+
requirements: []
|
65
|
+
|
66
|
+
rubyforge_project: shards
|
67
|
+
rubygems_version: 1.2.0
|
68
|
+
signing_key:
|
69
|
+
specification_version: 2
|
70
|
+
summary: An alternate implementation of the Pathname class
|
71
|
+
test_files:
|
72
|
+
- test/test_pathname.rb
|