mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/yaml/rubytypes.rb: remove comments that are bungling up
the rdoc and ri output. output symbols as plain scalars. * ext/syck/rubyext.c (syck_emitter_reset): emit headless documents always. * ext/syck/emitter.c (syck_scan_scalar): quote scalars with any kind of surrounding line space, tabs or spaces alike. * ext/syck/token.c: accept tabs as whitespace, not for indentation, but strip from plain scalars. * test/yaml/test_yaml.rb: remove outdated tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9207 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
17f4f5f507
commit
f3d9f34537
7 changed files with 583 additions and 610 deletions
|
@ -1,9 +1,6 @@
|
|||
# -*- mode: ruby; ruby-indent-level: 4; tab-width: 4 -*- vim: sw=4 ts=4
|
||||
require 'date'
|
||||
|
||||
#
|
||||
# Type conversions
|
||||
#
|
||||
class Class
|
||||
def to_yaml( opts = {} )
|
||||
raise TypeError, "can't dump anonymous class %s" % self.class
|
||||
|
@ -25,9 +22,6 @@ class Object
|
|||
end
|
||||
end
|
||||
|
||||
#
|
||||
# Maps: Hash#to_yaml
|
||||
#
|
||||
class Hash
|
||||
yaml_as "tag:ruby.yaml.org,2002:hash"
|
||||
yaml_as "tag:yaml.org,2002:map"
|
||||
|
@ -51,9 +45,6 @@ class Hash
|
|||
end
|
||||
end
|
||||
|
||||
#
|
||||
# Structs: export as a !map
|
||||
#
|
||||
class Struct
|
||||
yaml_as "tag:ruby.yaml.org,2002:struct"
|
||||
def self.yaml_tag_class_name; self.name.gsub( "Struct::", "" ); end
|
||||
|
@ -108,9 +99,6 @@ class Struct
|
|||
end
|
||||
end
|
||||
|
||||
#
|
||||
# Sequences: Array#to_yaml
|
||||
#
|
||||
class Array
|
||||
yaml_as "tag:ruby.yaml.org,2002:array"
|
||||
yaml_as "tag:yaml.org,2002:seq"
|
||||
|
@ -126,9 +114,6 @@ class Array
|
|||
end
|
||||
end
|
||||
|
||||
#
|
||||
# Exception#to_yaml
|
||||
#
|
||||
class Exception
|
||||
yaml_as "tag:ruby.yaml.org,2002:exception"
|
||||
def Exception.yaml_new( klass, tag, val )
|
||||
|
@ -150,10 +135,6 @@ class Exception
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
#
|
||||
# String#to_yaml
|
||||
#
|
||||
class String
|
||||
yaml_as "tag:ruby.yaml.org,2002:string"
|
||||
yaml_as "tag:yaml.org,2002:str"
|
||||
|
@ -194,9 +175,7 @@ class String
|
|||
end
|
||||
end
|
||||
end
|
||||
#
|
||||
# Symbol#to_yaml
|
||||
#
|
||||
|
||||
class Symbol
|
||||
yaml_as "tag:ruby.yaml.org,2002:symbol"
|
||||
yaml_as "tag:ruby.yaml.org,2002:sym"
|
||||
|
@ -210,15 +189,11 @@ class Symbol
|
|||
end
|
||||
def to_yaml( opts = {} )
|
||||
YAML::quick_emit( nil, opts ) do |out|
|
||||
out.scalar( taguri, self.id2name, :plain )
|
||||
out.scalar( "tag:yaml.org,2002:str", self.inspect, :plain )
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
# Range#to_yaml
|
||||
# TODO: Rework the Range as a sequence (simpler)
|
||||
#
|
||||
class Range
|
||||
yaml_as "tag:ruby.yaml.org,2002:range"
|
||||
def Range.yaml_new( klass, tag, val )
|
||||
|
@ -273,9 +248,6 @@ class Range
|
|||
end
|
||||
end
|
||||
|
||||
#
|
||||
# Make an Regexp
|
||||
#
|
||||
class Regexp
|
||||
yaml_as "tag:ruby.yaml.org,2002:regexp"
|
||||
def Regexp.yaml_new( klass, tag, val )
|
||||
|
@ -323,9 +295,6 @@ class Regexp
|
|||
end
|
||||
end
|
||||
|
||||
#
|
||||
# Emit a Time object as an ISO 8601 timestamp
|
||||
#
|
||||
class Time
|
||||
yaml_as "tag:ruby.yaml.org,2002:time"
|
||||
yaml_as "tag:yaml.org,2002:timestamp"
|
||||
|
@ -373,9 +342,6 @@ class Time
|
|||
end
|
||||
end
|
||||
|
||||
#
|
||||
# Emit a Date object as a simple implicit
|
||||
#
|
||||
class Date
|
||||
yaml_as "tag:yaml.org,2002:timestamp#ymd"
|
||||
def to_yaml( opts = {} )
|
||||
|
@ -385,9 +351,6 @@ class Date
|
|||
end
|
||||
end
|
||||
|
||||
#
|
||||
# Send Integer, Booleans, NilClass to String
|
||||
#
|
||||
class Numeric
|
||||
def to_yaml( opts = {} )
|
||||
YAML::quick_emit( nil, opts ) do |out|
|
||||
|
@ -403,9 +366,11 @@ class Numeric
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Fixnum
|
||||
yaml_as "tag:yaml.org,2002:int"
|
||||
end
|
||||
|
||||
class Float
|
||||
yaml_as "tag:yaml.org,2002:float"
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue