summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorwhy <why@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-04-03 08:13:22 +0000
committerwhy <why@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-04-03 08:13:22 +0000
commit1ba2a61687b9bc4f1fe7645c629511d0d986cca2 (patch)
treefe4b77b2b5162ad40f8235ed24ab6991c5673596 /lib
parent7c67e3f978264212cea7ded1791da719961c446c (diff)
* ext/syck/syck.h: version 0.43.
* 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] * ext/syck/bytecode.c: turn off default implicit typing. * ext/syck/implicit.c: detect base60 integers. * ext/syck/rubyext.c: handle base60, as well as hex and octal with commas. implicit typing of ruby symbols. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@6083 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/yaml.rb20
-rw-r--r--lib/yaml/rubytypes.rb4
2 files changed, 20 insertions, 4 deletions
diff --git a/lib/yaml.rb b/lib/yaml.rb
index 83ba9cc634..54880182e3 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 0e5d5b17d6..61ade3765f 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
@@ -353,7 +353,7 @@ class Range
def to_yaml( opts = {} )
YAML::quick_emit( nil, opts ) { |out|
out << "!ruby/range "
- self.inspect.to_yaml( :Emitter => out )
+ self.to_s.to_yaml(:Emitter => out)
}
end
end