diff --git a/ChangeLog b/ChangeLog index e21ff1e8f1..840114a138 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,25 @@ +Thu Aug 11 13:01:48 2005 Kouhei Sutou + + * 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:38:50 2005 Yukihiro Matsumoto * bignum.c (rb_big_mul0): multiply two numbers (x, y) without diff --git a/lib/rss/1.0.rb b/lib/rss/1.0.rb index 0e0f8d9fd2..fb1629944b 100644 --- a/lib/rss/1.0.rb +++ b/lib/rss/1.0.rb @@ -279,7 +279,7 @@ module RSS end def setup_maker_attributes(channel) - channel.about = self.about + channel.about = about end class Image < Element diff --git a/lib/rss/maker/1.0.rb b/lib/rss/maker/1.0.rb index e38a2f89e0..3e6542a007 100644 --- a/lib/rss/maker/1.0.rb +++ b/lib/rss/maker/1.0.rb @@ -31,6 +31,7 @@ module RSS channel = RDF::Channel.new(@about) set = setup_values(channel) if set + channel.dc_dates.clear rss.channel = channel setup_items(rss) setup_image(rss) @@ -143,6 +144,7 @@ module RSS item = RDF::Item.new(@link) set = setup_values(item) if set + item.dc_dates.clear rss.items << item setup_other_elements(rss) end diff --git a/lib/rss/maker/base.rb b/lib/rss/maker/base.rb index 629f794b07..4972821cf1 100644 --- a/lib/rss/maker/base.rb +++ b/lib/rss/maker/base.rb @@ -52,7 +52,7 @@ module RSS def_delegators("@\#{name}", :<<, :[], :[]=, :first, :last) def_delegators("@\#{name}", :push, :pop, :shift, :unshift) - def_delegators("@\#{name}", :each) + def_delegators("@\#{name}", :each, :size) add_need_initialize_variable(name, "[]") end @@ -457,9 +457,9 @@ EOC alias_method(:pubDate=, :date=) def <=>(other) - if @date and other.date - @date <=> other.date - elsif @date + if date and other.date + date <=> other.date + elsif date 1 elsif other.date -1 diff --git a/lib/rss/maker/dublincore.rb b/lib/rss/maker/dublincore.rb index 1876ec36ce..29da1c39d9 100644 --- a/lib/rss/maker/dublincore.rb +++ b/lib/rss/maker/dublincore.rb @@ -103,10 +103,10 @@ EOC class ChannelBase include DublinCoreModel - remove_method(:dc_date) - remove_method(:dc_date=) - alias_method(:dc_date, :date) - alias_method(:dc_date=, :date=) + remove_method(:date) + remove_method(:date=) + alias_method(:date, :dc_date) + alias_method(:date=, :dc_date=) end class ImageBase; include DublinCoreModel; end @@ -114,10 +114,10 @@ EOC class ItemBase include DublinCoreModel - remove_method(:dc_date) - remove_method(:dc_date=) - alias_method(:dc_date, :date) - alias_method(:dc_date=, :date=) + remove_method(:date) + remove_method(:date=) + alias_method(:date, :dc_date) + alias_method(:date=, :dc_date=) end end class TextinputBase; include DublinCoreModel; end diff --git a/test/rss/test_setup_maker_1.0.rb b/test/rss/test_setup_maker_1.0.rb index 395e9b1ec9..244eee6114 100644 --- a/test/rss/test_setup_maker_1.0.rb +++ b/test/rss/test_setup_maker_1.0.rb @@ -225,7 +225,57 @@ module RSS assert_equal(@trackback_elems[:about][i], about.value) 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 def test_setup_maker