summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSHIBATA Hiroshi <hsbt@ruby-lang.org>2017-03-03 16:57:06 +0900
committerSHIBATA Hiroshi <hsbt@ruby-lang.org>2017-03-03 16:57:06 +0900
commit2aba01fe63bcd26ab3880a5f98eb0477c58758d5 (patch)
tree20bf55f1a2d38b029e323337a29ae034d4b7acb9
parentd65cc11cedc7b0e834cd2ee70b10f95721662082 (diff)
downloadpsych-2aba01fe63bcd26ab3880a5f98eb0477c58758d5.tar.gz
Removed aliases for Syck module.
* Removed alias for to_yaml. * Renamed pysch_to_yaml to to_yaml. * Removed Pysch.quick_emit. Because it caused infinite recuresion call used to_yaml.
-rw-r--r--lib/psych/core_ext.rb6
-rw-r--r--lib/psych/deprecated.rb13
-rw-r--r--test/psych/helper.rb10
-rw-r--r--test/psych/test_deprecated.rb37
4 files changed, 7 insertions, 59 deletions
diff --git a/lib/psych/core_ext.rb b/lib/psych/core_ext.rb
index 1a98279..56e24bf 100644
--- a/lib/psych/core_ext.rb
+++ b/lib/psych/core_ext.rb
@@ -4,18 +4,14 @@ class Object
Psych.add_tag(url, self)
end
- # FIXME: rename this to "to_yaml" when syck is removed
-
###
# call-seq: to_yaml(options = {})
#
# Convert an object to YAML. See Psych.dump for more information on the
# available +options+.
- def psych_to_yaml options = {}
+ def to_yaml options = {}
Psych.dump self, options
end
- remove_method :to_yaml rescue nil
- alias :to_yaml :psych_to_yaml
end
class Module
diff --git a/lib/psych/deprecated.rb b/lib/psych/deprecated.rb
index 165d210..6a98eec 100644
--- a/lib/psych/deprecated.rb
+++ b/lib/psych/deprecated.rb
@@ -9,19 +9,6 @@ module Psych
attr_accessor :to_yaml_style
end
- def self.quick_emit thing, opts = {}, &block # :nodoc:
- warn "#{caller[0]}: YAML.quick_emit is deprecated" if $VERBOSE && !caller[0].start_with?(File.dirname(__FILE__))
- target = eval 'self', block.binding
- target.extend DeprecatedMethods
- metaclass = class << target; self; end
- metaclass.send(:define_method, :encode_with) do |coder|
- target.taguri = coder.tag
- target.to_yaml_style = coder.style
- block.call coder
- end
- target.psych_to_yaml unless opts[:nodump]
- end
-
# This method is deprecated, use Psych.load_stream instead.
def self.load_documents yaml, &block
if $VERBOSE
diff --git a/test/psych/helper.rb b/test/psych/helper.rb
index 0474cf1..7b564bd 100644
--- a/test/psych/helper.rb
+++ b/test/psych/helper.rb
@@ -50,10 +50,10 @@ module Psych
def assert_to_yaml( obj, yaml )
assert_equal( obj, Psych::load( yaml ) )
assert_equal( obj, Psych::parse( yaml ).transform )
- assert_equal( obj, Psych::load( obj.psych_to_yaml ) )
- assert_equal( obj, Psych::parse( obj.psych_to_yaml ).transform )
+ assert_equal( obj, Psych::load( obj.to_yaml ) )
+ assert_equal( obj, Psych::parse( obj.to_yaml ).transform )
assert_equal( obj, Psych::load(
- obj.psych_to_yaml(
+ obj.to_yaml(
:UseVersion => true, :UseHeader => true, :SortKeys => true
)
))
@@ -73,11 +73,11 @@ module Psych
if obj.nil?
assert_nil Psych.load(v.tree.yaml)
assert_nil Psych::load(Psych.dump(obj))
- assert_nil Psych::load(obj.psych_to_yaml)
+ assert_nil Psych::load(obj.to_yaml)
else
assert_equal(obj, Psych.load(v.tree.yaml))
assert_equal(obj, Psych::load(Psych.dump(obj)))
- assert_equal(obj, Psych::load(obj.psych_to_yaml))
+ assert_equal(obj, Psych::load(obj.to_yaml))
end
end
diff --git a/test/psych/test_deprecated.rb b/test/psych/test_deprecated.rb
index a806f6b..6489edd 100644
--- a/test/psych/test_deprecated.rb
+++ b/test/psych/test_deprecated.rb
@@ -8,47 +8,12 @@ module Psych
Psych.domain_types.clear
end
- class QuickEmitter
- attr_reader :name
- attr_reader :value
-
- def initialize
- @name = 'hello!!'
- @value = 'Friday!'
- end
-
- def to_yaml opts = {}
- Psych.quick_emit object_id, opts do |out|
- out.map taguri, to_yaml_style do |map|
- map.add 'name', @name
- map.add 'value', nil
- end
- end
- end
- end
+ class QuickEmitter; end
def setup
- @qe = QuickEmitter.new
@orig_verbose, $VERBOSE = $VERBOSE, false
end
- def test_quick_emit
- qe2 = Psych.load @qe.to_yaml
- assert_equal @qe.name, qe2.name
- assert_instance_of QuickEmitter, qe2
- assert_nil qe2.value
- end
-
- def test_recursive_quick_emit
- hash = { :qe => @qe }
- hash2 = Psych.load Psych.dump hash
- qe = hash2[:qe]
-
- assert_equal @qe.name, qe.name
- assert_instance_of QuickEmitter, qe
- assert_nil qe.value
- end
-
class QuickEmitterEncodeWith
attr_reader :name
attr_reader :value