lib/tap/tasks/load.rb in tap-0.17.1 vs lib/tap/tasks/load.rb in tap-0.18.0

- old
+ new

@@ -20,22 +20,21 @@ # contents of somefile # # :startdoc::task- # # Load serves as a baseclass for more complicated loads. A YAML load - # (see {tap-tasks}[http://tap.rubyforge.org/tap-tasks]) looks like this: + # could look like this: # # class Yaml < Tap::Tasks::Load # def load(io) # YAML.load(io) # end # end # - # Load is constructed to reque itself in cases where objects are to - # be loaded sequentially from the same io. Load will reque until the - # end-of-file is reached, but this behavior can be modified by - # overriding the complete? method. An example is a prompt task: + # Load subclasses may be constructed to reque itself in cases where objects + # are sequentially loaded from the same io. Load will reque until the + # complete? method returns true. An example is a prompt task: # # class Prompt < Tap::Tasks::Load # config :exit_seq, "\n" # # def load(io) @@ -85,11 +84,11 @@ # * Creating a StringIO for String inputs # * Opening an IO for integer file descriptors # * Returning all other objects # def open(io) - return File.open(io) if file + return(io.kind_of?(File) ? io : File.open(io)) if file case io when String StringIO.new(io) when Integer @@ -108,13 +107,13 @@ # Closes io. def close(io) io.close end - # Returns io.eof? Override in subclasses for the desired behavior - # (see process). + # Returns true by default. Override in subclasses to allow recurrent + # loading (see process). def complete?(io, last) - io.eof? + true end end end end