lib/ttk/dumpers/Yaml.rb in ttk-0.1.580 vs lib/ttk/dumpers/Yaml.rb in ttk-0.2.0
- old
+ new
@@ -1,12 +1,12 @@
# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
# Copyright:: Copyright (c) 2004, 2005 TTK team. All rights reserved.
# License:: LGPL
-# $Id: Yaml.rb 578 2005-04-14 20:46:09Z ertai $
+# $Id: Yaml.rb 598 2005-06-03 09:35:10Z ertai $
-class Symbol # :nodoc:
+class Symbol
alias_method :old_to_yaml, :to_yaml
def to_yaml ( opts={} )
# FIXME
# if opts[:ttk]
self.to_s.to_yaml(opts)
@@ -14,18 +14,18 @@
# old_to_yaml(opts)
# end
end
end
-class Class # :nodoc:
+class Class
alias_method :old_to_yaml, :to_yaml
def to_yaml ( opts={} )
self.to_s.sub(/^TTK::Strategies::/, '').to_yaml(opts)
end
end
-class Regexp # :nodoc:
+class Regexp
alias_method :old_to_yaml_type, :to_yaml_type
alias_method :old_to_yaml, :to_yaml
def to_yaml_type
'!re'
end
@@ -34,30 +34,22 @@
out << "#{to_yaml_type} #{source}"
end
end
end
-YAML.add_builtin_type('!re') do |type, val|
- Regexp.new(val.to_s)
-end
-
-class Pathname # :nodoc:
+class Pathname
alias_method :old_to_yaml, :to_yaml
def to_yaml ( opts={} )
if opts[:ttk]
self.to_s.to_yaml(opts)
else
old_to_yaml(opts)
end
end
end
-YAML.add_builtin_type('!path') do |type, val|
- Pathname.new(val.to_s)
-end
-
-class OHash # :nodoc:
+class OHash
def to_yaml ( opts={} )
if opts[:ttk]
YAML::quick_emit(self.object_id, opts) do |out|
out.seq('') do |seq|
self.each do |k,v|
@@ -85,11 +77,10 @@
def initialize ( *a, &b )
super
@indent = ''
@stack_indent = []
@endl = true
- @flushable = @io.respond_to?(:flush)
@io.puts '---'
@opts = {:ttk => true}
end
@@ -148,10 +139,10 @@
private :clean_to_yaml
def update ( *a, &b )
super
- @io.flush if @flushable and (not @io.closed?)
+ flush
end
end # class Yaml
end # module Dumpers