mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/rss/rss.rb (RSS::Element#convert): added.
* lib/rss/rss.rb: convert -> need_convert. * lib/rss/1.0.rb: ditto. * lib/rss/0.9.rb: ditto. * lib/rss/2.0.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7863 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
ab2b03033a
commit
bd4fd26fda
6 changed files with 86 additions and 66 deletions
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
|||
Wed Feb 2 21:56:01 2005 Kouhei Sutou <kou@cozmixng.org>
|
||||
|
||||
* lib/rss/rss.rb (RSS::Element#convert): added.
|
||||
|
||||
* lib/rss/rss.rb: convert -> need_convert.
|
||||
|
||||
* lib/rss/1.0.rb: ditto.
|
||||
|
||||
* lib/rss/0.9.rb: ditto.
|
||||
|
||||
* lib/rss/2.0.rb: ditto.
|
||||
|
||||
Wed Feb 2 03:30:58 2005 Minero Aoki <aamine@loveruby.net>
|
||||
|
||||
* ext/ripper/lib/ripper/tokenizer.rb -> lexer.rb.
|
||||
|
|
|
@ -59,14 +59,14 @@ module RSS
|
|||
end
|
||||
end
|
||||
|
||||
def to_s(convert=true, indent=calc_indent)
|
||||
def to_s(need_convert=true, indent=calc_indent)
|
||||
rv = tag(indent, ns_declarations) do |next_indent|
|
||||
[
|
||||
channel_element(false, next_indent),
|
||||
other_element(false, next_indent),
|
||||
]
|
||||
end
|
||||
rv = @converter.convert(rv) if convert and @converter
|
||||
rv = convert(rv) if need_convert
|
||||
rv
|
||||
end
|
||||
|
||||
|
@ -142,7 +142,7 @@ module RSS
|
|||
super()
|
||||
end
|
||||
|
||||
def to_s(convert=true, indent=calc_indent)
|
||||
def to_s(need_convert=true, indent=calc_indent)
|
||||
rv = tag(indent) do |next_indent|
|
||||
[
|
||||
title_element(false, next_indent),
|
||||
|
@ -165,7 +165,7 @@ module RSS
|
|||
other_element(false, next_indent),
|
||||
]
|
||||
end
|
||||
rv = @converter.convert(rv) if convert and @converter
|
||||
rv = convert(rv) if need_convert
|
||||
rv
|
||||
end
|
||||
|
||||
|
@ -233,13 +233,13 @@ module RSS
|
|||
install_model(x, occurs)
|
||||
end
|
||||
|
||||
def to_s(convert=true, indent=calc_indent)
|
||||
def to_s(need_convert=true, indent=calc_indent)
|
||||
rv = tag(indent) do |next_indent|
|
||||
[
|
||||
day_elements(false, next_indent)
|
||||
]
|
||||
end
|
||||
rv = @converter.convert(rv) if convert and @converter
|
||||
rv = convert(rv) if need_convert
|
||||
rv
|
||||
end
|
||||
|
||||
|
@ -278,13 +278,13 @@ module RSS
|
|||
install_model(x, occurs)
|
||||
end
|
||||
|
||||
def to_s(convert=true, indent=calc_indent)
|
||||
def to_s(need_convert=true, indent=calc_indent)
|
||||
rv = tag(indent) do |next_indent|
|
||||
[
|
||||
hour_elements(false, next_indent)
|
||||
]
|
||||
end
|
||||
rv = @converter.convert(rv) if convert and @converter
|
||||
rv = convert(rv) if need_convert
|
||||
rv
|
||||
end
|
||||
|
||||
|
@ -331,7 +331,7 @@ module RSS
|
|||
install_model(x, "?")
|
||||
end
|
||||
|
||||
def to_s(convert=true, indent=calc_indent)
|
||||
def to_s(need_convert=true, indent=calc_indent)
|
||||
rv = tag(indent) do |next_indent|
|
||||
[
|
||||
url_element(false, next_indent),
|
||||
|
@ -343,8 +343,8 @@ module RSS
|
|||
other_element(false, next_indent),
|
||||
]
|
||||
end
|
||||
rv = @converter.convert(rv) if convert and @converter
|
||||
rv
|
||||
rv = convert(rv) if need_convert
|
||||
rv
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -384,10 +384,10 @@ module RSS
|
|||
@protocol = protocol
|
||||
end
|
||||
|
||||
def to_s(convert=true, indent=calc_indent)
|
||||
def to_s(need_convert=true, indent=calc_indent)
|
||||
rv = tag(indent)
|
||||
rv = @converter.convert(rv) if convert and @converter
|
||||
rv
|
||||
rv = convert(rv) if need_convert
|
||||
rv
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -428,7 +428,7 @@ module RSS
|
|||
install_model(tag, occurs)
|
||||
end
|
||||
|
||||
def to_s(convert=true, indent=calc_indent)
|
||||
def to_s(need_convert=true, indent=calc_indent)
|
||||
rv = tag(indent) do |next_indent|
|
||||
[
|
||||
title_element(false, next_indent),
|
||||
|
@ -440,8 +440,8 @@ module RSS
|
|||
other_element(false, next_indent),
|
||||
]
|
||||
end
|
||||
rv = @converter.convert(rv) if convert and @converter
|
||||
rv
|
||||
rv = convert(rv) if need_convert
|
||||
rv
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -533,9 +533,9 @@ module RSS
|
|||
@type = type
|
||||
end
|
||||
|
||||
def to_s(convert=true, indent=calc_indent)
|
||||
def to_s(need_convert=true, indent=calc_indent)
|
||||
rv = tag(indent)
|
||||
rv = @converter.convert(rv) if convert and @converter
|
||||
rv = convert(rv) if need_convert
|
||||
rv
|
||||
end
|
||||
|
||||
|
@ -606,7 +606,7 @@ module RSS
|
|||
install_model(x, nil)
|
||||
end
|
||||
|
||||
def to_s(convert=true, indent=calc_indent)
|
||||
def to_s(need_convert=true, indent=calc_indent)
|
||||
rv = tag(indent) do |next_indent|
|
||||
[
|
||||
title_element(false, next_indent),
|
||||
|
@ -616,8 +616,8 @@ module RSS
|
|||
other_element(false, next_indent),
|
||||
]
|
||||
end
|
||||
rv = @converter.convert(rv) if convert and @converter
|
||||
rv
|
||||
rv = convert(rv) if need_convert
|
||||
rv
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -60,7 +60,7 @@ module RSS
|
|||
tag_name_with_prefix(PREFIX)
|
||||
end
|
||||
|
||||
def to_s(convert=true, indent=calc_indent)
|
||||
def to_s(need_convert=true, indent=calc_indent)
|
||||
rv = tag(indent, ns_declarations) do |next_indent|
|
||||
[
|
||||
channel_element(false, next_indent),
|
||||
|
@ -70,7 +70,7 @@ module RSS
|
|||
other_element(false, next_indent),
|
||||
]
|
||||
end
|
||||
rv = @converter.convert(rv) if convert and @converter
|
||||
rv = convert(rv) if need_convert
|
||||
rv
|
||||
end
|
||||
|
||||
|
@ -118,11 +118,11 @@ module RSS
|
|||
@li = li
|
||||
end
|
||||
|
||||
def to_s(convert=true, indent=calc_indent)
|
||||
def to_s(need_convert=true, indent=calc_indent)
|
||||
tag(indent) do |next_indent|
|
||||
[
|
||||
li_elements(convert, next_indent),
|
||||
other_element(convert, next_indent),
|
||||
li_elements(need_convert, next_indent),
|
||||
other_element(need_convert, next_indent),
|
||||
]
|
||||
end
|
||||
end
|
||||
|
@ -177,9 +177,9 @@ module RSS
|
|||
tag_name_with_prefix(PREFIX)
|
||||
end
|
||||
|
||||
def to_s(convert=true, indent=calc_indent)
|
||||
def to_s(need_convert=true, indent=calc_indent)
|
||||
rv = tag(indent)
|
||||
rv = @converter.convert(rv) if convert and @converter
|
||||
rv = convert(rv) if need_convert
|
||||
rv
|
||||
end
|
||||
|
||||
|
@ -204,7 +204,7 @@ module RSS
|
|||
|
||||
end
|
||||
|
||||
[
|
||||
[
|
||||
["about", URI, true]
|
||||
].each do |name, uri, required|
|
||||
install_get_attribute(name, uri, required)
|
||||
|
@ -234,7 +234,7 @@ module RSS
|
|||
@about = about
|
||||
end
|
||||
|
||||
def to_s(convert=true, indent=calc_indent)
|
||||
def to_s(need_convert=true, indent=calc_indent)
|
||||
rv = tag(indent) do |next_indent|
|
||||
[
|
||||
title_element(false, next_indent),
|
||||
|
@ -246,8 +246,8 @@ module RSS
|
|||
other_element(false, next_indent),
|
||||
]
|
||||
end
|
||||
rv = @converter.convert(rv) if convert and @converter
|
||||
rv
|
||||
rv = convert(rv) if need_convert
|
||||
rv
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -305,9 +305,9 @@ module RSS
|
|||
@resource = resource
|
||||
end
|
||||
|
||||
def to_s(convert=true, indent=calc_indent)
|
||||
def to_s(need_convert=true, indent=calc_indent)
|
||||
rv = tag(indent)
|
||||
rv = @converter.convert(rv) if convert and @converter
|
||||
rv = convert(rv) if need_convert
|
||||
rv
|
||||
end
|
||||
|
||||
|
@ -342,9 +342,9 @@ module RSS
|
|||
@resource = resource
|
||||
end
|
||||
|
||||
def to_s(convert=true, indent=calc_indent)
|
||||
def to_s(need_convert=true, indent=calc_indent)
|
||||
rv = tag(indent)
|
||||
rv = @converter.convert(rv) if convert and @converter
|
||||
rv = convert(rv) if need_convert
|
||||
rv
|
||||
end
|
||||
|
||||
|
@ -384,11 +384,11 @@ module RSS
|
|||
@Seq = seq
|
||||
end
|
||||
|
||||
def to_s(convert=true, indent=calc_indent)
|
||||
def to_s(need_convert=true, indent=calc_indent)
|
||||
rv = tag(indent) do |next_indent|
|
||||
[
|
||||
Seq_element(convert, next_indent),
|
||||
other_element(convert, next_indent),
|
||||
Seq_element(need_convert, next_indent),
|
||||
other_element(need_convert, next_indent),
|
||||
]
|
||||
end
|
||||
end
|
||||
|
@ -448,7 +448,7 @@ module RSS
|
|||
@about = about
|
||||
end
|
||||
|
||||
def to_s(convert=true, indent=calc_indent)
|
||||
def to_s(need_convert=true, indent=calc_indent)
|
||||
rv = tag(indent) do |next_indent|
|
||||
[
|
||||
title_element(false, next_indent),
|
||||
|
@ -457,7 +457,7 @@ module RSS
|
|||
other_element(false, next_indent),
|
||||
]
|
||||
end
|
||||
rv = @converter.convert(rv) if convert and @converter
|
||||
rv = convert(rv) if need_convert
|
||||
rv
|
||||
end
|
||||
|
||||
|
@ -518,7 +518,7 @@ module RSS
|
|||
@about = about
|
||||
end
|
||||
|
||||
def to_s(convert=true, indent=calc_indent)
|
||||
def to_s(need_convert=true, indent=calc_indent)
|
||||
rv = tag(indent) do |next_indent|
|
||||
[
|
||||
title_element(false, next_indent),
|
||||
|
@ -527,7 +527,7 @@ module RSS
|
|||
other_element(false, next_indent),
|
||||
]
|
||||
end
|
||||
rv = @converter.convert(rv) if convert and @converter
|
||||
rv = convert(rv) if need_convert
|
||||
rv
|
||||
end
|
||||
|
||||
|
@ -589,7 +589,7 @@ module RSS
|
|||
@about = about
|
||||
end
|
||||
|
||||
def to_s(convert=true, indent=calc_indent)
|
||||
def to_s(need_convert=true, indent=calc_indent)
|
||||
rv = tag(indent) do |next_indent|
|
||||
[
|
||||
title_element(false, next_indent),
|
||||
|
@ -599,7 +599,7 @@ module RSS
|
|||
other_element(false, next_indent),
|
||||
]
|
||||
end
|
||||
rv = @converter.convert(rv) if convert and @converter
|
||||
rv = convert(rv) if need_convert
|
||||
rv
|
||||
end
|
||||
|
||||
|
|
|
@ -30,11 +30,11 @@ module RSS
|
|||
install_model(x, occurs)
|
||||
end
|
||||
|
||||
def other_element(convert, indent)
|
||||
def other_element(need_convert, indent)
|
||||
rv = <<-EOT
|
||||
#{category_elements(convert, indent)}
|
||||
#{generator_element(convert, indent)}
|
||||
#{ttl_element(convert, indent)}
|
||||
#{category_elements(need_convert, indent)}
|
||||
#{generator_element(need_convert, indent)}
|
||||
#{ttl_element(need_convert, indent)}
|
||||
EOT
|
||||
rv << super
|
||||
end
|
||||
|
@ -86,7 +86,7 @@ EOT
|
|||
install_model(x, occurs)
|
||||
end
|
||||
|
||||
def other_element(convert, indent)
|
||||
def other_element(need_convert, indent)
|
||||
rv = [
|
||||
super,
|
||||
*%w(author comments pubDate guid).collect do |name|
|
||||
|
|
|
@ -164,7 +164,7 @@ module RSS
|
|||
install_element(name) do |n, elem_name|
|
||||
<<-EOC
|
||||
if @#{n}
|
||||
"\#{@#{n}.to_s(convert, indent)}"
|
||||
"\#{@#{n}.to_s(need_convert, indent)}"
|
||||
else
|
||||
''
|
||||
end
|
||||
|
@ -183,7 +183,7 @@ EOC
|
|||
<<-EOC
|
||||
rv = []
|
||||
@#{n}.each do |x|
|
||||
value = "\#{x.to_s(convert, indent)}"
|
||||
value = "\#{x.to_s(need_convert, indent)}"
|
||||
rv << value if /\\A\\s*\\z/ !~ value
|
||||
end
|
||||
rv.join("\n")
|
||||
|
@ -202,8 +202,8 @@ EOC
|
|||
if @#{n}
|
||||
rv = "\#{indent}<#{elem_name}>"
|
||||
value = html_escape(@#{n})
|
||||
if convert and @converter
|
||||
rv << @converter.convert(value)
|
||||
if need_convert
|
||||
rv << convert(value)
|
||||
else
|
||||
rv << value
|
||||
end
|
||||
|
@ -260,8 +260,8 @@ EOC
|
|||
if @#{n}
|
||||
rv = "\#{indent}<#{elem_name}>"
|
||||
value = html_escape(@#{n}.#{type})
|
||||
if convert and @converter
|
||||
rv << @converter.convert(value)
|
||||
if need_convert
|
||||
rv << convert(value)
|
||||
else
|
||||
rv << value
|
||||
end
|
||||
|
@ -279,7 +279,7 @@ EOC
|
|||
def install_element(name, postfix="")
|
||||
elem_name = name.sub('_', ':')
|
||||
module_eval(<<-EOC, *get_file_and_line_from_caller(2))
|
||||
def #{name}_element#{postfix}(convert=true, indent='')
|
||||
def #{name}_element#{postfix}(need_convert=true, indent='')
|
||||
#{yield(name, elem_name)}
|
||||
end
|
||||
private :#{name}_element#{postfix}
|
||||
|
@ -332,12 +332,12 @@ EOC
|
|||
|
||||
def def_content_only_to_s
|
||||
module_eval(<<-EOC, *get_file_and_line_from_caller(2))
|
||||
def to_s(convert=true, indent=calc_indent)
|
||||
def to_s(need_convert=true, indent=calc_indent)
|
||||
if @content
|
||||
rv = tag(indent) do |next_indent|
|
||||
h(@content)
|
||||
end
|
||||
rv = @converter.convert(rv) if convert and @converter
|
||||
rv = convert(rv) if need_convert
|
||||
rv
|
||||
else
|
||||
""
|
||||
|
@ -515,6 +515,14 @@ EOC
|
|||
child.converter = converter unless child.nil?
|
||||
end
|
||||
end
|
||||
|
||||
def convert(value)
|
||||
if @converter
|
||||
@converter.convert(value)
|
||||
else
|
||||
value
|
||||
end
|
||||
end
|
||||
|
||||
def validate
|
||||
validate_attribute
|
||||
|
@ -692,12 +700,12 @@ EOC
|
|||
end
|
||||
end
|
||||
|
||||
def other_element(convert, indent='')
|
||||
def other_element(need_convert, indent='')
|
||||
rv = []
|
||||
private_methods.each do |meth|
|
||||
if /\A([^_]+)_[^_]+_elements?\z/ =~ meth and
|
||||
self.class::NSPOOL.has_key?($1)
|
||||
res = __send__(meth, convert)
|
||||
res = __send__(meth, need_convert)
|
||||
rv << "#{indent}#{res}" if /\A\s*\z/ !~ res
|
||||
end
|
||||
end
|
||||
|
|
|
@ -146,9 +146,9 @@ module RSS
|
|||
tag_name_with_prefix(TRACKBACK_PREFIX)
|
||||
end
|
||||
|
||||
def to_s(convert=true, indent=calc_indent)
|
||||
def to_s(need_convert=true, indent=calc_indent)
|
||||
rv = tag(indent)
|
||||
rv = @converter.convert(rv) if convert and @converter
|
||||
rv = convert(rv) if need_convert
|
||||
rv
|
||||
end
|
||||
|
||||
|
@ -194,9 +194,9 @@ module RSS
|
|||
tag_name_with_prefix(TRACKBACK_PREFIX)
|
||||
end
|
||||
|
||||
def to_s(convert=true, indent=calc_indent)
|
||||
def to_s(need_convert=true, indent=calc_indent)
|
||||
rv = tag(indent)
|
||||
rv = @converter.convert(rv) if convert and @converter
|
||||
rv = convert(rv) if need_convert
|
||||
rv
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue