Skip to content
Permalink
Browse files

Merge pull request #517 from jstepien/io-read

Most basic IO.read invocation works
  • Loading branch information
alex committed Mar 16, 2013
2 parents 2efbbe5 + bc040ab commit 25e808d542ed040f1006c1e3080b69319f04aa48
Showing with 6 additions and 7 deletions.
  1. +6 −0 lib-topaz/io.rb
  2. +0 −7 spec/tags/core/io/read_tags.txt
@@ -88,6 +88,12 @@ def readlines(sep = $/, limit = nil)
return lines
end

def self.read(name)
File.open(name) do |f|
f.read
end
end

def self.readlines(name, *args)
File.open(name) do |f|
return f.readlines(*args)
@@ -1,5 +1,3 @@
fails:IO.read reads the contents of a file
fails:IO.read calls #to_path on non-String arguments
fails:IO.read accepts an empty options Hash
fails:IO.read accepts a length, offset, and empty options Hash
fails:IO.read raises an IOError if the options Hash specifies write mode
@@ -13,8 +11,6 @@ fails:IO.read reads the contents of a file up to a certain size when specified
fails:IO.read reads the contents of a file from an offset of a specific size when specified
fails:IO.read returns nil at end-of-file when length is passed
fails:IO.read raises an Errno::ENOENT when the requested file does not exist
fails:IO.read raises a TypeError when not passed a String type
fails:IO.read raises an ArgumentError when not passed a valid length
fails:IO.read raises an Errno::EINVAL when not passed a valid offset
fails:IO.read from a pipe runs the rest as a subprocess and returns the standard output
fails:IO.read from a pipe opens a pipe to a fork if the rest is -
@@ -39,11 +35,8 @@ fails:IO#read returns an empty string when the current pos is bigger than the co
fails:IO#read returns nil at end-of-file with a length
fails:IO#read with length argument returns nil when the current pos is bigger than the content size
fails:IO#read raises IOError on closed stream
fails:IO#read with encodings ignores unicode encoding
fails:IO#read with 1.9 encodings strips the BOM when given 'rb:utf-7-bom' as the mode
fails:IO#read with large data reads all the data at once
fails:IO#read with large data reads only the requested number of bytes
fails:IO#read with $KCODE set to UTF-8 ignores unicode encoding
fails:IO#read in binary mode does not transcode file contents when Encoding.default_internal is set
fails:IO#read in binary mode does transcode file contents when an internal encoding is specified
fails:IO.read with BOM reads a file without a bom

0 comments on commit 25e808d

Please sign in to comment.