1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib/rss/2.0.rb, lib/rss/content.rb, lib/rss/dublincore.rb,

lib/rss/rss.rb, lib/rss/syndication.rb: removed warnings.

* lib/rss/converter.rb: removed handling load error of nkf.

* test/rss/test_syndication.rb, test/rss/test_trackback.rb,
  test/rss/test_dublincore.rb, test/rss/test_content.rb: replaced
	'require "rss/parser"' by 'require "rss/1.0"'.

* test/rss/test_parser.rb, test/rss/test_accessor.rb: removed
  'require "rss/parser"'.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5619 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
kou 2004-02-03 14:01:42 +00:00
parent 7376af3092
commit 1a235738a8
13 changed files with 94 additions and 59 deletions

View file

@ -1,3 +1,17 @@
Tue Feb 3 22:36:25 2004 Kouhei Sutou <kou@cozmixng.org>
* lib/rss/2.0.rb, lib/rss/content.rb, lib/rss/dublincore.rb,
lib/rss/rss.rb, lib/rss/syndication.rb: removed warnings.
* lib/rss/converter.rb: removed handling load error of nkf.
* test/rss/test_syndication.rb, test/rss/test_trackback.rb,
test/rss/test_dublincore.rb, test/rss/test_content.rb: replaced
'require "rss/parser"' by 'require "rss/1.0"'.
* test/rss/test_parser.rb, test/rss/test_accessor.rb: removed
'require "rss/parser"'.
Tue Feb 3 11:23:17 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* parse.y (reduce_nodes): remove tail returns. [ruby-talk:90934]

View file

@ -129,6 +129,7 @@ EOT
module ListenerMixin
private
alias start_rss09 start_rss
def start_rss(tag_name, prefix, attrs, ns)
check_ns(tag_name, prefix, ns, Rss::URI)

View file

@ -13,9 +13,13 @@ module RSS
ELEMENTS = []
%w(encoded).each do |x|
install_text_element("#{CONTENT_PREFIX}_#{x}")
end
def self.included(mod)
mod.module_eval(<<-EOC)
%w(encoded).each do |x|
install_text_element("\#{CONTENT_PREFIX}_\#{x}")
end
EOC
end
def content_validate(tags)
counter = {}
@ -38,6 +42,7 @@ module RSS
end
prefix_size = CONTENT_PREFIX.size + 1
ContentModel::ELEMENTS.uniq!
ContentModel::ELEMENTS.each do |x|
BaseListener.install_get_text_element(x[prefix_size..-1], CONTENT_URI, "#{x}=")
end

View file

@ -111,44 +111,28 @@ EOC
end
def def_to_euc_jp_from_shift_jis
begin
require "nkf"
rescue LoadError
raise UnknownConversionMethodError.new('EUC-JP', 'Shift_JIS')
end
require "nkf"
def_convert do |value|
"NKF.nkf('-Se', #{value})"
end
end
def def_to_shift_jis_from_euc_jp
begin
require "nkf"
rescue LoadError
raise UnknownConversionMethodError.new('Shift_JIS', 'EUC-JP')
end
require "nkf"
def_convert do |value|
"NKF.nkf('-Es', #{value})"
end
end
def def_to_euc_jp_from_iso_2022_jp
begin
require "nkf"
rescue LoadError
raise UnknownConversionMethodError.new('EUC-JP', 'ISO-2022-JP')
end
require "nkf"
def_convert do |value|
"NKF.nkf('-Je', #{value})"
end
end
def def_to_iso_2022_jp_from_euc_jp
begin
require "nkf"
rescue LoadError
raise UnknownConversionMethodError.new('ISO-2022-JP', 'EUC-JP')
end
require "nkf"
def_convert do |value|
"NKF.nkf('-Ej', #{value})"
end

View file

@ -13,14 +13,18 @@ module RSS
ELEMENTS = []
%w(title description creator subject publisher
contributor type format identifier source
language relation coverage rights).each do |x|
install_text_element("#{DC_PREFIX}_#{x}")
end
def self.included(mod)
mod.module_eval(<<-EOC)
%w(title description creator subject publisher
contributor type format identifier source
language relation coverage rights).each do |x|
install_text_element("\#{DC_PREFIX}_\#{x}")
end
%w(date).each do |x|
install_date_element("#{DC_PREFIX}_#{x}", 'iso8601', x)
%w(date).each do |x|
install_date_element("\#{DC_PREFIX}_\#{x}", 'iso8601', x)
end
EOC
end
def dc_validate(tags)
@ -47,6 +51,7 @@ module RSS
end
prefix_size = DC_PREFIX.size + 1
DublincoreModel::ELEMENTS.uniq!
DublincoreModel::ELEMENTS.each do |x|
BaseListener.install_get_text_element(x[prefix_size..-1], DC_URI, "#{x}=")
end

View file

