mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* test/rss/test_maker_*.rb: added tests for RSS Maker.
* lib/rss/maker.rb: added RSS Maker. * lib/rss/maker/*.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@7184 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
3d712cdd9d
commit
b45e1493f8
17 changed files with 95 additions and 24 deletions
|
@ -1,3 +1,11 @@
|
|||
Wed Nov 3 15:53:34 2004 Kouhei Sutou <kou@cozmixng.org>
|
||||
|
||||
* test/rss/test_maker_*.rb: added tests for RSS Maker.
|
||||
|
||||
* lib/rss/maker.rb: added RSS Maker.
|
||||
|
||||
* lib/rss/maker/*.rb: ditto.
|
||||
|
||||
Tue Nov 2 16:05:21 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* process.c (rb_f_fork): need to flush stdout and stderr before
|
||||
|
|
|
@ -51,6 +51,14 @@ module RSS
|
|||
end
|
||||
end
|
||||
|
||||
def textinput
|
||||
if @channel
|
||||
@channel.textInput
|
||||
else
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
def to_s(convert=true, indent=calc_indent)
|
||||
next_indent = indent + INDENT
|
||||
rv = <<-EOR
|
||||
|
@ -252,7 +260,7 @@ EOT
|
|||
install_get_attribute(name, uri, required)
|
||||
end
|
||||
|
||||
def initialize(domain, port, path, rp, protocol)
|
||||
def initialize(domain=nil, port=nil, path=nil, rp=nil, protocol=nil)
|
||||
super()
|
||||
@domain = domain
|
||||
@port = port
|
||||
|
|
|
@ -16,7 +16,7 @@ module RSS
|
|||
def self.append_features(klass)
|
||||
super
|
||||
|
||||
klass.module_eval(<<-EOC)
|
||||
klass.module_eval(<<-EOC, *get_file_and_line_from_caller(1))
|
||||
%w(encoded).each do |x|
|
||||
install_text_element("\#{CONTENT_PREFIX}_\#{x}")
|
||||
end
|
||||
|
|
|
@ -16,7 +16,7 @@ module RSS
|
|||
def self.append_features(klass)
|
||||
super
|
||||
|
||||
klass.module_eval(<<-EOC)
|
||||
klass.module_eval(<<-EOC, *get_file_and_line_from_caller(1))
|
||||
%w(title description creator subject publisher
|
||||
contributor type format identifier source
|
||||
language relation coverage rights).each do |x|
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
# Author:: Kouhei Sutou <kou@cozmixng.org>
|
||||
# Tutorial:: http://www.cozmixng.org/~rwiki/?cmd=view;name=RSS+Parser%3A%3ATutorial.en
|
||||
|
||||
|
||||
require "time"
|
||||
|
||||
class Time
|
||||
|
@ -234,7 +235,7 @@ EOC
|
|||
# Is it need?
|
||||
if @#{name}
|
||||
class << @#{name}
|
||||
alias_method(:_to_s, :to_s) unless respond_to?(:_to_s)
|
||||
undef_method(:to_s)
|
||||
alias_method(:to_s, :#{type})
|
||||
end
|
||||
end
|
||||
|
|
|
@ -16,7 +16,7 @@ module RSS
|
|||
def self.append_features(klass)
|
||||
super
|
||||
|
||||
klass.module_eval(<<-EOC)
|
||||
klass.module_eval(<<-EOC, *get_file_and_line_from_caller(1))
|
||||
%w(updatePeriod updateFrequency).each do |x|
|
||||
install_text_element("\#{SY_PREFIX}_\#{x}")
|
||||
end
|
||||
|
@ -34,7 +34,6 @@ module RSS
|
|||
|
||||
alias_method(:_sy_updateFrequency=, :sy_updateFrequency=)
|
||||
def sy_updateFrequency=(new_value)
|
||||
new_value = new_value.strip
|
||||
validate_sy_updateFrequency(new_value) if @do_validate
|
||||
self._sy_updateFrequency = new_value.to_i
|
||||
end
|
||||
|
@ -65,6 +64,7 @@ module RSS
|
|||
|
||||
SY_UPDATEFREQUENCY_AVAILABLE_RE = /\A\s*\+?\d+\s*\z/
|
||||
def validate_sy_updateFrequency(value)
|
||||
value = value.to_s.strip
|
||||
if SY_UPDATEFREQUENCY_AVAILABLE_RE !~ value
|
||||
raise NotAvailableValueError.new("updateFrequency", value)
|
||||
end
|
||||
|
|
|
@ -86,7 +86,7 @@ module RSS
|
|||
|
||||
private
|
||||
def guess_type(filename)
|
||||
/\.([^.]+)/ =~ filename
|
||||
/\.([^.]+)$/ =~ filename
|
||||
GUESS_TABLE[$1]
|
||||
end
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# -*- tab-width: 2 -*- vim: ts=2
|
||||
module Test
|
||||
module Unit
|
||||
module Assertions
|
||||
|
@ -135,5 +134,29 @@ module RSS
|
|||
assert_equal(xss_strs.join("\n"), pi_str)
|
||||
end
|
||||
|
||||
def assert_dublin_core(elems, target)
|
||||
elems.each do |name, value|
|
||||
assert_equal(value, target.__send__("dc_#{name}"))
|
||||
end
|
||||
end
|
||||
|
||||
def assert_syndication(elems, target)
|
||||
elems.each do |name, value|
|
||||
assert_equal(value, target.__send__("sy_#{name}"))
|
||||
end
|
||||
end
|
||||
|
||||
def assert_content(elems, target)
|
||||
elems.each do |name, value|
|
||||
assert_equal(value, target.__send__("content_#{name}"))
|
||||
end
|
||||
end
|
||||
|
||||
def assert_trackback(elems, target)
|
||||
elems.each do |name, value|
|
||||
assert_equal(value, target.__send__("trackback_#{name}"))
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
@ -189,5 +189,52 @@ EOI
|
|||
EOC
|
||||
end
|
||||
|
||||
private
|
||||
def setup_dummy_channel(maker)
|
||||
about = "http://hoge.com"
|
||||
title = "fugafuga"
|
||||
link = "http://hoge.com"
|
||||
description = "fugafugafugafuga"
|
||||
language = "ja"
|
||||
|
||||
maker.channel.about = about
|
||||
maker.channel.title = title
|
||||
maker.channel.link = link
|
||||
maker.channel.description = description
|
||||
maker.channel.language = language
|
||||
end
|
||||
|
||||
def setup_dummy_image(maker)
|
||||
title = "fugafuga"
|
||||
link = "http://hoge.com"
|
||||
url = "http://hoge.com/hoge.png"
|
||||
|
||||
maker.channel.link = link if maker.channel.link.nil?
|
||||
|
||||
maker.image.title = title
|
||||
maker.image.url = url
|
||||
end
|
||||
|
||||
def setup_dummy_textinput(maker)
|
||||
title = "fugafuga"
|
||||
description = "text hoge fuga"
|
||||
name = "hoge"
|
||||
link = "http://hoge.com/search.cgi"
|
||||
|
||||
maker.textinput.title = title
|
||||
maker.textinput.description = description
|
||||
maker.textinput.name = name
|
||||
maker.textinput.link = link
|
||||
end
|
||||
|
||||
def setup_dummy_item(maker)
|
||||
title = "TITLE"
|
||||
link = "http://hoge.com/"
|
||||
|
||||
item = maker.items.new_item
|
||||
item.title = title
|
||||
item.link = link
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
# -*- tab-width: 2 -*- vim: ts=2
|
||||
|
||||
require "rexml/document"
|
||||
|
||||
require "rss-testcase"
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
# -*- tab-width: 2 -*- vim: ts=2
|
||||
|
||||
require "rss-testcase"
|
||||
|
||||
require "rss/1.0"
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
# -*- tab-width: 2 -*- vim: ts=2
|
||||
|
||||
require "cgi"
|
||||
require "rexml/document"
|
||||
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
# -*- tab-width: 2 -*- vim: ts=2
|
||||
|
||||
require "cgi"
|
||||
require "rexml/document"
|
||||
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
# -*- tab-width: 2 -*- vim: ts=2
|
||||
|
||||
require "rss-testcase"
|
||||
|
||||
require "rss/1.0"
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
# -*- tab-width: 2 -*- vim: ts=2
|
||||
|
||||
require "cgi"
|
||||
require "rexml/document"
|
||||
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
# -*- tab-width: 2 -*- vim: ts=2
|
||||
|
||||
require "cgi"
|
||||
require "rexml/document"
|
||||
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
# -*- tab-width: 2 -*- vim: ts=2
|
||||
|
||||
require "rexml/document"
|
||||
|
||||
require "rss-testcase"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue