Permalink
Browse files

* ext/psych/lib/psych/visitors/yaml_tree.rb: register time objects so

  they are referenced as ids during output.
* test/psych/test_date_time.rb: corresponding test.

Fixes #146
  • Loading branch information...
1 parent fdb594d commit 5258fab369546994131bd4ca0b57ff7e7f0b0241 @tenderlove tenderlove committed Jul 5, 2013
Showing with 15 additions and 1 deletion.
  1. +6 −0 CHANGELOG.rdoc
  2. +1 −1 lib/psych/visitors/yaml_tree.rb
  3. +8 −0 test/psych/test_date_time.rb
View
@@ -1,3 +1,9 @@
+Sat Jul 6 04:49:38 2013 Aaron Patterson <aaron@tenderlovemaking.com>
+
+ * ext/psych/lib/psych/visitors/yaml_tree.rb: register time objects so
+ they are referenced as ids during output.
+ * test/psych/test_date_time.rb: corresponding test.
+
Wed May 15 02:22:16 2013 Aaron Patterson <aaron@tenderlovemaking.com>
* ext/psych/lib/psych.rb: Adding Psych.safe_load for loading a user
@@ -216,7 +216,7 @@ def visit_DateTime o
def visit_Time o
formatted = format_time o
- @emitter.scalar formatted, nil, nil, true, false, Nodes::Scalar::ANY
+ register o, @emitter.scalar(formatted, nil, nil, true, false, Nodes::Scalar::ANY)
end
def visit_Rational o
@@ -13,5 +13,13 @@ def test_round_trip
dt = DateTime.now
assert_cycle dt
end
+
+ def test_alias_with_time
+ t = Time.now
+ h = {:a => t, :b => t}
+ yaml = Psych.dump h
+ assert_match('&', yaml)
+ assert_match('*', yaml)
+ end
end
end

0 comments on commit 5258fab

Please sign in to comment.