@ -92,6 +92,8 @@ module RSS
include Utils
def install_have_child_element(name)
add_need_initialize_variable(name)
attr_accessor name
install_element(name) do |n, elem_name|
<<-EOC
@ -106,8 +108,9 @@ EOC
alias_method(:install_have_attribute_element, :install_have_child_element)
def install_have_children_element(name, postfix="s")
def_children_accessor(name, postfix)
add_have_children_element(name)
def_children_accessor(name, postfix)
install_element(name, postfix) do |n, elem_name|
<<-EOC
rv = ''
@ -121,6 +124,8 @@ EOC
def install_text_element(name)
self::ELEMENTS << name
add_need_initialize_variable(name)
attr_writer name
convert_attr_reader name
install_element(name) do |n, elem_name|
@ -144,6 +149,7 @@ EOC
def install_date_element(name, type, disp_name=name)
self::ELEMENTS << name
add_need_initialize_variable(name)
# accessor
convert_attr_reader name
@ -323,6 +329,16 @@ EOC
@@have_children_elements << variable_name
end
@@need_initialize_variables = []
def self.add_need_initialize_variable(variable_name)
@@need_initialize_variables << variable_name
end
def self.need_initialize_variables
@@need_initialize_variables
end
EOC
end
@ -346,8 +362,9 @@ EOC
attr_accessor :do_validate
def initialize(do_validate=true)
@converter = nil
@do_validate = do_validate
initialize_have_children_elements
initialize_variables
end
def tag_name
@ -371,6 +388,13 @@ EOC
end
private
def initialize_variables
self.class.need_initialize_variables.each do |variable_name|
instance_eval("@#{variable_name} = nil")
end
initialize_have_children_elements
end
def initialize_have_children_elements
self.class.have_children_elements.each do |variable_name|
instance_eval("@#{variable_name} = []")

View file

@ -13,13 +13,31 @@ module RSS
ELEMENTS = []
%w(updatePeriod updateFrequency).each do |x|
install_text_element("#{SY_PREFIX}_#{x}")
end
def self.included(mod)
mod.module_eval(<<-EOC)
%w(updatePeriod updateFrequency).each do |x|
install_text_element("\#{SY_PREFIX}_\#{x}")
end
%w(updateBase).each do |x|
install_date_element("#{SY_PREFIX}_#{x}", 'iso8601', x)
end
%w(updateBase).each do |x|
install_date_element("\#{SY_PREFIX}_\#{x}", 'iso8601', x)
end
alias_method(:_sy_updatePeriod=, :sy_updatePeriod=)
def sy_updatePeriod=(new_value)
new_value = new_value.strip
validate_sy_updatePeriod(new_value) if @do_validate
self._sy_updatePeriod = new_value
end
alias_method(:_sy_updateFrequency=, :sy_updateFrequency=)
def sy_updateFrequency=(new_value)
new_value = new_value.strip
validate_sy_updateFrequency(new_value) if @do_validate
self._sy_updateFrequency = new_value.to_i
end
EOC
end
def sy_validate(tags)
counter = {}
@ -35,21 +53,6 @@ module RSS
end
end
alias_method(:_sy_updatePeriod=, :sy_updatePeriod=)
def sy_updatePeriod=(new_value)
new_value = new_value.strip
validate_sy_updatePeriod(new_value) if @do_validate
self._sy_updatePeriod = new_value
end
alias_method(:_sy_updateFrequency=, :sy_updateFrequency=)
def sy_updateFrequency=(new_value)
new_value = new_value.strip
validate_sy_updateFrequency(new_value) if @do_validate
self._sy_updateFrequency = new_value.to_i
end
private
SY_UPDATEPERIOD_AVAILABLE_VALUES = %w(hourly daily weekly monthly yearly)
def validate_sy_updatePeriod(value)
@ -72,6 +75,7 @@ module RSS
end
prefix_size = SY_PREFIX.size + 1
SyndicationModel::ELEMENTS.uniq!
SyndicationModel::ELEMENTS.each do |x|
BaseListener.install_get_text_element(x[prefix_size..-1], SY_URI, "#{x}=")
end

View file

@ -1,7 +1,6 @@
# -*- tab-width: 2 -*- vim: ts=2
require "test/unit"
require "rss/parser"
require "rss/1.0"
require "rss/2.0"
require "common"

View file

@ -4,7 +4,7 @@ require "test/unit"
require "cgi-lib"
require "rexml/document"
require "rss/parser"
require "rss/1.0"
require "rss/content"
require "common"

View file

@ -4,7 +4,7 @@ require "test/unit"
require "cgi-lib"
require "rexml/document"
require "rss/parser"
require "rss/1.0"
require "rss/dublincore"
require "common"

View file

@ -1,7 +1,6 @@
# -*- tab-width: 2 -*- vim: ts=2
require "test/unit"
require "rss/parser"
require "rss/1.0"
require "common"

View file

@ -4,7 +4,7 @@ require "test/unit"
require "cgi-lib"
require "rexml/document"
require "rss/parser"
require "rss/1.0"
require "rss/syndication"
require "common"

View file

@ -4,7 +4,7 @@ require "test/unit"
require "cgi-lib"
require "rexml/document"
require "rss/parser"
require "rss/1.0"
require "rss/trackback"
require "common"