summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/psych/lib/psych.rb1
-rw-r--r--ext/psych/lib/psych/deprecated.rb6
-rw-r--r--test/psych/test_deprecated.rb8
3 files changed, 14 insertions, 1 deletions
diff --git a/ext/psych/lib/psych.rb b/ext/psych/lib/psych.rb
index 16602ef221..a582f56eb1 100644
--- a/ext/psych/lib/psych.rb
+++ b/ext/psych/lib/psych.rb
@@ -241,6 +241,5 @@ module Psych
attr_accessor :dump_tags
attr_accessor :domain_types
end
-
# :startdoc:
end
diff --git a/ext/psych/lib/psych/deprecated.rb b/ext/psych/lib/psych/deprecated.rb
index 093f145302..fdff46845d 100644
--- a/ext/psych/lib/psych/deprecated.rb
+++ b/ext/psych/lib/psych/deprecated.rb
@@ -30,6 +30,12 @@ module Psych
list.each(&block)
end
+ def self.detect_implicit thing
+ warn "#{caller[0]}: detect_implicit is deprecated" if $VERBOSE
+ return '' unless String === thing
+ return 'null' if '' == thing
+ ScalarScanner.new.tokenize(thing).class.name.downcase
+ end
end
class Object
diff --git a/test/psych/test_deprecated.rb b/test/psych/test_deprecated.rb
index c93b36ed44..f5ff79b56d 100644
--- a/test/psych/test_deprecated.rb
+++ b/test/psych/test_deprecated.rb
@@ -163,5 +163,13 @@ module Psych
assert_equal [["tag:ruby.yaml.org,2002:foo", "bar"]], types
end
+
+ def test_detect_implicit
+ assert_equal '', Psych.detect_implicit(nil)
+ assert_equal '', Psych.detect_implicit(Object.new)
+ assert_equal '', Psych.detect_implicit(1.2)
+ assert_equal 'null', Psych.detect_implicit('')
+ assert_equal 'string', Psych.detect_implicit('foo')
+ end
end
end