feedjira-podcast 0.9.14 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cb6cd379a0d36a4311fc8d511d49562e4575cee0
4
- data.tar.gz: db188b0638b4b4b015cd45657d11677df58d8695
3
+ metadata.gz: ac3a1196fabb335ea51d62168ec80797768ded8e
4
+ data.tar.gz: cd06b8dc8e1b5a06752980de182a65affb400c31
5
5
  SHA512:
6
- metadata.gz: 0afae3d893d59de6f375fe63d31479ee47f65c062ef464a122b28ab0e345c65252e3bf9364ed1eb996c970b732219bdae540f86a886e7a200be9a64d02cf3215
7
- data.tar.gz: 3e5803e5f0e887840d484879406856c524ae89ba4603c82fda873112571cb79f0cc612d5512302dcd043bbeb7414a849554b42365ff9c5f1f9862e4672e98480
6
+ metadata.gz: ab3d078680dad24ebb13cf6922d99ad5fd2a1d9bde94edda4bd49afb9809a774665ee2459e2cc8903731eccc80e674364380f7234b0652cef09220e79a08cdc1
7
+ data.tar.gz: 3acc7dbabdfff90416ca56aa1ec7e880541598f77223fc543e31972230a0c89a94eb48c53b4bb70cf308b83a83a7e3f57159a7ca813b4025833709ee06230900
data/README.md CHANGED
@@ -46,7 +46,7 @@ In nearly all cases the value types of podcast feed data is predictable. As such
46
46
 
