mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/rss/rss.rb (RSS::VERSION): 0.1.1 -> 0.1.2
* lib/rss/rss.rb: #item=/#set_item and so on are obsolete. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7458 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
5262bd8a2c
commit
636e37fcb9
4 changed files with 40 additions and 8 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
Sat Dec 4 18:49:09 2004 Kouhei Sutou <kou@cozmixng.org>
|
||||||
|
|
||||||
|
* lib/rss/rss.rb (RSS::VERSION): 0.1.1 -> 0.1.2
|
||||||
|
|
||||||
|
* lib/rss/rss.rb: #item=/#set_item and so on are obsolete.
|
||||||
|
|
||||||
Sat Dec 4 14:28:56 2004 Dave Thomas <dave@pragprog.com>
|
Sat Dec 4 14:28:56 2004 Dave Thomas <dave@pragprog.com>
|
||||||
|
|
||||||
* lib/rdoc/code_objects.rb (RDoc::Context::Section::set_comment):
|
* lib/rdoc/code_objects.rb (RDoc::Context::Section::set_comment):
|
||||||
|
|
|
@ -59,7 +59,7 @@ module RSS
|
||||||
category = Rss::Channel::Category.new
|
category = Rss::Channel::Category.new
|
||||||
set = setup_values(category)
|
set = setup_values(category)
|
||||||
if set
|
if set
|
||||||
channel.category = category
|
channel.categories << category
|
||||||
setup_other_elements(rss)
|
setup_other_elements(rss)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -145,7 +145,7 @@ module RSS
|
||||||
category = Rss::Channel::Item::Category.new
|
category = Rss::Channel::Item::Category.new
|
||||||
set = setup_values(category)
|
set = setup_values(category)
|
||||||
if set
|
if set
|
||||||
item.category = category
|
item.categories << category
|
||||||
setup_other_elements(rss)
|
setup_other_elements(rss)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -364,10 +364,9 @@ module RSS
|
||||||
previous = @last_element
|
previous = @last_element
|
||||||
next_element = klass.send(:new, *args)
|
next_element = klass.send(:new, *args)
|
||||||
next_element.do_validate = @do_validate
|
next_element.do_validate = @do_validate
|
||||||
setter = ""
|
prefix = ""
|
||||||
setter << "#{klass.required_prefix}_" if klass.required_prefix
|
prefix << "#{klass.required_prefix}_" if klass.required_prefix
|
||||||
setter << "#{tag_name}="
|
previous.__send__(:set_next_element, prefix, tag_name, next_element)
|
||||||
@last_element.send(setter, next_element)
|
|
||||||
@last_element = next_element
|
@last_element = next_element
|
||||||
@proc_stack.push Proc.new { |text, tags|
|
@proc_stack.push Proc.new { |text, tags|
|
||||||
p(@last_element.class) if DEBUG
|
p(@last_element.class) if DEBUG
|
||||||
|
|
|
@ -58,7 +58,7 @@ require "rss/xml-stylesheet"
|
||||||
|
|
||||||
module RSS
|
module RSS
|
||||||
|
|
||||||
VERSION = "0.1.1"
|
VERSION = "0.1.2"
|
||||||
|
|
||||||
URI = "http://purl.org/rss/1.0/"
|
URI = "http://purl.org/rss/1.0/"
|
||||||
|
|
||||||
|
@ -176,6 +176,7 @@ EOC
|
||||||
def install_have_children_element(name, plural_name=nil)
|
def install_have_children_element(name, plural_name=nil)
|
||||||
plural_name ||= "#{name}s"
|
plural_name ||= "#{name}s"
|
||||||
add_have_children_element(name, plural_name)
|
add_have_children_element(name, plural_name)
|
||||||
|
add_plural_form(name, plural_name)
|
||||||
|
|
||||||
def_children_accessor(name, plural_name)
|
def_children_accessor(name, plural_name)
|
||||||
install_element(name, "s") do |n, elem_name|
|
install_element(name, "s") do |n, elem_name|
|
||||||
|
@ -314,6 +315,10 @@ EOC
|
||||||
end
|
end
|
||||||
|
|
||||||
def #{accessor_name}=(*args)
|
def #{accessor_name}=(*args)
|
||||||
|
warn("Warning:\#{caller.first.sub(/:in `.*'\z/, '')}: " \
|
||||||
|
"Don't use `#{accessor_name} = XXX'/`set_#{accessor_name}(XXX)'. " \
|
||||||
|
"Those APIs are not sense of Ruby. " \
|
||||||
|
"Use `#{plural_name} << XXX' instead of them.")
|
||||||
if args.size == 1
|
if args.size == 1
|
||||||
@#{accessor_name}.push(args[0])
|
@#{accessor_name}.push(args[0])
|
||||||
else
|
else
|
||||||
|
@ -428,6 +433,16 @@ EOC
|
||||||
@@need_initialize_variables
|
@@need_initialize_variables
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@@plural_forms = {}
|
||||||
|
|
||||||
|
def self.add_plural_form(singular, plural)
|
||||||
|
@@plural_forms[singular] = plural
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.plural_forms
|
||||||
|
@@plural_forms
|
||||||
|
end
|
||||||
|
|
||||||
EOC
|
EOC
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -605,6 +620,18 @@ EOC
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def set_next_element(prefix, tag_name, next_element)
|
||||||
|
klass = next_element.class
|
||||||
|
prefix = ""
|
||||||
|
prefix << "#{klass.required_prefix}_" if klass.required_prefix
|
||||||
|
if self.class.plural_forms.has_key?(tag_name)
|
||||||
|
ary = __send__("#{prefix}#{self.class.plural_forms[tag_name]}")
|
||||||
|
ary << next_element
|
||||||
|
else
|
||||||
|
__send__("#{prefix}#{tag_name}=", next_element)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# not String class children.
|
# not String class children.
|
||||||
def children
|
def children
|
||||||
[]
|
[]
|
||||||
|
|
Loading…
Reference in a new issue