summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-02-22 12:18:58 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-02-22 12:18:58 +0000
commitcb8d34855e7374f7a28b115f8d3a5e2020072f0e (patch)
treeb0a5d9b71c1cd68afc270e4cadae97fe01825bec
parentbea93efc42f1e50e759888e53dbcd1ec624d3d80 (diff)
* lib/pathname.rb (Pathname#each_filename): use split_names properly.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9984 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog4
-rw-r--r--lib/pathname.rb3
-rw-r--r--test/pathname/test_pathname.rb6
3 files changed, 12 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 9064d78b926..acf017f0564 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Wed Feb 22 21:16:55 2006 Tanaka Akira <akr@m17n.org>
+
+ * lib/pathname.rb (Pathname#each_filename): use split_names properly.
+
Wed Feb 22 16:24:05 2006 NAKAMURA Usaku <usa@ruby-lang.org>
* test/webrick/test_cgi.rb: should support platforms which search
diff --git a/lib/pathname.rb b/lib/pathname.rb
index c81a70562b7..87c496107cb 100644
--- a/lib/pathname.rb
+++ b/lib/pathname.rb
@@ -492,7 +492,8 @@ class Pathname
# # yields "usr", "bin", and "ruby".
#
def each_filename # :yield: s
- split_names(@path).each {|filename| yield filename }
+ prefix, names = split_names(@path)
+ names.each {|filename| yield filename }
end
# Iterates over and yields a new Pathname object
diff --git a/test/pathname/test_pathname.rb b/test/pathname/test_pathname.rb
index 94ddbcd9cf4..20351fa0f80 100644
--- a/test/pathname/test_pathname.rb
+++ b/test/pathname/test_pathname.rb
@@ -458,4 +458,10 @@ class TestPathname < Test::Unit::TestCase
assert_equal(1, count)
assert_equal(2, result)
end
+
+ def test_each_filename
+ result = []
+ Pathname.new("/usr/bin/ruby").each_filename {|f| result << f }
+ assert_equal(%w[usr bin ruby], result)
+ end
end