diff options
| author | why <why@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-04-02 23:31:14 +0000 |
|---|---|---|
| committer | why <why@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-04-02 23:31:14 +0000 |
| commit | e693e176f4306ff745b409be9846279a88633675 (patch) | |
| tree | adef687820d474cdfded3db8f888857b16a70b01 /lib | |
| parent | cfd8f256bd90884af4f1fb8764c605361c3ea3b1 (diff) | |
| download | ruby-e693e176f4306ff745b409be9846279a88633675.tar.gz ruby-e693e176f4306ff745b409be9846279a88633675.tar.xz ruby-e693e176f4306ff745b409be9846279a88633675.zip | |
* ext/syck/lib/gram.c: allow root-level inline collections.
[ruby-talk:94922]
* lib/yaml/rubytypes.rb (Symbol#to_yaml): emit symbols as implicits.
[ruby-talk:94930]
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@6079 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/yaml.rb | 20 | ||||
| -rw-r--r-- | lib/yaml/rubytypes.rb | 2 |
2 files changed, 19 insertions, 3 deletions
diff --git a/lib/yaml.rb b/lib/yaml.rb index 83ba9cc63..54880182e 100644 --- a/lib/yaml.rb +++ b/lib/yaml.rb @@ -88,6 +88,17 @@ module YAML end # + # Dump documents to a stream + # + def YAML.dump_stream( *objs ) + d = YAML::Stream.new + objs.each do |doc| + d.add( doc ) + end + d.emit + end + + # # Add a transfer method to a domain # def YAML.add_domain_type( domain, type_re, &transfer_proc ) @@ -215,9 +226,14 @@ module Kernel # ryan:: Either way, I certainly will have a pony parade. # - def y( x ) - puts x.to_yaml + def y( *x ) + puts( if x.length == 1 + YAML::dump( *x ) + else + YAML::dump_stream( *x ) + end ) end + private :y end diff --git a/lib/yaml/rubytypes.rb b/lib/yaml/rubytypes.rb index 3fc243710..61ade3765 100644 --- a/lib/yaml/rubytypes.rb +++ b/lib/yaml/rubytypes.rb @@ -327,7 +327,7 @@ class Symbol end def to_yaml( opts = {} ) YAML::quick_emit( nil, opts ) { |out| - out << "!ruby/sym " + out << ":" self.id2name.to_yaml( :Emitter => out ) } end |
