1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib/rss/rss.rb: added backward compatibility codes.

* lib/rss/parser.rb: ditto.
* test/rss/test_parser.rb: ditto.
* test/rss/test_2.0.rb: ditto.

* test/rss/test_content.rb: use #__send__ instead of #funcall for
  no private method.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9611 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
kou 2005-11-25 03:54:29 +00:00
parent 456ba712fe
commit 254670b3bc
6 changed files with 50 additions and 10 deletions

View file

@ -1,3 +1,13 @@
Fri Nov 25 12:52:57 2005 Kouhei Sutou <kou@cozmixng.org>
* lib/rss/rss.rb: added backward compatibility codes.
* lib/rss/parser.rb: ditto.
* test/rss/test_parser.rb: ditto.
* test/rss/test_2.0.rb: ditto.
* test/rss/test_content.rb: use #__send__ instead of #funcall for
no private method.
Fri Nov 25 12:39:56 2005 Kouhei Sutou <kou@cozmixng.org> Fri Nov 25 12:39:56 2005 Kouhei Sutou <kou@cozmixng.org>
* lib/rss/rss.rb: improved type conversion. * lib/rss/rss.rb: improved type conversion.

View file

@ -1,5 +1,17 @@
require "forwardable" require "forwardable"
require "open-uri" begin
require "open-uri"
rescue LoadError
require "uri"
end
unless Kernel.methods.include?("URI")
module Kernel
def URI(uri_str) # :doc:
URI.parse(uri_str)
end
module_function :URI
end
end
require "rss/rss" require "rss/rss"
@ -414,7 +426,7 @@ module RSS
end end
previous = @last_element previous = @last_element
next_element = klass.__send__(:new, *args) next_element = klass.new(*args)
next_element.do_validate = @do_validate next_element.do_validate = @do_validate
previous.funcall(:set_next_element, tag_name, next_element) previous.funcall(:set_next_element, tag_name, next_element)
@last_element = next_element @last_element = next_element

View file

@ -52,6 +52,14 @@ class Hash
end end
end end
module Kernel
unless methods.include?("funcall")
def funcall(*args, &block)
__send__(*args, &block)
end
end
end
require "English" require "English"
require "rss/utils" require "rss/utils"
require "rss/converter" require "rss/converter"

View file

@ -145,7 +145,7 @@ module RSS
actual = {} actual = {}
cloud_elem.attributes.each do |name, value| cloud_elem.attributes.each do |name, value|
value = value.to_i if name == "port" value = value.to_i if name == "port"
actual[name.to_sym] = value actual[name.intern] = value
end end
assert_equal(cloud_params, actual) assert_equal(cloud_params, actual)
end end
@ -313,7 +313,7 @@ module RSS
actual = {} actual = {}
enclosure_elem.attributes.each do |name, value| enclosure_elem.attributes.each do |name, value|
value = value.to_i if name == "length" value = value.to_i if name == "length"
actual[name.to_sym] = value actual[name.intern] = value
end end
assert_equal(enclosure_params, actual) assert_equal(enclosure_params, actual)
end end
@ -348,7 +348,7 @@ module RSS
actual[:content] = guid_elem.text if guid_elem.text actual[:content] = guid_elem.text if guid_elem.text
guid_elem.attributes.each do |name, value| guid_elem.attributes.each do |name, value|
value = value == "true" if name == "isPermaLink" value = value == "true" if name == "isPermaLink"
actual[name.to_sym] = value actual[name.intern] = value
end end
assert_equal(guid_params, actual) assert_equal(guid_params, actual)
end end
@ -369,7 +369,7 @@ module RSS
actual = {} actual = {}
actual[:content] = source_elem.text actual[:content] = source_elem.text
source_elem.attributes.each do |name, value| source_elem.attributes.each do |name, value|
actual[name.to_sym] = value actual[name.intern] = value
end end
assert_equal(source_params, actual) assert_equal(source_params, actual)
end end

View file

@ -61,9 +61,9 @@ EOR
@elems.each do |name, value| @elems.each do |name, value|
@parents.each do |parent| @parents.each do |parent|
meth = "#{RSS::CONTENT_PREFIX}_#{name}" meth = "#{RSS::CONTENT_PREFIX}_#{name}"
assert_equal(value, @rss.__send__(parent).funcall(meth)) assert_equal(value, @rss.__send__(parent).__send__(meth))
@rss.__send__(parent).funcall("#{meth}=", new_value[name].to_s) @rss.__send__(parent).__send__("#{meth}=", new_value[name].to_s)
assert_equal(new_value[name], @rss.__send__(parent).funcall(meth)) assert_equal(new_value[name], @rss.__send__(parent).__send__(meth))
end end
end end

View file

@ -1,4 +1,14 @@
require "fileutils" begin
require "fileutils"
rescue LoadError
module FileUtils
module_function
def rm_f(target)
File.unlink(target)
rescue Errno::ENOENT
end
end
end
require "rss-testcase" require "rss-testcase"