summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--lib/rss/0.9.rb10
-rw-r--r--lib/rss/content.rb2
-rw-r--r--lib/rss/dublincore.rb2
-rw-r--r--lib/rss/rss.rb3
-rw-r--r--lib/rss/syndication.rb4
-rw-r--r--lib/rss/xml-stylesheet.rb2
-rw-r--r--test/rss/rss-assertions.rb25
-rw-r--r--test/rss/rss-testcase.rb47
-rw-r--r--test/rss/test_1.0.rb2
-rw-r--r--test/rss/test_accessor.rb2
-rw-r--r--test/rss/test_content.rb2
-rw-r--r--test/rss/test_dublincore.rb2
-rw-r--r--test/rss/test_parser.rb2
-rw-r--r--test/rss/test_syndication.rb2
-rw-r--r--test/rss/test_trackback.rb2
-rw-r--r--test/rss/test_xml-stylesheet.rb2
17 files changed, 95 insertions, 24 deletions
diff --git a/ChangeLog b/ChangeLog
index 29ead92147..97b15192b6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
diff --git a/lib/rss/0.9.rb b/lib/rss/0.9.rb
index dd5f93b868..c772e80870 100644
--- a/lib/rss/0.9.rb
+++ b/lib/rss/0.9.rb
@@ -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
diff --git a/lib/rss/content.rb b/lib/rss/content.rb
index 4367d16d92..280bbb8d6b 100644
--- a/lib/rss/content.rb
+++ b/lib/rss/content.rb
@@ -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
diff --git a/lib/rss/dublincore.rb b/lib/rss/dublincore.rb
index 417ab5b179..7ea9cf31dd 100644
--- a/lib/rss/dublincore.rb
+++ b/lib/rss/dublincore.rb
@@ -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|
diff --git a/lib/rss/rss.rb b/lib/rss/rss.rb
index 231fb1fb62..b6afa24b93 100644
--- a/lib/rss/rss.rb
+++ b/lib/rss/rss.rb
@@ -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
diff --git a/lib/rss/syndication.rb b/lib/rss/syndication.rb
index 75f612864d..c274ff8c82 100644
--- a/lib/rss/syndication.rb
+++ b/lib/rss/syndication.rb
@@ -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
diff --git a/lib/rss/xml-stylesheet.rb b/lib/rss/xml-stylesheet.rb
index 726899ed88..c51c0dc71a 100644
--- a/lib/rss/xml-stylesheet.rb
+++ b/lib/rss/xml-stylesheet.rb
@@ -86,7 +86,7 @@ module RSS
private
def guess_type(filename)
- /\.([^.]+)/ =~ filename
+ /\.([^.]+)$/ =~ filename
GUESS_TABLE[$1]
end
diff --git a/test/rss/rss-assertions.rb b/test/rss/rss-assertions.rb
index 40a72e93cd..6b83cbe093 100644
--- a/test/rss/rss-assertions.rb
+++ b/test/rss/rss-assertions.rb
@@ -1,4 +1,3 @@
-# -*- tab-width: 2 -*- vim: ts=2
module Test
module Unit
module Assertions
@@ -134,6 +133,30 @@ module RSS
pi_str = rdf.to_s.gsub(/<\?xml .*\n/, "").gsub(/\s*<rdf:RDF.*\z/m, "")
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
diff --git a/test/rss/rss-testcase.rb b/test/rss/rss-testcase.rb
index 098263a392..27b4eba5d6 100644
--- a/test/rss/rss-testcase.rb
+++ b/test/rss/rss-testcase.rb
@@ -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
diff --git a/test/rss/test_1.0.rb b/test/rss/test_1.0.rb
index 43a168d035..e6a81af2bd 100644
--- a/test/rss/test_1.0.rb
+++ b/test/rss/test_1.0.rb
@@ -1,5 +1,3 @@
-# -*- tab-width: 2 -*- vim: ts=2
-
require "rexml/document"
require "rss-testcase"
diff --git a/test/rss/test_accessor.rb b/test/rss/test_accessor.rb
index 1b92f9d98c..5281a81c2c 100644
--- a/test/rss/test_accessor.rb
+++ b/test/rss/test_accessor.rb
@@ -1,5 +1,3 @@
-# -*- tab-width: 2 -*- vim: ts=2
-
require "rss-testcase"
require "rss/1.0"
diff --git a/test/rss/test_content.rb b/test/rss/test_content.rb
index c0f6e4292f..77cd1c7005 100644
--- a/test/rss/test_content.rb
+++ b/test/rss/test_content.rb
@@ -1,5 +1,3 @@
-# -*- tab-width: 2 -*- vim: ts=2
-
require "cgi"
require "rexml/document"
diff --git a/test/rss/test_dublincore.rb b/test/rss/test_dublincore.rb
index 796666cdb5..d95d31f24e 100644
--- a/test/rss/test_dublincore.rb
+++ b/test/rss/test_dublincore.rb
@@ -1,5 +1,3 @@
-# -*- tab-width: 2 -*- vim: ts=2
-
require "cgi"
require "rexml/document"
diff --git a/test/rss/test_parser.rb b/test/rss/test_parser.rb
index 3fd26bffb4..de4894997f 100644
--- a/test/rss/test_parser.rb
+++ b/test/rss/test_parser.rb
@@ -1,5 +1,3 @@
-# -*- tab-width: 2 -*- vim: ts=2
-
require "rss-testcase"
require "rss/1.0"
diff --git a/test/rss/test_syndication.rb b/test/rss/test_syndication.rb
index 9d620089e1..a3dd763c83 100644
--- a/test/rss/test_syndication.rb
+++ b/test/rss/test_syndication.rb
@@ -1,5 +1,3 @@
-# -*- tab-width: 2 -*- vim: ts=2
-
require "cgi"
require "rexml/document"
diff --git a/test/rss/test_trackback.rb b/test/rss/test_trackback.rb
index 9c4b086cae..bfe39d005b 100644
--- a/test/rss/test_trackback.rb
+++ b/test/rss/test_trackback.rb
@@ -1,5 +1,3 @@
-# -*- tab-width: 2 -*- vim: ts=2
-
require "cgi"
require "rexml/document"
diff --git a/test/rss/test_xml-stylesheet.rb b/test/rss/test_xml-stylesheet.rb
index f3dee2c63b..ab16d6e2ff 100644
--- a/test/rss/test_xml-stylesheet.rb
+++ b/test/rss/test_xml-stylesheet.rb
@@ -1,5 +1,3 @@
-# -*- tab-width: 2 -*- vim: ts=2
-
require "rexml/document"
require "rss-testcase"