ruby-changes:48253
From: kou <ko1@a...>
Date: Mon, 23 Oct 2017 01:04:03 +0900 (JST)
Subject: [ruby-changes:48253] kou:r60367 (trunk): rss itunes: fix a bug that <itunes:explicit> value isn't fully supported
kou 2017-10-23 01:03:57 +0900 (Mon, 23 Oct 2017) New Revision: 60367 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=60367 Log: rss itunes: fix a bug that <itunes:explicit> value isn't fully supported Fix GH-1725 <itunes:explicit> accepts "explicit", "yes", "true", "clean", "no" and "false" as valid values. Here is the <itunes:explicit>'s description in https://help.apple.com/itc/podcasts_connect/#/itcb54353390: > The <itunes:explicit> tag indicates whether your podcast contains > explicit material. You can specify the following values: > > * Yes | Explicit | True. If you specify yes, explicit, or true, > indicating the presence of explicit content, the iTunes Store > displays an Explicit parental advisory graphic for your podcast. > > * Clean | No | False. If you specify clean, no, or false, indicating > that none of your podcast episodes contain explicit language or > adult content, the iTunes Store displays a Clean parental > advisory graphic for your podcast. I don't know whether <itunes:explicit> value is case sensitive or insensitive. But the current implementation is case insensitive. Reported by Valerie Woolard Srinivasan. Thanks!!! Modified files: trunk/lib/rss/itunes.rb trunk/lib/rss/maker/itunes.rb trunk/lib/rss/rss.rb trunk/lib/rss/utils.rb trunk/test/rss/test_itunes.rb trunk/test/rss/test_maker_itunes.rb Index: lib/rss/maker/itunes.rb =================================================================== --- lib/rss/maker/itunes.rb (revision 60366) +++ lib/rss/maker/itunes.rb (revision 60367) @@ -13,8 +13,8 @@ module RSS https://github.com/ruby/ruby/blob/trunk/lib/rss/maker/itunes.rb#L13 klass.def_other_element(full_name) when :yes_other def_yes_other_accessor(klass, full_name) - when :yes_clean_other - def_yes_clean_other_accessor(klass, full_name) + when :explicit_clean_other + def_explicit_clean_other_accessor(klass, full_name) when :csv def_csv_accessor(klass, full_name) when :element, :attribute @@ -43,11 +43,11 @@ module RSS https://github.com/ruby/ruby/blob/trunk/lib/rss/maker/itunes.rb#L43 EOC end - def def_yes_clean_other_accessor(klass, full_name) + def def_explicit_clean_other_accessor(klass, full_name) klass.def_other_element(full_name) klass.module_eval(<<-EOC, __FILE__, __LINE__ + 1) def #{full_name}? - Utils::YesCleanOther.parse(#{full_name}) + Utils::ExplicitCleanOther.parse(#{full_name}) end EOC end Index: lib/rss/utils.rb =================================================================== --- lib/rss/utils.rb (revision 60366) +++ lib/rss/utils.rb (revision 60367) @@ -125,16 +125,16 @@ module RSS https://github.com/ruby/ruby/blob/trunk/lib/rss/utils.rb#L125 [true, false].include?(args[0]) and args[1].is_a?(Hash) end - module YesCleanOther + module ExplicitCleanOther module_function def parse(value) if [true, false, nil].include?(value) value else case value.to_s - when /\Ayes\z/i + when /\Aexplicit|yes|true\z/i true - when /\Aclean\z/i + when /\Aclean|no|false\z/i false else nil Index: lib/rss/itunes.rb =================================================================== --- lib/rss/itunes.rb (revision 60366) +++ lib/rss/itunes.rb (revision 60367) @@ -51,7 +51,7 @@ module RSS https://github.com/ruby/ruby/blob/trunk/lib/rss/itunes.rb#L51 ELEMENT_INFOS = [["author"], ["block", :yes_other], - ["explicit", :yes_clean_other], + ["explicit", :explicit_clean_other], ["keywords", :csv], ["subtitle"], ["summary"]] Index: lib/rss/rss.rb =================================================================== --- lib/rss/rss.rb (revision 60366) +++ lib/rss/rss.rb (revision 60367) @@ -374,12 +374,12 @@ EOC https://github.com/ruby/ruby/blob/trunk/lib/rss/rss.rb#L374 end end - def yes_clean_other_attr_reader(*attrs) + def explicit_clean_other_attr_reader(*attrs) attrs.each do |attr| module_eval(<<-EOC, __FILE__, __LINE__ + 1) attr_reader(:#{attr}) def #{attr}? - YesCleanOther.parse(@#{attr}) + ExplicitCleanOther.parse(@#{attr}) end EOC end @@ -544,7 +544,7 @@ EOC https://github.com/ruby/ruby/blob/trunk/lib/rss/rss.rb#L544 EOC end - def yes_clean_other_writer(name, disp_name=name) + def explicit_clean_other_writer(name, disp_name=name) module_eval(<<-EOC, __FILE__, __LINE__ + 1) def #{name}=(value) value = (value ? "yes" : "no") if [true, false].include?(value) @@ -763,8 +763,8 @@ EOC https://github.com/ruby/ruby/blob/trunk/lib/rss/rss.rb#L763 text_type_writer name, disp_name when :content content_writer name, disp_name - when :yes_clean_other - yes_clean_other_writer name, disp_name + when :explicit_clean_other + explicit_clean_other_writer name, disp_name when :yes_other yes_other_writer name, disp_name when :csv @@ -782,8 +782,8 @@ EOC https://github.com/ruby/ruby/blob/trunk/lib/rss/rss.rb#L782 inherit_convert_attr_reader name when :uri uri_convert_attr_reader name - when :yes_clean_other - yes_clean_other_attr_reader name + when :explicit_clean_other + explicit_clean_other_attr_reader name when :yes_other yes_other_attr_reader name when :csv Index: test/rss/test_itunes.rb =================================================================== --- test/rss/test_itunes.rb (revision 60366) +++ test/rss/test_itunes.rb (revision 60367) @@ -224,9 +224,13 @@ module RSS https://github.com/ruby/ruby/blob/trunk/test/rss/test_itunes.rb#L224 def assert_itunes_explicit(readers, &rss20_maker) _wrap_assertion do + _assert_itunes_explicit(true, "explicit", readers, &rss20_maker) _assert_itunes_explicit(true, "yes", readers, &rss20_maker) + _assert_itunes_explicit(true, "true", readers, &rss20_maker) _assert_itunes_explicit(false, "clean", readers, &rss20_maker) - _assert_itunes_explicit(nil, "no", readers, &rss20_maker) + _assert_itunes_explicit(false, "no", readers, &rss20_maker) + _assert_itunes_explicit(false, "false", readers, &rss20_maker) + _assert_itunes_explicit(nil, "invalid", readers, &rss20_maker) end end Index: test/rss/test_maker_itunes.rb =================================================================== --- test/rss/test_maker_itunes.rb (revision 60366) +++ test/rss/test_maker_itunes.rb (revision 60367) @@ -279,10 +279,20 @@ module RSS https://github.com/ruby/ruby/blob/trunk/test/rss/test_maker_itunes.rb#L279 def assert_maker_itunes_explicit(maker_readers, feed_readers=nil) _wrap_assertion do feed_readers ||= maker_readers - _assert_maker_itunes_explicit(true, "yes", maker_readers, feed_readers) + _assert_maker_itunes_explicit(true, "explicit", + maker_readers, feed_readers) + _assert_maker_itunes_explicit(true, "yes", + maker_readers, feed_readers) + _assert_maker_itunes_explicit(true, "true", + maker_readers, feed_readers) _assert_maker_itunes_explicit(false, "clean", maker_readers, feed_readers) - _assert_maker_itunes_explicit(nil, "no", maker_readers, feed_readers) + _assert_maker_itunes_explicit(false, "no", + maker_readers, feed_readers) + _assert_maker_itunes_explicit(false, "false", + maker_readers, feed_readers) + _assert_maker_itunes_explicit(nil, "invalid", + maker_readers, feed_readers) end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/