diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2009-10-07 09:40:02 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2009-10-07 09:40:02 -0700 |
commit | 4d047de2c59b71bbe6b4d438970b2c93012662b4 (patch) | |
tree | 59cdb64b78b72b0683e00161226e41cd7d2fb706 | |
parent | 762d889dc911c43274aa4c00104302d36e883add (diff) | |
download | psych-4d047de2c59b71bbe6b4d438970b2c93012662b4.zip |
regexps now roundtrip
-rw-r--r-- | lib/psych/visitors/yast_builder.rb | 4 | ||||
-rw-r--r-- | test/visitors/test_yast_builder.rb | 6 |
2 files changed, 10 insertions, 0 deletions
diff --git a/lib/psych/visitors/yast_builder.rb b/lib/psych/visitors/yast_builder.rb index 1f1eae4..1cfcd33 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_Regexp o + append Nodes::Scalar.new(o.inspect, nil, '!ruby/regexp', false) + end + def visit_Time o formatted = o.strftime("%Y-%m-%d %H:%M:%S") if o.utc? diff --git a/test/visitors/test_yast_builder.rb b/test/visitors/test_yast_builder.rb index 8205430..dec8c6a 100644 --- a/test/visitors/test_yast_builder.rb +++ b/test/visitors/test_yast_builder.rb @@ -8,6 +8,12 @@ module Psych @v = Visitors::YASTBuilder.new end + def test_regexp + assert_round_trip(/foo/) + assert_round_trip(/foo/i) + assert_round_trip(/foo/mx) + end + def test_time assert_round_trip Time.now end |