lib/document.rb
# Adds the given file under the specified version.
# @param version [String] the version identifier (can be 'current')
# @param filename [String] the name of the file
# @param body [String or IO] the file contents (binary string or IO)
# @param author [String] the author of the file (optional)
# @return [void]
Adds the given file under the specified version.
Adds the given file under the specified version .
def add_file version, filename, body, author=nil
      raise VersionNotFound.new unless File.exist?( directory + version )
      body = StringIO.new(body) unless body.respond_to?(:read) 
      File.open( directory + version + filename, "wb" ) { |f| IO.copy_stream(body,f) }
      File.open( directory + version + AUTHOR_FILE, 'w' ) { |f| f.write author }
    end
def add_file version , filename , body , author = nil raise VersionNotFound . new unless File . exist? ( directory + version ) body = StringIO . new ( body ) unless body . respond_to? ( :read ) File . open ( directory + version + filename , "wb" ) { | f | IO . copy_stream ( body , f ) } File . open ( directory + version + AUTHOR_FILE , 'w' ) { | f | f . write author } end
Adds the given file under the specified version.
Adds the given file under the specified version .
# string -> IO
None
void
version
the version identifier (can be 'current')
the version identifier ( can be ' current ' )
filename
the name of the file
the name of the file
body
the file contents (binary string or IO)
the file contents ( binary string or IO )
author
the author of the file (optional)
the author of the file ( optional )