From bec41aa80d5977c3f9315e3761f4d364d311960d Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 6 Oct 2009 16:50:50 -0700 Subject: emitting dates --- lib/psych/ruby.rb | 4 ++-- lib/psych/visitors/yast_builder.rb | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/psych/ruby.rb b/lib/psych/ruby.rb index e68632b..6258e81 100644 --- a/lib/psych/ruby.rb +++ b/lib/psych/ruby.rb @@ -1,14 +1,14 @@ require 'complex' require 'rational' +require 'date' [ Object, String, Class, Hash, Array, NilClass, Float, - FalseClass, TrueClass, Range, Complex, Rational + FalseClass, TrueClass, Range, Complex, Rational, Date # Struct # Exception # Regexp # Time - # Date ].each do |klass| klass.send(:remove_method, :to_yaml) rescue NameError end diff --git a/lib/psych/visitors/yast_builder.rb b/lib/psych/visitors/yast_builder.rb index c0396e2..9111f8b 100644 --- a/lib/psych/visitors/yast_builder.rb +++ b/lib/psych/visitors/yast_builder.rb @@ -21,6 +21,10 @@ module Psych raise TypeError, "Can't dump #{target.class}" end + def visit_Date o + append Nodes::Scalar.new o.to_s + end + def visit_Rational o @stack.push append Nodes::Mapping.new(nil,'!ruby/object:Rational',false) ['denominator', o.denominator, 'numerator', o.numerator].each do |m| -- cgit v1.2.3