summaryrefslogtreecommitdiff
path: root/lib/yaml/rubytypes.rb
diff options
context:
space:
mode:
authorwhy <why@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-04-26 23:24:46 +0000
committerwhy <why@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-04-26 23:24:46 +0000
commita7524e343c1db6c3d336e0223029a1392fa080e2 (patch)
tree69a30e0e5d0cbe200622e7885f07f19cf27d56c8 /lib/yaml/rubytypes.rb
parent10b598499b61d2c95a417f145e4cc70d96aeee71 (diff)
* lib/yaml/rubytypes.rb: passing Range tests.
* ext/syck/syck.h: version 0.44. * ext/syck/gram.c: transfers no longer open an indentation. fixed transfers which precede blocks. * ext/syck/token.c: ditto. * ext/syck/syck.c: fixed segfault if an anchor has been released already. * ext/syck/node.c (syck_free_members): organized order of free'd nodes. * ext/syck/rubyext.c (syck_emitter_write_m): test for proper string with StringValue. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6221 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/yaml/rubytypes.rb')
-rw-r--r--lib/yaml/rubytypes.rb12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/yaml/rubytypes.rb b/lib/yaml/rubytypes.rb
index 61ade3765f..7d36b468d6 100644
--- a/lib/yaml/rubytypes.rb
+++ b/lib/yaml/rubytypes.rb
@@ -352,16 +352,20 @@ class Range
end
def to_yaml( opts = {} )
YAML::quick_emit( nil, opts ) { |out|
- out << "!ruby/range "
- self.to_s.to_yaml(:Emitter => out)
+ out << "!ruby/range '"
+ self.begin.to_yaml(:Emitter => out)
+ out << ( self.exclude_end? ? "..." : ".." )
+ self.end.to_yaml(:Emitter => out)
+ out << "'"
}
end
end
YAML.add_ruby_type( 'range' ) { |type, val|
- if String === val and val =~ /^(.*[^.])(\.{2,3})([^.].*)$/
+ inr = '(\w+|[+-]*\d+(?:\.\d+)?|"(?:[^\\"]|\\.)*")'
+ if String === val and val =~ /^#{inr}(\.{2,3})#{inr}$/
r1, rdots, r2 = $1, $2, $3
- Range.new( YAML.try_implicit( r1 ), YAML.try_implicit( r2 ), rdots.length == 3 )
+ Range.new( YAML.load( "--- #{r1}" ), YAML.load( "--- #{r2}" ), rdots.length == 3 )
elsif Hash === val
Range.new( val['begin'], val['end'], val['exclude_end?'] )
else