summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--lib/rss/maker/1.0.rb1
-rw-r--r--lib/rss/maker/base.rb19
-rw-r--r--lib/rss/maker/feed.rb2
-rw-r--r--test/rss/test_maker_1.0.rb20
-rw-r--r--test/rss/test_maker_atom_feed.rb9
6 files changed, 58 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 84bf7b09dd2..7435b7f077e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Sat May 16 18:02:16 2009 Kouhei Sutou <kou@cozmixng.org>
+
+ * lib/rss/maker/base.rb, lib/rss/maker/1.0.rb, lib/rss/maker/feed.rb,
+ test/rss/test_maker_1.0.rb, test/rss/test_maker_atom_feed.rb:
+ RSS 1.0 and Atom feed maker treat maker.channel.language as
+ maker.channel.dc_language.
+
Sat May 16 17:57:39 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/dl/lib/dl/callback.rb (DL#remove_callback_internal): ignore
diff --git a/lib/rss/maker/1.0.rb b/lib/rss/maker/1.0.rb
index 676f662915b..0d8075f836c 100644
--- a/lib/rss/maker/1.0.rb
+++ b/lib/rss/maker/1.0.rb
@@ -25,6 +25,7 @@ module RSS
end
class Channel < ChannelBase
+ include SetupDefaultLanguage
def to_feed(rss)
set_default_values do
diff --git a/lib/rss/maker/base.rb b/lib/rss/maker/base.rb
index 615088f8f79..6b42f11fcb1 100644
--- a/lib/rss/maker/base.rb
+++ b/lib/rss/maker/base.rb
@@ -372,6 +372,25 @@ module RSS
end
end
+ module SetupDefaultLanguage
+ private
+ def _set_default_values(&block)
+ keep = {
+ :dc_languages => dc_languages.to_a.dup,
+ }
+ _language = language
+ if _language and
+ !dc_languages.any? {|dc_language| dc_language.value == _language}
+ dc_language = self.class::DublinCoreLanguages::DublinCoreLanguage.new(self)
+ dc_language.value = _language.dup
+ dc_languages.unshift(dc_language)
+ end
+ super(&block)
+ ensure
+ dc_languages.replace(keep[:dc_languages])
+ end
+ end
+
class RSSBase < Base
class << self
def make(*args, &block)
diff --git a/lib/rss/maker/feed.rb b/lib/rss/maker/feed.rb
index 3a30ad42874..fa3a1771608 100644
--- a/lib/rss/maker/feed.rb
+++ b/lib/rss/maker/feed.rb
@@ -22,6 +22,8 @@ module RSS
end
class Channel < ChannelBase
+ include SetupDefaultLanguage
+
def to_feed(feed)
set_default_values do
setup_values(feed)
diff --git a/test/rss/test_maker_1.0.rb b/test/rss/test_maker_1.0.rb
index ab6f6ade6b2..47bfe99ba28 100644
--- a/test/rss/test_maker_1.0.rb
+++ b/test/rss/test_maker_1.0.rb
@@ -95,6 +95,26 @@ module RSS
assert_equal(rss.textinput.about, channel.textinput.resource)
end
+ def test_channel_language
+ about = "http://hoge.com"
+ title = "fugafuga"
+ link = "http://hoge.com"
+ description = "fugafugafugafuga"
+ language = "ja"
+
+ rss = RSS::Maker.make("1.0") do |maker|
+ maker.channel.about = about
+ maker.channel.title = title
+ maker.channel.link = link
+ maker.channel.description = description
+ maker.channel.language = language
+
+ setup_dummy_item(maker)
+ end
+ channel = rss.channel
+ assert_equal(language, channel.dc_language)
+ end
+
def test_not_valid_channel
about = "http://hoge.com"
title = "fugafuga"
diff --git a/test/rss/test_maker_atom_feed.rb b/test/rss/test_maker_atom_feed.rb
index 378cf9ac314..8b32189b9d2 100644
--- a/test/rss/test_maker_atom_feed.rb
+++ b/test/rss/test_maker_atom_feed.rb
@@ -392,5 +392,14 @@ module RSS
setup_dummy_item_atom(maker)
end
end
+
+ def test_language
+ language = "ja"
+ feed = Maker.make("atom") do |maker|
+ setup_dummy_channel_atom(maker)
+ maker.channel.language = "ja"
+ end
+ assert_equal(language, feed.dc_language)
+ end
end
end