mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/rss/maker/base.rb: changed xml-stylesheet's API of RSS Maker
to like item's one. * lib/rss/xml-stylesheet.rb (RSS::XMLStyleSheet#guess_type): fixed regular expression bug. * test/rss/test_maker_xml-stylesheet.rb: updated tests for xml-stylesheet. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7173 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
0aeea1ad38
commit
c2d8185ba6
4 changed files with 61 additions and 18 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
|||
Mon Nov 1 22:25:56 2004 Kouhei Sutou <kou@cozmixng.org>
|
||||
|
||||
* lib/rss/maker/base.rb: changed xml-stylesheet's API of RSS Maker
|
||||
like item's one.
|
||||
|
||||
* lib/rss/xml-stylesheet.rb (RSS::XMLStyleSheet#guess_type): fixed
|
||||
regular expression bug.
|
||||
|
||||
* test/rss/test_maker_xml-stylesheet.rb: updated tests for
|
||||
xml-stylesheet.
|
||||
|
||||
Mon Nov 1 13:59:28 2004 WATANABE Hirofumi <eban@ruby-lang.org>
|
||||
|
||||
* ext/extmk.rb (MANIFEST): do not use anymore, use extconf.rb instead.
|
||||
|
|
|
@ -143,7 +143,7 @@ module RSS
|
|||
end
|
||||
|
||||
def setup_xml_stylesheets(rss)
|
||||
rss.xml_stylesheets = @xml_stylesheets.normalize
|
||||
@xml_stylesheets.to_rss(rss)
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -153,22 +153,41 @@ module RSS
|
|||
|
||||
extend Forwardable
|
||||
|
||||
def_delegators(:@xml_stylesheets, :<<, :[], :[]=)
|
||||
def_delegators(:@xml_stylesheets, :<<, :[], :[]=, :first, :last)
|
||||
def_delegators(:@xml_stylesheets, :push, :pop, :shift, :unshift)
|
||||
|
||||
def initialize(maker)
|
||||
super
|
||||
@xml_stylesheets = []
|
||||
end
|
||||
|
||||
def normalize
|
||||
@xml_stylesheets.collect do |info|
|
||||
make_xml_stylesheet(info)
|
||||
|
||||
def to_rss(rss)
|
||||
@xml_stylesheets.each do |xss|
|
||||
xss.to_rss(rss)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def make_xml_stylesheet(info)
|
||||
RSS::XMLStyleSheet.new(*info)
|
||||
def new_xml_stylesheet
|
||||
xss = XMLStyleSheet.new(@maker)
|
||||
@xml_stylesheets << xss
|
||||
xss
|
||||
end
|
||||
|
||||
class XMLStyleSheet
|
||||
include Base
|
||||
|
||||
::RSS::XMLStyleSheet::ATTRIBUTES.each do |attribute|
|
||||
attr_accessor attribute
|
||||
add_need_initialize_variable(attribute)
|
||||
end
|
||||
|
||||
def to_rss(rss)
|
||||
xss = ::RSS::XMLStyleSheet.new
|
||||
set = setup_values(xss)
|
||||
if set
|
||||
rss.xml_stylesheets << xss
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ module RSS
|
|||
|
||||
private
|
||||
def guess_type(filename)
|
||||
/\.([^.]+)/ =~ filename
|
||||
/\.([^.]+)$/ =~ filename
|
||||
GUESS_TABLE[$1]
|
||||
end
|
||||
|
||||
|
|
|
@ -14,14 +14,13 @@ module RSS
|
|||
alternate = 'yes'
|
||||
|
||||
rss = RSS::Maker.make("1.0") do |maker|
|
||||
maker.xml_stylesheets << {
|
||||
:href => href,
|
||||
:type => type,
|
||||
:title => title,
|
||||
:media => media,
|
||||
:charset => charset,
|
||||
:alternate => alternate,
|
||||
}
|
||||
xss = maker.xml_stylesheets.new_xml_stylesheet
|
||||
xss.href = href
|
||||
xss.type = type
|
||||
xss.title = title
|
||||
xss.media = media
|
||||
xss.charset = charset
|
||||
xss.alternate = alternate
|
||||
|
||||
setup_dummy_channel(maker)
|
||||
end
|
||||
|
@ -33,6 +32,20 @@ module RSS
|
|||
assert_equal(media, xss.media)
|
||||
assert_equal(charset, xss.charset)
|
||||
assert_equal(alternate, xss.alternate)
|
||||
|
||||
|
||||
href = 'http://example.com/index.xsl'
|
||||
type = 'text/xsl'
|
||||
rss = RSS::Maker.make("1.0") do |maker|
|
||||
xss = maker.xml_stylesheets.new_xml_stylesheet
|
||||
xss.href = href
|
||||
|
||||
setup_dummy_channel(maker)
|
||||
end
|
||||
|
||||
xss = rss.xml_stylesheets.first
|
||||
assert_equal(href, xss.href)
|
||||
assert_equal(type, xss.type)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue