* lib/yaml/basenode.rb: deprecating YPath methods

* lib/yaml/stream.rb: deprecating YAML::Stream#edit
* test/yaml/test_yaml.rb: requiring yaml/ypath for tests.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27058 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
tenderlove 2010-03-26 03:42:21 +00:00
parent e959fda8ff
commit f82b8e76e8
4 changed files with 16 additions and 1 deletions

View File

@ -1,3 +1,9 @@
Fri Mar 26 12:36:10 2010 Aaron Patterson <aaron@tenderlovemaking.com>
* lib/yaml/basenode.rb: deprecating YPath methods
* lib/yaml/stream.rb: deprecating YAML::Stream#edit
Fri Mar 26 12:29:28 2010 Aaron Patterson <aaron@tenderlovemaking.com> Fri Mar 26 12:29:28 2010 Aaron Patterson <aaron@tenderlovemaking.com>
* lib/yaml/encoding.rb: YAML.encode, YAML.decode are deprecated. * lib/yaml/encoding.rb: YAML.encode, YAML.decode are deprecated.

View File

@ -1,7 +1,6 @@
# #
# YAML::BaseNode class # YAML::BaseNode class
# #
require 'yaml/ypath'
module YAML module YAML
@ -15,6 +14,7 @@ module YAML
# qualified nodes. # qualified nodes.
# #
def select( ypath_str ) def select( ypath_str )
warn "#{caller[0]}: select is deprecated" if $VERBOSE
matches = match_path( ypath_str ) matches = match_path( ypath_str )
# #
@ -34,6 +34,7 @@ module YAML
# transformed nodes. # transformed nodes.
# #
def select!( ypath_str ) def select!( ypath_str )
warn "#{caller[0]}: select!() is deprecated" if $VERBOSE
matches = match_path( ypath_str ) matches = match_path( ypath_str )
# #
@ -53,6 +54,7 @@ module YAML
# qualified paths. # qualified paths.
# #
def search( ypath_str ) def search( ypath_str )
warn "#{caller[0]}: search() is deprecated" if $VERBOSE
matches = match_path( ypath_str ) matches = match_path( ypath_str )
if matches if matches
@ -67,6 +69,7 @@ module YAML
end end
def at( seg ) def at( seg )
warn "#{caller[0]}: at() is deprecated" if $VERBOSE
if Hash === @value if Hash === @value
self[seg] self[seg]
elsif Array === @value and seg =~ /\A\d+\Z/ and @value[seg.to_i] elsif Array === @value and seg =~ /\A\d+\Z/ and @value[seg.to_i]
@ -78,6 +81,8 @@ module YAML
# YPath search returning a complete depth array # YPath search returning a complete depth array
# #
def match_path( ypath_str ) def match_path( ypath_str )
warn "#{caller[0]}: match_path is deprecated" if $VERBOSE
require 'yaml/ypath'
depth = 0 depth = 0
matches = [] matches = []
YPath.each_path( ypath_str ) do |ypath| YPath.each_path( ypath_str ) do |ypath|
@ -91,6 +96,7 @@ module YAML
# Search a node for a single YPath segment # Search a node for a single YPath segment
# #
def match_segment( ypath, depth ) def match_segment( ypath, depth )
warn "#{caller[0]}: match_segment is deprecated" if $VERBOSE
deep_nodes = [] deep_nodes = []
seg = ypath.segments[ depth ] seg = ypath.segments[ depth ]
if seg == "/" if seg == "/"
@ -200,6 +206,7 @@ module YAML
end end
def children_with_index def children_with_index
warn "#{caller[0]}: children_with_index is deprecated, use children" if $VERBOSE
if Hash === @value if Hash === @value
@value.keys.collect { |i| [self[i], i] } @value.keys.collect { |i| [self[i], i] }
elsif Array === @value elsif Array === @value

View File

@ -21,6 +21,7 @@ module YAML
end end
def edit( doc_num, doc ) def edit( doc_num, doc )
warn "#{caller[0]}: edit is deprecated" if $VERBOSE
@documents[ doc_num ] = doc @documents[ doc_num ] = doc
end end

View File

@ -4,6 +4,7 @@
# #
require 'test/unit' require 'test/unit'
require 'yaml' require 'yaml'
require 'yaml/ypath'
# [ruby-core:01946] # [ruby-core:01946]
module YAML_Tests module YAML_Tests