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

* 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.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23445 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
kou 2009-05-16 09:01:18 +00:00
parent 28e7beb54c
commit 277f48de57
6 changed files with 58 additions and 0 deletions

View file

@ -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

View file

@ -25,6 +25,7 @@ module RSS
end
class Channel < ChannelBase
include SetupDefaultLanguage
def to_feed(rss)
set_default_values do

View file

@ -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)

View file

@ -22,6 +22,8 @@ module RSS
end
class Channel < ChannelBase
include SetupDefaultLanguage
def to_feed(feed)
set_default_values do
setup_values(feed)

View file

@ -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"

View file

@ -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