mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/rss/1.0.rb (RSS::RDF::Channel#setup_maker_attributes):
removed self. * lib/rss/maker/base.rb (RSS::Maker::ItemsBase#<=>): use #date instead of @date. (RSS::Maker::Base::self.def_array_element): added #size. * lib/rss/maker/1.0.rb (RSS::Maker::RSS10::Channel#to_rss, RSS::Maker::RSS10::Items::Item#to_rss): cleared dc_dates set upped by using #date. * lib/rss/maker/dublincore.rb (RSS::Maker::ChannelBase, RSS::Maker::ItemsBase::ItemBase): fixed opposite alias. * test/rss/test_setup_maker_1.0.rb (RSS::TestSetupMaker10::test_setup_maker_items_sort): added some tests for RSS::Maker::ItemsBase#do_sort. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@8966 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
29c1d98017
commit
2bafec23f0
6 changed files with 87 additions and 13 deletions
22
ChangeLog
22
ChangeLog
|
@ -1,3 +1,25 @@
|
||||||
|
Thu Aug 11 13:01:48 2005 Kouhei Sutou <kou@cozmixng.org>
|
||||||
|
|
||||||
|
* lib/rss/1.0.rb (RSS::RDF::Channel#setup_maker_attributes):
|
||||||
|
removed self.
|
||||||
|
|
||||||
|
* lib/rss/maker/base.rb (RSS::Maker::ItemsBase#<=>): use #date
|
||||||
|
instead of @date.
|
||||||
|
(RSS::Maker::Base::self.def_array_element): added #size.
|
||||||
|
|
||||||
|
* lib/rss/maker/1.0.rb
|
||||||
|
(RSS::Maker::RSS10::Channel#to_rss,
|
||||||
|
RSS::Maker::RSS10::Items::Item#to_rss): cleared dc_dates set
|
||||||
|
upped by using #date.
|
||||||
|
|
||||||
|
* lib/rss/maker/dublincore.rb
|
||||||
|
(RSS::Maker::ChannelBase, RSS::Maker::ItemsBase::ItemBase):
|
||||||
|
fixed opposite alias.
|
||||||
|
|
||||||
|
* test/rss/test_setup_maker_1.0.rb
|
||||||
|
(RSS::TestSetupMaker10::test_setup_maker_items_sort): added some
|
||||||
|
tests for RSS::Maker::ItemsBase#do_sort.
|
||||||
|
|
||||||
Wed Aug 10 10:29:40 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
|
Wed Aug 10 10:29:40 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
|
||||||
|
|
||||||
* ext/tk/lib/tk.rb: fix bug on handling __ruby2val_optkeys().
|
* ext/tk/lib/tk.rb: fix bug on handling __ruby2val_optkeys().
|
||||||
|
|
|
@ -279,7 +279,7 @@ module RSS
|
||||||
end
|
end
|
||||||
|
|
||||||
def setup_maker_attributes(channel)
|
def setup_maker_attributes(channel)
|
||||||
channel.about = self.about
|
channel.about = about
|
||||||
end
|
end
|
||||||
|
|
||||||
class Image < Element
|
class Image < Element
|
||||||
|
|
|
@ -31,6 +31,7 @@ module RSS
|
||||||
channel = RDF::Channel.new(@about)
|
channel = RDF::Channel.new(@about)
|
||||||
set = setup_values(channel)
|
set = setup_values(channel)
|
||||||
if set
|
if set
|
||||||
|
channel.dc_dates.clear
|
||||||
rss.channel = channel
|
rss.channel = channel
|
||||||
setup_items(rss)
|
setup_items(rss)
|
||||||
setup_image(rss)
|
setup_image(rss)
|
||||||
|
@ -143,6 +144,7 @@ module RSS
|
||||||
item = RDF::Item.new(@link)
|
item = RDF::Item.new(@link)
|
||||||
set = setup_values(item)
|
set = setup_values(item)
|
||||||
if set
|
if set
|
||||||
|
item.dc_dates.clear
|
||||||
rss.items << item
|
rss.items << item
|
||||||
setup_other_elements(rss)
|
setup_other_elements(rss)
|
||||||
end
|
end
|
||||||
|
|
|
@ -52,7 +52,7 @@ module RSS
|
||||||
|
|
||||||
def_delegators("@\#{name}", :<<, :[], :[]=, :first, :last)
|
def_delegators("@\#{name}", :<<, :[], :[]=, :first, :last)
|
||||||
def_delegators("@\#{name}", :push, :pop, :shift, :unshift)
|
def_delegators("@\#{name}", :push, :pop, :shift, :unshift)
|
||||||
def_delegators("@\#{name}", :each)
|
def_delegators("@\#{name}", :each, :size)
|
||||||
|
|
||||||
add_need_initialize_variable(name, "[]")
|
add_need_initialize_variable(name, "[]")
|
||||||
end
|
end
|
||||||
|
@ -457,9 +457,9 @@ EOC
|
||||||
alias_method(:pubDate=, :date=)
|
alias_method(:pubDate=, :date=)
|
||||||
|
|
||||||
def <=>(other)
|
def <=>(other)
|
||||||
if @date and other.date
|
if date and other.date
|
||||||
@date <=> other.date
|
date <=> other.date
|
||||||
elsif @date
|
elsif date
|
||||||
1
|
1
|
||||||
elsif other.date
|
elsif other.date
|
||||||
-1
|
-1
|
||||||
|
|
|
@ -103,10 +103,10 @@ EOC
|
||||||
class ChannelBase
|
class ChannelBase
|
||||||
include DublinCoreModel
|
include DublinCoreModel
|
||||||
|
|
||||||
remove_method(:dc_date)
|
remove_method(:date)
|
||||||
remove_method(:dc_date=)
|
remove_method(:date=)
|
||||||
alias_method(:dc_date, :date)
|
alias_method(:date, :dc_date)
|
||||||
alias_method(:dc_date=, :date=)
|
alias_method(:date=, :dc_date=)
|
||||||
end
|
end
|
||||||
|
|
||||||
class ImageBase; include DublinCoreModel; end
|
class ImageBase; include DublinCoreModel; end
|
||||||
|
@ -114,10 +114,10 @@ EOC
|
||||||
class ItemBase
|
class ItemBase
|
||||||
include DublinCoreModel
|
include DublinCoreModel
|
||||||
|
|
||||||
remove_method(:dc_date)
|
remove_method(:date)
|
||||||
remove_method(:dc_date=)
|
remove_method(:date=)
|
||||||
alias_method(:dc_date, :date)
|
alias_method(:date, :dc_date)
|
||||||
alias_method(:dc_date=, :date=)
|
alias_method(:date=, :dc_date=)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
class TextinputBase; include DublinCoreModel; end
|
class TextinputBase; include DublinCoreModel; end
|
||||||
|
|
|
@ -225,7 +225,57 @@ module RSS
|
||||||
assert_equal(@trackback_elems[:about][i], about.value)
|
assert_equal(@trackback_elems[:about][i], about.value)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_setup_maker_items_sort
|
||||||
|
title = "TITLE"
|
||||||
|
link = "http://hoge.com/"
|
||||||
|
description = "text hoge fuga"
|
||||||
|
item_size = 5
|
||||||
|
|
||||||
|
|
||||||
|
rss = RSS::Maker.make("1.0") do |maker|
|
||||||
|
setup_dummy_channel(maker)
|
||||||
|
|
||||||
|
item_size.times do |i|
|
||||||
|
item = RSS::RDF::Item.new("#{link}#{i}")
|
||||||
|
item.title = "#{title}#{i}"
|
||||||
|
item.link = "#{link}#{i}"
|
||||||
|
item.description = "#{description}#{i}"
|
||||||
|
item.dc_date = Time.now + i * 60
|
||||||
|
item.setup_maker(maker)
|
||||||
|
end
|
||||||
|
maker.items.do_sort = false
|
||||||
|
end
|
||||||
|
assert_equal(item_size, rss.items.size)
|
||||||
|
rss.items.each_with_index do |item, i|
|
||||||
|
assert_equal("#{link}#{i}", item.about)
|
||||||
|
assert_equal("#{title}#{i}", item.title)
|
||||||
|
assert_equal("#{link}#{i}", item.link)
|
||||||
|
assert_equal("#{description}#{i}", item.description)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
rss = RSS::Maker.make("1.0") do |maker|
|
||||||
|
setup_dummy_channel(maker)
|
||||||
|
|
||||||
|
item_size.times do |i|
|
||||||
|
item = RSS::RDF::Item.new("#{link}#{i}")
|
||||||
|
item.title = "#{title}#{i}"
|
||||||
|
item.link = "#{link}#{i}"
|
||||||
|
item.description = "#{description}#{i}"
|
||||||
|
item.dc_date = Time.now + i * 60
|
||||||
|
item.setup_maker(maker)
|
||||||
|
end
|
||||||
|
maker.items.do_sort = true
|
||||||
|
end
|
||||||
|
assert_equal(item_size, rss.items.size)
|
||||||
|
rss.items.reverse.each_with_index do |item, i|
|
||||||
|
assert_equal("#{link}#{i}", item.about)
|
||||||
|
assert_equal("#{title}#{i}", item.title)
|
||||||
|
assert_equal("#{link}#{i}", item.link)
|
||||||
|
assert_equal("#{description}#{i}", item.description)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_setup_maker
|
def test_setup_maker
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue