Skip to content

Commit

Permalink
Improved ext method (need to double check windows code)
Browse files Browse the repository at this point in the history
  • Loading branch information
jimweirich committed Mar 5, 2009
1 parent 180688c commit d751f06
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/rake.rb
Expand Up @@ -84,7 +84,7 @@ def ext(newext='')
if newext != ''
newext = (newext =~ /^\./) ? newext : ("." + newext)
end
dup.sub!(%r(([^/\\])\.[^./\\]*$)) { $1 + newext } || self + newext
self.chomp(File.extname(self)) << newext
end
end

Expand Down
7 changes: 5 additions & 2 deletions test/test_filelist.rb
Expand Up @@ -285,9 +285,7 @@ def test_string_ext
assert_equal "one.two.net", "one.two.c".ext(".net")
assert_equal "one/two.net", "one/two.c".ext(".net")
assert_equal "one.x/two.net", "one.x/two.c".ext(".net")
assert_equal "one.x\\two.net", "one.x\\two.c".ext(".net")
assert_equal "one.x/two.net", "one.x/two".ext(".net")
assert_equal "one.x\\two.net", "one.x\\two".ext(".net")
assert_equal ".onerc.net", ".onerc.dot".ext("net")
assert_equal ".onerc.net", ".onerc".ext("net")
assert_equal ".a/.onerc.net", ".a/.onerc".ext("net")
Expand All @@ -297,6 +295,11 @@ def test_string_ext
assert_equal ".one", ".one".ext
assert_equal ".", ".".ext("c")
assert_equal "..", "..".ext("c")
# These only need to work in windows
if Rake::Win32.windows?
assert_equal "one.x\\two.net", "one.x\\two.c".ext(".net")
assert_equal "one.x\\two.net", "one.x\\two".ext(".net")
end
end

def test_filelist_ext
Expand Down

0 comments on commit d751f06

Please sign in to comment.