pathname2 1.3.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +4 -0
- data/MANIFEST +3 -0
- data/README +1 -1
- data/lib/pathname2.rb +23 -1
- data/test/tc_pathname.rb +31 -1
- data/test/tc_pathname_win.rb +31 -1
- metadata +2 -2
data/CHANGES
CHANGED
data/MANIFEST
CHANGED
data/README
CHANGED
data/lib/pathname2.rb
CHANGED
@@ -75,7 +75,7 @@ class Pathname < String
|
|
75
75
|
Win32API.new("shlwapi", "PathRemoveBackslash", "P", "P")
|
76
76
|
end
|
77
77
|
|
78
|
-
VERSION = "1.3.
|
78
|
+
VERSION = "1.3.1"
|
79
79
|
MAX_PATH = 260
|
80
80
|
|
81
81
|
# Creates and returns a new Pathname object.
|
@@ -108,6 +108,28 @@ class Pathname < String
|
|
108
108
|
super(path)
|
109
109
|
end
|
110
110
|
|
111
|
+
# Returns the children of the directory, files and subdirectories, as an
|
112
|
+
# array of Pathname objects. If you set +with_directory+ to +false+, then
|
113
|
+
# the returned pathnames will contain the filename only.
|
114
|
+
#
|
115
|
+
# Note that the result never contain the entries '.' and '..' in the
|
116
|
+
# the directory because they are not children. Also note that this method
|
117
|
+
# is *not* recursive.
|
118
|
+
#
|
119
|
+
def children(with_directory = true)
|
120
|
+
with_directory = false if self == '.'
|
121
|
+
result = []
|
122
|
+
Dir.foreach(self) { |file|
|
123
|
+
next if file == '.' || file == '..'
|
124
|
+
if with_directory
|
125
|
+
result << Pathname.new(File.join(self, file))
|
126
|
+
else
|
127
|
+
result << Pathname.new(file)
|
128
|
+
end
|
129
|
+
}
|
130
|
+
result
|
131
|
+
end
|
132
|
+
|
111
133
|
# Win32 only
|
112
134
|
#
|
113
135
|
# Removes the decoration from a path string. For example,
|
data/test/tc_pathname.rb
CHANGED
@@ -41,7 +41,7 @@ class TC_Pathname < Test::Unit::TestCase
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def test_version
|
44
|
-
assert_equal("1.3.
|
44
|
+
assert_equal("1.3.1", Pathname::VERSION)
|
45
45
|
end
|
46
46
|
|
47
47
|
def test_ascend
|
@@ -82,6 +82,36 @@ class TC_Pathname < Test::Unit::TestCase
|
|
82
82
|
assert_equal(3, @rel_array.length)
|
83
83
|
end
|
84
84
|
|
85
|
+
def test_children
|
86
|
+
Dir.chdir("..") if File.basename(Dir.pwd) == "test"
|
87
|
+
@cur_path = Pathname.new(Dir.pwd)
|
88
|
+
|
89
|
+
assert_respond_to(@cur_path, :children)
|
90
|
+
assert_nothing_raised{ @cur_path.children }
|
91
|
+
assert_kind_of(Array, @cur_path.children)
|
92
|
+
|
93
|
+
assert_equal(
|
94
|
+
[
|
95
|
+
Dir.pwd + "/CHANGES",
|
96
|
+
Dir.pwd + "/MANIFEST",
|
97
|
+
Dir.pwd + "/README",
|
98
|
+
Dir.pwd + "/install.rb",
|
99
|
+
Dir.pwd + "/pathname2.gemspec",
|
100
|
+
Dir.pwd + "/examples",
|
101
|
+
Dir.pwd + "/lib",
|
102
|
+
Dir.pwd + "/test"
|
103
|
+
],
|
104
|
+
@cur_path.children
|
105
|
+
)
|
106
|
+
assert_equal(
|
107
|
+
[
|
108
|
+
"CHANGES","MANIFEST","README","install.rb",
|
109
|
+
"pathname2.gemspec","examples", "lib", "test"
|
110
|
+
],
|
111
|
+
@cur_path.children(false)
|
112
|
+
)
|
113
|
+
end
|
114
|
+
|
85
115
|
def test_unc
|
86
116
|
assert_raises(NotImplementedError){ @abs_path.unc? }
|
87
117
|
end
|
data/test/tc_pathname_win.rb
CHANGED
@@ -34,7 +34,7 @@ class TC_Pathname_MSWin < Test::Unit::TestCase
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def test_version
|
37
|
-
assert_equal("1.3.
|
37
|
+
assert_equal("1.3.1", Pathname::VERSION)
|
38
38
|
end
|
39
39
|
|
40
40
|
# Convenience method for test_plus
|
@@ -295,6 +295,36 @@ class TC_Pathname_MSWin < Test::Unit::TestCase
|
|
295
295
|
assert_kind_of(Pathname, f)
|
296
296
|
}
|
297
297
|
end
|
298
|
+
|
299
|
+
def test_children
|
300
|
+
Dir.chdir("..") if File.basename(Dir.pwd) == "test"
|
301
|
+
@cur_path = Pathname.new(Dir.pwd)
|
302
|
+
|
303
|
+
assert_respond_to(@cur_path, :children)
|
304
|
+
assert_nothing_raised{ @cur_path.children }
|
305
|
+
assert_kind_of(Array, @cur_path.children)
|
306
|
+
|
307
|
+
assert_equal(
|
308
|
+
[
|
309
|
+
Dir.pwd + "/CHANGES",
|
310
|
+
Dir.pwd + "/examples",
|
311
|
+
Dir.pwd + "/install.rb",
|
312
|
+
Dir.pwd + "/lib",
|
313
|
+
Dir.pwd + "/MANIFEST",
|
314
|
+
Dir.pwd + "/pathname2.gemspec",
|
315
|
+
Dir.pwd + "/README",
|
316
|
+
Dir.pwd + "/test"
|
317
|
+
].map{ |e| e.tr("/","\\") },
|
318
|
+
@cur_path.children
|
319
|
+
)
|
320
|
+
assert_equal(
|
321
|
+
[
|
322
|
+
"CHANGES","examples","install.rb","lib",
|
323
|
+
"MANIFEST", "pathname2.gemspec", "README", "test"
|
324
|
+
],
|
325
|
+
@cur_path.children(false)
|
326
|
+
)
|
327
|
+
end
|
298
328
|
|
299
329
|
def teardown
|
300
330
|
@fpath = nil
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
|
|
3
3
|
specification_version: 1
|
4
4
|
name: pathname2
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.3.
|
7
|
-
date: 2005-
|
6
|
+
version: 1.3.1
|
7
|
+
date: 2005-11-21 00:00:00 -07:00
|
8
8
|
summary: An alternate implementation of the Pathname class
|
9
9
|
require_paths:
|
10
10
|
- lib
|