diff options
author | tenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-04-03 21:50:47 +0000 |
---|---|---|
committer | tenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-04-03 21:50:47 +0000 |
commit | eb71e5cd67f4ce4da5ba331f93a8e36c65457b94 (patch) | |
tree | 1df66113ae7340e2b928839b3f09dbf8dcfb3d73 /ext/syck/lib/syck/stream.rb | |
parent | ca926ad017a804817b9a2e5389196f9acf9d9b68 (diff) |
* lib/yaml: Moved to ext/syck/lib, Syck only uses Syck constant.
* lib/yaml.rb: Added an engine manager for choosing YAML engine.
* ext/syck/lib/syck/rubytypes.rb: squashed warnings when using Psych
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27212 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/syck/lib/syck/stream.rb')
-rw-r--r-- | ext/syck/lib/syck/stream.rb | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/ext/syck/lib/syck/stream.rb b/ext/syck/lib/syck/stream.rb new file mode 100644 index 0000000000..cd77a033c6 --- /dev/null +++ b/ext/syck/lib/syck/stream.rb @@ -0,0 +1,41 @@ +module Syck + + # + # YAML::Stream -- for emitting many documents + # + class Stream + + attr_accessor :documents, :options + + def initialize( opts = {} ) + @options = opts + @documents = [] + end + + def []( i ) + @documents[ i ] + end + + def add( doc ) + @documents << doc + end + + def edit( doc_num, doc ) + warn "#{caller[0]}: edit is deprecated" if $VERBOSE + @documents[ doc_num ] = doc + end + + def emit( io = nil ) + # opts = @options.dup + # opts[:UseHeader] = true if @documents.length > 1 + out = Syck.emitter + out.reset( io || io2 = StringIO.new ) + @documents.each { |v| + v.to_yaml( out ) + } + io || ( io2.rewind; io2.read ) + end + + end + +end |