aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-01-25 06:35:04 +0000
committerkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-01-25 06:35:04 +0000
commitcee0c36a0890dd44efacf4ea0d37872fb3e903c6 (patch)
tree932c2a99d9e585af73b00edb3fdc6ed8ea057026 /lib
parent6375c68f8851e1e0fee8a95afba91c4555097127 (diff)
downloadruby-cee0c36a0890dd44efacf4ea0d37872fb3e903c6.tar.gz
Upgrade RSS to 0.2.8
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66920 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/rss.rb2
-rw-r--r--lib/rss/itunes.rb36
-rw-r--r--lib/rss/maker/0.9.rb2
-rw-r--r--lib/rss/rss.gemspec70
-rw-r--r--lib/rss/rss.rb4
-rw-r--r--lib/rss/version.rb4
6 files changed, 87 insertions, 31 deletions
diff --git a/lib/rss.rb b/lib/rss.rb
index 1c7d72b9f7..1438d97bd3 100644
--- a/lib/rss.rb
+++ b/lib/rss.rb
@@ -77,6 +77,8 @@
module RSS
end
+require "rss/version"
+
require 'rss/1.0'
require 'rss/2.0'
require 'rss/atom'
diff --git a/lib/rss/itunes.rb b/lib/rss/itunes.rb
index 987b090f21..bc3e25448a 100644
--- a/lib/rss/itunes.rb
+++ b/lib/rss/itunes.rb
@@ -277,34 +277,46 @@ module RSS
def parse(duration, do_validate=true)
if do_validate and /\A(?:
\d?\d:[0-5]\d:[0-5]\d|
- [0-5]?\d:[0-5]\d
+ [0-5]?\d:[0-5]\d|
+ \d+
)\z/x !~ duration
raise ArgumentError,
- "must be one of HH:MM:SS, H:MM:SS, MM::SS, M:SS: " +
+ "must be one of HH:MM:SS, H:MM:SS, MM:SS, M:SS, S+: " +
duration.inspect
end
- components = duration.split(':')
- components[3..-1] = nil if components.size > 3
+ if duration.include?(':')
+ components = duration.split(':')
+ components[3..-1] = nil if components.size > 3
- components.unshift("00") until components.size == 3
-
- components.collect do |component|
- component.to_i
+ components.unshift("00") until components.size == 3
+ components.collect do |component|
+ component.to_i
+ end
+ else
+ seconds_to_components(duration.to_i)
end
end
- def construct(hour, minute, second)
- components = [minute, second]
+ def construct(hours, minutes, seconds)
+ components = [minutes, seconds]
if components.include?(nil)
nil
else
- components.unshift(hour) if hour and hour > 0
+ components.unshift(hours) if hours and hours > 0
components.collect do |component|
"%02d" % component
- end.join(":")
+ end.join(':')
end
end
+
+ private
+ def seconds_to_components(total_seconds)
+ hours = total_seconds / (60 * 60)
+ minutes = (total_seconds / 60) % 60
+ seconds = total_seconds % 60
+ [hours, minutes, seconds]
+ end
end
content_setup
diff --git a/lib/rss/maker/0.9.rb b/lib/rss/maker/0.9.rb
index 7f961b392e..eb35fc14e1 100644
--- a/lib/rss/maker/0.9.rb
+++ b/lib/rss/maker/0.9.rb
@@ -278,7 +278,7 @@ module RSS
vars = super
if @maker.feed_version == "0.91"
vars << "title" unless title {|t| t.have_required_values?}
- vars << "link" unless link {|l| l.have_required_values?}
+ vars << "link" unless link
end
vars
end
diff --git a/lib/rss/rss.gemspec b/lib/rss/rss.gemspec
index 669c6c1ad4..04f2b2f42d 100644
--- a/lib/rss/rss.gemspec
+++ b/lib/rss/rss.gemspec
@@ -1,8 +1,8 @@
begin
- require_relative "lib/rss"
+ require_relative "lib/rss/version"
rescue LoadError
# for Ruby core repository
- require_relative "rss"
+ require_relative "version"
end
Gem::Specification.new do |spec|
@@ -16,18 +16,60 @@ Gem::Specification.new do |spec|
spec.homepage = "https://github.com/ruby/rss"
spec.license = "BSD-2-Clause"
- spec.files = [".gitignore", ".travis.yml", "Gemfile", "LICENSE.txt", "README.md", "Rakefile",
- "bin/console", "bin/setup", "lib/rss.rb", "lib/rss/0.9.rb", "lib/rss/1.0.rb", "lib/rss/2.0.rb",
- "lib/rss/atom.rb", "lib/rss/content.rb", "lib/rss/content/1.0.rb", "lib/rss/content/2.0.rb",
- "lib/rss/converter.rb", "lib/rss/dublincore.rb", "lib/rss/dublincore/1.0.rb", "lib/rss/dublincore/2.0.rb",
- "lib/rss/dublincore/atom.rb", "lib/rss/image.rb", "lib/rss/itunes.rb", "lib/rss/maker.rb",
- "lib/rss/maker/0.9.rb", "lib/rss/maker/1.0.rb", "lib/rss/maker/2.0.rb", "lib/rss/maker/atom.rb",
- "lib/rss/maker/base.rb", "lib/rss/maker/content.rb", "lib/rss/maker/dublincore.rb", "lib/rss/maker/entry.rb",
- "lib/rss/maker/feed.rb", "lib/rss/maker/image.rb", "lib/rss/maker/itunes.rb", "lib/rss/maker/slash.rb",
- "lib/rss/maker/syndication.rb", "lib/rss/maker/taxonomy.rb", "lib/rss/maker/trackback.rb",
- "lib/rss/parser.rb", "lib/rss/rexmlparser.rb", "lib/rss/rss.rb", "lib/rss/slash.rb", "lib/rss/syndication.rb",
- "lib/rss/taxonomy.rb", "lib/rss/trackback.rb", "lib/rss/utils.rb", "lib/rss/xml-stylesheet.rb",
- "lib/rss/xml.rb", "lib/rss/xmlparser.rb", "lib/rss/xmlscanner.rb", "rss.gemspec"]
+ spec.files = [
+ ".gitignore",
+ ".travis.yml",
+ "Gemfile",
+ "LICENSE.txt",
+ "NEWS.md",
+ "README.md",
+ "Rakefile",
+ "lib/rss.rb",
+ "lib/rss/0.9.rb",
+ "lib/rss/1.0.rb",
+ "lib/rss/2.0.rb",
+ "lib/rss/atom.rb",
+ "lib/rss/content.rb",
+ "lib/rss/content/1.0.rb",
+ "lib/rss/content/2.0.rb",
+ "lib/rss/converter.rb",
+ "lib/rss/dublincore.rb",
+ "lib/rss/dublincore/1.0.rb",
+ "lib/rss/dublincore/2.0.rb",
+ "lib/rss/dublincore/atom.rb",
+ "lib/rss/image.rb",
+ "lib/rss/itunes.rb",
+ "lib/rss/maker.rb",
+ "lib/rss/maker/0.9.rb",
+ "lib/rss/maker/1.0.rb",
+ "lib/rss/maker/2.0.rb",
+ "lib/rss/maker/atom.rb",
+ "lib/rss/maker/base.rb",
+ "lib/rss/maker/content.rb",
+ "lib/rss/maker/dublincore.rb",
+ "lib/rss/maker/entry.rb",
+ "lib/rss/maker/feed.rb",
+ "lib/rss/maker/image.rb",
+ "lib/rss/maker/itunes.rb",
+ "lib/rss/maker/slash.rb",
+ "lib/rss/maker/syndication.rb",
+ "lib/rss/maker/taxonomy.rb",
+ "lib/rss/maker/trackback.rb",
+ "lib/rss/parser.rb",
+ "lib/rss/rexmlparser.rb",
+ "lib/rss/rss.rb",
+ "lib/rss/slash.rb",
+ "lib/rss/syndication.rb",
+ "lib/rss/taxonomy.rb",
+ "lib/rss/trackback.rb",
+ "lib/rss/utils.rb",
+ "lib/rss/version.rb",
+ "lib/rss/xml-stylesheet.rb",
+ "lib/rss/xml.rb",
+ "lib/rss/xmlparser.rb",
+ "lib/rss/xmlscanner.rb",
+ "rss.gemspec",
+ ]
spec.bindir = "exe"
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]
diff --git a/lib/rss/rss.rb b/lib/rss/rss.rb
index daaf6793b9..daa0837e9c 100644
--- a/lib/rss/rss.rb
+++ b/lib/rss/rss.rb
@@ -68,10 +68,6 @@ require_relative "converter"
require_relative "xml-stylesheet"
module RSS
-
- # The current version of RSS
- VERSION = "0.2.7"
-
# The URI of the RSS 1.0 specification
URI = "http://purl.org/rss/1.0/"
diff --git a/lib/rss/version.rb b/lib/rss/version.rb
new file mode 100644
index 0000000000..f0a8894e79
--- /dev/null
+++ b/lib/rss/version.rb
@@ -0,0 +1,4 @@
+module RSS
+ # The current version of RSS
+ VERSION = "0.2.8"
+end