lib/rio/if/yaml.rb in rio-0.3.8 vs lib/rio/if/yaml.rb in rio-0.3.9
- old
+ new
@@ -1,8 +1,8 @@
#--
# ===============================================================================
-# Copyright (c) 2005, 2006 Christopher Kleckner
+# Copyright (c) 2005,2006,2007 Christopher Kleckner
# All rights reserved
#
# This file is part of the Rio library for ruby.
#
# Rio is free software; you can redistribute it and/or modify
@@ -21,25 +21,24 @@
# ===============================================================================
#++
#
# To create the documentation for Rio run the command
# ruby build_doc.rb
-# from the distribution directory. Then point your browser at the 'doc/rdoc' directory.
+# from the distribution directory.
#
# Suggested Reading
# * RIO::Doc::SYNOPSIS
# * RIO::Doc::INTRO
# * RIO::Doc::HOWTO
+# * RIO::Doc::EXAMPLES
# * RIO::Rio
#
-# <b>Rio is pre-alpha software.
-# The documented interface and behavior is subject to change without notice.</b>
module RIO
module IF
- module YAML #:nodoc: all
+ module YAML
#def file() target.file end
#def dir() target.dir end
# Puts a Rio in YAML mode.
#
@@ -49,11 +48,11 @@
# <tt>(skip)records</tt> is identical to <tt>(skip)lines</tt> because
# while +records+ only selects and does not specify the record-type,
# +lines+ is the default.
#
# The YAML extension distingishes between items selected using
- # Rio#records, Rio#rows and Rio#lines. Rio returns objects loaded via
+ # IF::GrandeStream#records, IF::GrandeStream#rows and IF::GrandeStream#lines. Rio returns objects loaded via
# YAML#load when +records+ is used; returns the YAML text as a String
# when +rows+ is used; and returns lines as Strings as normal when
# +lines+ is used. +records+ is the default. In yaml-mode,
# <tt>(skip)records</tt> can be called as <tt>(skip)objects</tt> and
# <tt>(skip)rows</tt> can be called as <tt>(skip)documents</tt>
@@ -91,57 +90,32 @@
# 'database' => 'rails_production',
# }
# }
# rio('afile.yaml').yaml.dump(anobject)
#
- # The YAML extension changes the way the grande copy operators interpret
- # their argument. Rio#< (copy-from) and Rio#<< (append-from) treat an
- # array as an array of objects which are converted using their #to_yaml
- # method before writing.
#
- # rio('afile.yaml').yaml < [obj1, obj2, obj3]
+ # Single objects can be written using IF::Grande#putrec (aliased to IF::YAML#putobj
+ # and IF::YAML#dump)
#
- # Because of this, copying an ::Array must be done like this:
- #
- # rio('afile.yaml').yaml < [anarray]
- #
- # If their argument is a Rio or ::IO it is iterate through as normal,
- # with each record converted using its to_yaml method.
- #
- # For all other objects, the result of their +to_yaml+ operator is
- # simply written.
- #
- # rio('afile.yaml').yaml < anobject
- #
- # Rio#> (copy-to) and Rio#>> (append-to) will fill an array with with
- # all selected YAML documents in the Rio. For non-arrays, the yaml text
- # is copied. (This may change if a useful reasonable alternative can be
- # found) rio('afile.yaml').yaml > anarray # load all YAML documents from
- # 'afile.yaml'
- #
- # Single objects can be written using Rio#putrec (aliased to Rio#putobj
- # and Rio#dump)
- #
# rio('afile.yaml').yaml.putobj(anobject)
#
- # Single objects can be loaded using Rio#getrec (aliase to Rio#getobj
- # and Rio#load)
+ # Single objects can be loaded using IF::Grande#getrec (aliase to IF::Grande#getobj
+ # and IF::YAML#load)
#
# anobject = rio('afile.yaml').yaml.getobj
#
- # Note that other than this redefinition of what a record is and how the
- # copy operators interpret their argument, a Rio in yaml-mode is just
+ # A Rio in yaml-mode is just
# like any other Rio. And all the things you can do with any Rio come
- # for free. They can be iterated over using #each and read into an
- # array using #[] just like any other Rio. All the selection criteria
+ # for free. They can be iterated over using IF::Grande#each and read into an
+ # array using IF::Grande#[] just like any other Rio. All the selection criteria
# are identical also.
#
# Get the first three objects into an array:
#
# array_of_objects = rio('afile.yaml').yaml[0..2]
#
- # Iterate over only YAML documents that are a kind_of ::Hash use:
+ # Iterate over only YAML documents that are a kind_of ::Hash:
#
# rio('afile.yaml').yaml(::Hash) {|ahash| ...}
#
# This takes advantage of the fact that the default for matching records
# is <tt>===</tt>
@@ -198,20 +172,20 @@
# Calls YAML.dump, leaving the Rio open.
def putobj(obj) target.putobj(obj); self end
- # Dumps an object to a Rio as with Rio#putobj, and closes the Rio.
+ # Dumps an object to a Rio as with IF::YAML#putobj, and closes the Rio.
#
# rio('afile.yaml').yaml.putobj!(anobject)
#
# is identical to
#
# rio('afile.yaml').yaml.putobj(anobject).close
#
def putobj!(obj) target.putobj!(obj); self end
- # Alias for Rio#putobj!
+ # Alias for IF::YAML#putobj!
def dump(obj) target.dump(obj); self end
end
end
end