mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/psych/lib/psych/deprecated.rb: supporting detect_implicit method
* test/psych/test_deprecated.rb: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27478 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
9ac224eb26
commit
b57db764b0
3 changed files with 14 additions and 1 deletions
|
@ -241,6 +241,5 @@ module Psych
|
|||
attr_accessor :dump_tags
|
||||
attr_accessor :domain_types
|
||||
end
|
||||
|
||||
# :startdoc:
|
||||
end
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue