Project

General

Profile

Feature #7378 ยป 0001-ext-pathname-lib-pathname.rb-add-Pathname-write-and-.patch

Eregon (Benoit Daloze), 01/14/2013 06:01 AM

View differences:

ChangeLog
Mon Jan 14 05:56:27 2013 Benoit Daloze <eregontp@gmail.com>
* ext/pathname/lib/pathname.rb: add Pathname#write and #binwrite.
* test/pathname/test_pathname.rb: add tests.
Sun Jan 13 16:45:00 2013 Zachary Scott <zachary@zacharyscott.net>
* ext/psych/yaml/scanner.c: Fix typos, patch by James Dabbs
ext/pathname/lib/pathname.rb
Pathname.new(File.join(*relpath_names))
end
end
# Writes +contents+ to the file.
#
# See IO.write.
def write(contents, *args)
IO.write(@path, contents, *args)
end
# Writes +contents+ to the file, opening it in binary mode.
#
# See IO.binwrite.
def binwrite(contents, *args)
IO.binwrite(@path, contents, *args)
end
end
test/pathname/test_pathname.rb
}
end
def test_write
with_tmpchdir('rubytest-pathname') {|dir|
path = Pathname("a")
path.write "abc"
assert_equal("abc", path.read)
}
end
def test_binwrite
with_tmpchdir('rubytest-pathname') {|dir|
path = Pathname("a")
path.binwrite "abc\x80"
assert_equal("abc\x80".b, path.binread)
}
end
def test_sysopen
with_tmpchdir('rubytest-pathname') {|dir|
open("a", "w") {|f| f.write "abc" }
    (1-1/1)