From 73af8137d9df0ef0bbdf49c4744242f727ed227f Mon Sep 17 00:00:00 2001 From: tenderlove Date: Mon, 21 Feb 2011 01:06:34 +0000 Subject: * ext/psych/lib/psych/json/ruby_events.rb: DRY up ruby event handling for JSON. * ext/psych/lib/psych/visitors/json_tree.rb: use ruby events module * ext/psych/lib/psych/json/stream.rb: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30929 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/psych/lib/psych/visitors/json_tree.rb | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) (limited to 'ext/psych/lib/psych/visitors/json_tree.rb') diff --git a/ext/psych/lib/psych/visitors/json_tree.rb b/ext/psych/lib/psych/visitors/json_tree.rb index dd06e80607..292afae623 100644 --- a/ext/psych/lib/psych/visitors/json_tree.rb +++ b/ext/psych/lib/psych/visitors/json_tree.rb @@ -1,23 +1,13 @@ +require 'psych/json/ruby_events' + module Psych module Visitors class JSONTree < YAMLTree + include Psych::JSON::RubyEvents + def initialize options = {}, emitter = Psych::JSON::TreeBuilder.new super end - - def visit_Time o - formatted = format_time o - @emitter.scalar formatted, nil, nil, false, true, Nodes::Scalar::DOUBLE_QUOTED - end - - def visit_DateTime o - visit_Time o.to_time - end - - def visit_String o - @emitter.scalar o.to_s, nil, nil, false, true, Nodes::Scalar::DOUBLE_QUOTED - end - alias :visit_Symbol :visit_String end end end -- cgit v1.2.3