47
47
  Date values are parsed as `Time` objects, number values become `Float` objects, hrefs, URIs and URLs are parsed using [Addressable](https://github.com/sporkmonger/addressable), and boolean values will return `true` or `false`.
48
48
 
49
- In the case of the `<itunes:explicit>` tag, there are three mutually exclusive options, `"yes"`, `"clean"`, and any other value (representing `"no"`). This element gets expanded to two properties through parsing, `explicit?` and `clean?`, allowing both to be simple boolean values.
49
+ In 2016 the definition of the `<itunes:explicit>` tag changed, but it still gets expanded into two properties when parsed: `explicit?` and `clean?`. Unlike previously, where both being false would indicate `"no"` (rather than `"yes"` or `"clean"`), now both properties being false means the tag is not included (or it is being use incorrectly). When present, and given a proper value, `explicit?` and `clean?` will be accurate according to the Podcasts Connect guidelines. If you choose to, you can refer only to `explicit?` to test the value, but when it is false there is no guarantee `<itunes:explicit>` was actually set to `clean`, `no`, or `false`; you would have to also check `clean?` to be sure.
50
50
 
51
51
  The spec for the item `<guid>` indicates that the default value if no value is given for the `isPermaLink` attribute is `true`. It also states that when `isPermaLink` is true, the value of `<guid>` represents a URI (and that the client can choose to treat it that way or not). As such, whenever a `<guid>` is acting as a `permaLink`, whether implicitly or explicitly, the `guid` value will return an `Addressable::URI`. Only if `isPermaLink` has a value of `"false"` with `guid` return a string.
52
52
 
@@ -4,19 +4,39 @@ module Feedjira
4
4
  include SAXMachine
5
5
  include FeedUtilities
6
6
 
7
- include ::Feedjira::Podcast::Channel::Required
8
- include ::Feedjira::Podcast::Channel::Optional
9
- include ::Feedjira::Podcast::Channel::Atom
10
- include ::Feedjira::Podcast::Channel::Feedburner
11
- include ::Feedjira::Podcast::Channel::Apple
7
+ include ::Feedjira::Podcast::XML::Required
12
8
 
13
- elements :item, as: :items, class: PodcastItem
9
+ # def parse(xml_input, on_error = nil, on_warning = nil)
10
+ # # TODO This is fragile
11
+ # @namespaces = {}
12
+ # Nokogiri::XML(xml_input).xpath("//namespace::*").each do |ns|
13
+ # @namespaces[ns.href] = ns.prefix
14
+ # end
15
+ #
16
+ # super xml_input
17
+ # end
14
18
 
15
19
  def self.able_to_parse?(xml)
16
- # TODO Look several something podcast-specific matches, especially
20
+ # TODO Look for any of several podcast-specific matches, especially
17
21
  # to cover feeds that may not have any items yet
18
22
  (/\<rss|\<rdf/ =~ xml) && (/enclosure/ =~ xml)
19
23
  end
24
+
25
+ def method_missing(method_sym, *arguments, &block)
26
+ if rss && rss.channel && rss.channel.respond_to?(method_sym)
27
+ rss.channel.send(method_sym, *arguments, &block)
28
+ else
29
+ super
30
+ end
31
+ end
32
+
33
+ def self.respond_to_missing?(method_sym, include_private = false)
34
+ if rss && rss.channel && rss.channel.respond_to?(method_sym)
35
+ true
36
+ else
37
+ super
38
+ end
39
+ end
20
40
  end
21
41
  end
22
42
  end
@@ -3,6 +3,15 @@ require "addressable/uri"
3
3
 
4
4
  require "feedjira/podcast/version"
5
5
 
6
+ require "feedjira/podcast/item/guid"
7
+ require "feedjira/podcast/item/source"
8
+
9
+ require "feedjira/podcast/item/required"
10
+ require "feedjira/podcast/item/optional"
11
+ require "feedjira/podcast/item/apple"
12
+ require "feedjira/podcast/item/dublin"
13
+ require "feedjira/podcast/item/content"
14
+
6
15
  require "feedjira/podcast/channel/cloud"
7
16
  require "feedjira/podcast/channel/image"
8
17
  require "feedjira/podcast/channel/skip_hours"
@@ -18,17 +27,14 @@ require "feedjira/podcast/channel/atom"
18
27
  require "feedjira/podcast/channel/feedburner"
19
28
  require "feedjira/podcast/channel/apple"
20
29
  require "feedjira/podcast/channel/syndication"
30
+ require "feedjira/podcast/channel/item"
21
31
 
22
- require "feedjira/podcast/item/guid"
23
- require "feedjira/podcast/item/source"
32
+ require "feedjira/podcast/rss/channel"
33
+ require "feedjira/podcast/rss/required"
24
34
 
25
- require "feedjira/podcast/item/required"
26
- require "feedjira/podcast/item/optional"
27
- require "feedjira/podcast/item/apple"
28
- require "feedjira/podcast/item/dublin"
29
- require "feedjira/podcast/item/content"
35
+ require "feedjira/podcast/xml/rss"
36
+ require "feedjira/podcast/xml/required"
30
37
 
31
- require "feedjira/parser/podcast_item"
32
38
  require "feedjira/parser/podcast"
33
39
 
34
40
  Feedjira::Feed.add_feed_class(Feedjira::Parser::Podcast)
@@ -52,11 +52,11 @@ module Feedjira
52
52
  end
53
53
 
54
54
  def itunes_explicit
55
- @itunes_explicit ||= (_itunes_explicit == "yes")
55
+ @itunes_explicit ||= ["yes", "explicit", "true"].include?(_itunes_explicit)
56
56
  end
57
57
 
58
58
  def itunes_clean
59
- @itunes_clean ||= (_itunes_explicit == "clean")
59
+ @itunes_clean ||= ["no", "clean", "false"].include?(_itunes_explicit)
60
60
  end
61
61
 
62
62
  def itunes_owner
@@ -70,30 +70,32 @@ module Feedjira
70
70
  def self.included(base)
71
71
  base.include(InstanceMethods)
72
72
 
73
- base.element :"itunes:author", as: :itunes_author
73
+ itunes_xml_ns = "itunes"
74
74
 
75
- base.element :"itunes:block", as: :_itunes_block
75
+ base.element :"#{itunes_xml_ns}:author", as: :itunes_author
76
76
 
77
- base.elements :"itunes:category", as: :_itunes_categories, class: AppleCategory
77
+ base.element :"#{itunes_xml_ns}:block", as: :_itunes_block
78
78
 
79
- base.element :"itunes:image", as: :itunes_image_href, value: :href do |href|
79
+ base.elements :"#{itunes_xml_ns}:category", as: :_itunes_categories, class: AppleCategory
80
+
81
+ base.element :"#{itunes_xml_ns}:image", as: :itunes_image_href, value: :href do |href|
80
82
  Addressable::URI.parse(href.strip)
81
83
  end
82
84
 
83
- base.element :"itunes:explicit", as: :_itunes_explicit
84
- base.element :"itunes:complete", as: :_itunes_complete
85
+ base.element :"#{itunes_xml_ns}:explicit", as: :_itunes_explicit
86
+ base.element :"#{itunes_xml_ns}:complete", as: :_itunes_complete
85
87
 
86
- base.element :"itunes:new_feed_url", as: :itunes_new_feed_url do |url|
88
+ base.element :"#{itunes_xml_ns}:new_feed_url", as: :itunes_new_feed_url do |url|
87
89
  Addressable::URI.parse(url.strip)
88
90
  end
89
91
 
90
- base.element :"itunes:owner", as: :_itunes_owner, class: AppleOwner
91
- base.element :"itunes:subtitle", as: :itunes_subtitle
92
- base.element :"itunes:summary", as: :itunes_summary
92
+ base.element :"#{itunes_xml_ns}:owner", as: :_itunes_owner, class: AppleOwner
93
+ base.element :"#{itunes_xml_ns}:subtitle", as: :itunes_subtitle
94
+ base.element :"#{itunes_xml_ns}:summary", as: :itunes_summary
93
95
 
94
96
  # Legacy support
95
97
 
96
- base.element :"itunes:keywords", as: :itunes_keywords, default: "" do |keywords|
98
+ base.element :"#{itunes_xml_ns}:keywords", as: :itunes_keywords, default: "" do |keywords|
97
99
  keywords.split(",").map(&:strip).select { |k| !k.empty? }
98
100
  end
99
101
  end
@@ -12,7 +12,9 @@ module Feedjira
12
12
  def self.included(base)
13
13
  base.include(InstanceMethods)
14
14
 
15
- base.element :"feedburner:info", as: :feedburner_info_uri, value: :uri do |uri|
15
+ feedburner_xml_ns = "feedburner"
16
+
17
+ base.element :"#{feedburner_xml_ns}:info", as: :feedburner_info_uri, value: :uri do |uri|
16
18
  Addressable::URI.parse(uri.strip)
17
19
  end
18
20
  end
@@ -0,0 +1,16 @@
1
+ module Feedjira
2
+ module Podcast
3
+ module Channel
4
+ class Item
5
+ include SAXMachine
6
+ include FeedUtilities
7
+
8
+ include ::Feedjira::Podcast::Item::Required
9
+ include ::Feedjira::Podcast::Item::Optional
10
+ include ::Feedjira::Podcast::Item::Apple
11
+ include ::Feedjira::Podcast::Item::Dublin
12
+ include ::Feedjira::Podcast::Item::Content
13
+ end
14
+ end
15
+ end
16
+ end
@@ -46,42 +46,44 @@ module Feedjira
46
46
  end
47
47
 
48
48
  def itunes_explicit
49
- @itunes_explicit ||= (_itunes_explicit == "yes")
49
+ @itunes_explicit ||= ["yes", "explicit", "true"].include?(_itunes_explicit)
50
50
  end
51
51
 
52
52
  def itunes_clean
53
- @itunes_clean ||= (_itunes_explicit == "clean")
53
+ @itunes_clean ||= ["no", "clean", "false"].include?(_itunes_explicit)
54
54
  end
55
55
  end
56
56
 
57
57
  def self.included(base)
58
58
  base.include(InstanceMethods)
59
59
 
60
- base.element :"itunes:author", as: :itunes_author
61
- base.element :"itunes:block", as: :_itunes_block
60
+ itunes_xml_ns = "itunes"
62
61
 
63
- base.element :"itunes:image", as: :itunes_image_href, value: :href do |href|
62
+ base.element :"#{itunes_xml_ns}:author", as: :itunes_author
63
+ base.element :"#{itunes_xml_ns}:block", as: :_itunes_block
64
+
65
+ base.element :"#{itunes_xml_ns}:image", as: :itunes_image_href, value: :href do |href|
64
66
  Addressable::URI.parse(href.strip)
65
67
  end
66
68
 
67
- base.element :"itunes:duration", as: :itunes_duration do |d|
69
+ base.element :"#{itunes_xml_ns}:duration", as: :itunes_duration do |d|
68
70
  ["0:0:0:#{d}".split(":")[-3, 3].map(&:to_i)].inject(0) do |_m, i|
69
71
  (i[0] * 3600) + (i[1] * 60) + i[2]
70
72
  end
71
73
  end
72
74
 
73
- base.element :"itunes:explicit", as: :_itunes_explicit
75
+ base.element :"#{itunes_xml_ns}:explicit", as: :_itunes_explicit
74
76
 
75
- base.element :"itunes:isClosedCaptioned", as: :_itunes_is_closed_captioned
77
+ base.element :"#{itunes_xml_ns}:isClosedCaptioned", as: :_itunes_is_closed_captioned
76
78
 
77
- base.element :"itunes:order", as: :itunes_order, &:to_f
79
+ base.element :"#{itunes_xml_ns}:order", as: :itunes_order, &:to_f
78
80
 
79
- base.element :"itunes:subtitle", as: :itunes_subtitle
80
- base.element :"itunes:summary", as: :itunes_summary
81
+ base.element :"#{itunes_xml_ns}:subtitle", as: :itunes_subtitle
82
+ base.element :"#{itunes_xml_ns}:summary", as: :itunes_summary
81
83
 
82
84
  # Legacy support
83
85
 
84
- base.element :"itunes:keywords", as: :itunes_keywords do |keywords|
86
+ base.element :"#{itunes_xml_ns}:keywords", as: :itunes_keywords do |keywords|
85
87
  keywords.split(",").map(&:strip).select { |k| !k.empty? }
86
88
  end
87
89
  end
@@ -11,7 +11,9 @@ module Feedjira
11
11
  def self.included(base)
12
12
  base.include(InstanceMethods)
13
13
 
14
- base.element :"content:encoded", as: :content_encoded
14
+ content_xml_ns = "content"
15
+
16
+ base.element :"#{content_xml_ns}:encoded", as: :content_encoded
15
17
  end
16
18
  end
17
19
  end
@@ -13,7 +13,9 @@ module Feedjira
13
13
  def self.included(base)
14
14
  base.include(InstanceMethods)
15
15
 
16
- base.element :"dc:creator", as: :dc_creator
16
+ dc_xml_ns = "dc"
17
+
18
+ base.element :"#{dc_xml_ns}:creator", as: :dc_creator
17
19
  end
18
20
  end
19
21
  end
@@ -0,0 +1,20 @@
1
+ module Feedjira
2
+ module Podcast
3
+ module RSS
4
+ class Channel
5
+ include SAXMachine
6
+ include FeedUtilities
7
+
8
+ include ::Feedjira::Podcast::Channel::Required
9
+ include ::Feedjira::Podcast::Channel::Optional
10
+ include ::Feedjira::Podcast::Channel::Atom
11
+ include ::Feedjira::Podcast::Channel::Feedburner
12
+ include ::Feedjira::Podcast::Channel::Apple
13
+
14
+ elements :item, as: :items, class: ::Feedjira::Podcast::Channel::Item
15
+
16
+ ancestor :rss
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,14 @@
1
+ module Feedjira
2
+ module Podcast
3
+ module RSS
4
+ module Required
5
+ def self.included(base)
6
+ base.element :channel, class: Channel
7
+ base.attribute :version
8
+
9
+ base.ancestor :xml
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -1,5 +1,5 @@
1
1
  module Feedjira
2
2
  module Podcast
3
- VERSION = "0.9.14"
3
+ VERSION = "0.10.0"
4
4
  end
5
5
  end
@@ -0,0 +1,11 @@
1
+ module Feedjira
2
+ module Podcast
3
+ module XML
4
+ module Required
5
+ def self.included(base)
6
+ base.element :rss, class: RSS
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,12 @@
1
+ module Feedjira
2
+ module Podcast
3
+ module XML
4
+ class RSS
5
+ include SAXMachine
6
+ include FeedUtilities
7
+
8
+ include ::Feedjira::Podcast::RSS::Required
9
+ end
10
+ end
11
+ end
12
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: feedjira-podcast
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.14
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Kalafarski
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-01-14 00:00:00.000000000 Z
11
+ date: 2016-04-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -128,7 +128,6 @@ files:
128
128
  - bin/setup
129
129
  - feedjira-podcast.gemspec
130
130
  - lib/feedjira/parser/podcast.rb
131
- - lib/feedjira/parser/podcast_item.rb
132
131
  - lib/feedjira/podcast.rb
133
132
  - lib/feedjira/podcast/channel/apple.rb
134
133
  - lib/feedjira/podcast/channel/apple_category.rb
@@ -138,6 +137,7 @@ files:
138
137
  - lib/feedjira/podcast/channel/cloud.rb
139
138
  - lib/feedjira/podcast/channel/feedburner.rb
140
139
  - lib/feedjira/podcast/channel/image.rb
140
+ - lib/feedjira/podcast/channel/item.rb
141
141
  - lib/feedjira/podcast/channel/optional.rb
142
142
  - lib/feedjira/podcast/channel/required.rb
143
143
  - lib/feedjira/podcast/channel/skip_days.rb
@@ -152,8 +152,12 @@ files:
152
152
  - lib/feedjira/podcast/item/optional.rb
153
153
  - lib/feedjira/podcast/item/required.rb
154
154
  - lib/feedjira/podcast/item/source.rb
155
+ - lib/feedjira/podcast/rss/channel.rb
156
+ - lib/feedjira/podcast/rss/required.rb
155
157
  - lib/feedjira/podcast/version.rb
156
158
  - lib/feedjira/podcast/warning.rb
159
+ - lib/feedjira/podcast/xml/required.rb
160
+ - lib/feedjira/podcast/xml/rss.rb
157
161
  homepage: https://github.com/scour/feedjira-podcast
158
162
  licenses:
159
163
  - MIT
@@ -175,7 +179,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
175
179
  version: '0'
176
180
  requirements: []
177
181
  rubyforge_project:
178
- rubygems_version: 2.5.1
182
+ rubygems_version: 2.6.3
179
183
  signing_key:
180
184
  specification_version: 4
181
185
  summary: Podcast feed parsing with Feedjira
@@ -1,14 +0,0 @@
1
- module Feedjira
2
- module Parser
3
- class PodcastItem
4
- include SAXMachine
5
- include FeedUtilities
6
-
7
- include ::Feedjira::Podcast::Item::Required
8
- include ::Feedjira::Podcast::Item::Optional
9
- include ::Feedjira::Podcast::Item::Apple
10
- include ::Feedjira::Podcast::Item::Dublin
11
- include ::Feedjira::Podcast::Item::Content
12
- end
13
- end
14
- end