feedzirra-podcast 0.0.11 → 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -18,12 +18,14 @@ If you want to avoid potential conflicts, you can directly pass feeds to the pod
18
18
 
19
19
  ## Usage
20
20
 
21
- The parser attempts to match the structure and naming conventions of the actual feed XML elements as closely as possible. `<link>` tags are accessed through `item.link`, etc.
21
+ The parser attempts to match the structure and naming conventions of the actual feed XML elements as closely as possible. `<link>` tags are accessed through `item.link`, etc. Some elements, such as `pubDate`, can be accessed with methods that match the element, or aliases that better adhere to ruby naming conventions (e.g. `pub_date`).
22
22
 
23
23
  The goal is to support all elements common to podcast feeds. Currently not all elements are supported; as they are added, they will be listed below.
24
24
 
25
25
  When it makes sense for an element's value to be parsed or tranformed into a non-string object, that will be done. The string value is always preserved, though.
26
26
 
27
+ When an element has children, such as `itunes:owner`, you can safely call the children directly (`feed.itunes_owner.email`) even when the feed doesn't include the parent element. You will get `nil` back for both calls to the parent or child
28
+
27
29
  ### Channel
28
30
 
29
31
  <link> feed.link
@@ -62,6 +64,7 @@ When it makes sense for an element's value to be parsed or tranformed into a non
62
64
  feed.itunes_explicit_string
63
65
  <itunes:subtitle> feed.itunes_subtitle
64
66
  <itunes:summary> feed.itunes_summary
67
+ <itunes:image href> feed.itunes_image.href
65
68
  <itunes:keywords> feed.itunes_keywords (Array of Strings)
66
69
  feed.itunes_keywords_string
67
70
 
@@ -70,8 +73,13 @@ When it makes sense for an element's value to be parsed or tranformed into a non
70
73
  <itunes:complete> feed.itunes_complete (true, false)
71
74
  feed.itunes_complete_string
72
75
  <itunes:new-feed-url> feed.itunes_new_feed_url
76
+
77
+ <sy:updatePeriod> feed.sy_updatePeriod (:hourly, :daily, etc)
78
+ <sy:updateFrequency> feed.sy_updateFrequency (Integer)
79
+ <sy:updateBase> feed.sy_updateBase (Time)
73
80
 
74
81
  <issn> feed.issn
82
+ <network> feed.network
75
83
 
76
84
  ### Items
77
85
 
@@ -92,6 +100,31 @@ When it makes sense for an element's value to be parsed or tranformed into a non
92
100
  item.enclosure.length
93
101
 
94
102
  <comments> item.comments
103
+
104
+ <dc:creator> item.dc_creator
105
+ <dc:created> item.dc_created (Time)
106
+ <dc:modified> item.dc_modified (Time)
107
+ <dc:replaces> item.dc_replaces
108
+ <dc:isReplacedBy> item.dc_isReplacedBy
109
+
110
+ <itunes:author> feed.itunes_author
111
+ <itunes:subtitle> feed.itunes_subtitle
112
+ <itunes:summary> feed.itunes_summary
113
+ <itunes:explicit> feed.itunes_explicit (true, false, :clean)
114
+ feed.itunes_explicit_string
115
+ <itunes:duration> feed.itunes_duration (Number)
116
+ feed.itunes_duration_string (String)
117
+ <itunes:keywords> feed.itunes_keywords (Array of Strings)
118
+ feed.itunes_keywords_string
119
+ <itunes:image href> feed.itunes_image.href
120
+ <itunes:block> feed.itunes_block (true, false)
121
+ feed.itunes_block_string
122
+ <itunes:isClosedCaptioned> feed.itunes_is_closed_captioned (Boolean)
123
+ feed.itunes_is_closed_captioned_string
124
+ <itunes:order> feed.itunes_order (Float)
125
+ feed.itunes_order_string (String)
126
+
127
+ <content:encoded> item.content_encoded
95
128
 
96
129
  ### Helpers
97
130
 
@@ -10,6 +10,7 @@
10
10
  <language>en-US</language>
11
11
  <sy:updatePeriod>hourly</sy:updatePeriod>
12
12
  <sy:updateFrequency>1</sy:updateFrequency>
13
+ <sy:updateBase>2012-01-01T02:00:00+00:00</sy:updateBase>
13
14
  <!-- podcast_generator="Blubrry PowerPress/4.0.9" -->
14
15
  <itunes:summary>Design is everywhere in our lives, perhaps most importantly in the places where we've just stopped noticing. 99% Invisible (99 Percent Invisible) is a weekly exploration of the process and power of design and architecture. From award winning producer Roman Mars and KALW in San Francisco. Learn more: http://99percentinvisible.org
15
16
 
@@ -36,7 +37,11 @@ Awesome people saying nice things:
36
37
  <link>http://99percentinvisible.org</link>
37
38
  </image>
38
39
  <itunes:category text="Arts">
39
- <itunes:category text="Design" />
40
+ <itunes:category text="Painting" />
41
+ </itunes:category>
42
+ <itunes:category text="Design" />
43
+ <itunes:category text="Music">
44
+ <itunes:category text="Technology" />
40
45
  </itunes:category>
41
46
  <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.99percentinvisible.org/99percentinvisible" />
42
47
  <feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="99percentinvisible" />
@@ -9,12 +9,12 @@ module FeedzirraPodcast
9
9
  # iTunes
10
10
 
11
11
  element :"itunes:author", as: :itunes_author
12
- element :"itunes:owner", as: :itunes_owner, class: ItunesOwner
12
+ element :"itunes:owner", as: :itunes_owner_object, class: ItunesOwner
13
13
  element :"itunes:explicit", as: :itunes_explicit_string
14
14
  element :"itunes:subtitle", as: :itunes_subtitle
15
15
  element :"itunes:summary", as: :itunes_summary
16
- elements :"itunes:category", as: :itunes_categories, value: :text
17
- element :"itunes:image", as: :itunes_image, value: :href
16
+ # elements :"itunes:category", as: :itunes_categories, value: :text
17
+ element :"itunes:image", as: :itunes_image_href, value: :href
18
18
  element :"itunes:keywords", as: :itunes_keywords_string
19
19
 
20
20
  element :"itunes:block", as: :itunes_block_string
@@ -23,13 +23,24 @@ module FeedzirraPodcast
23
23
 
24
24
  # Syndication RSS
25
25
 
26
- # element :"sy:updatePeriod"
27
- # element :"sy:updateFrequency"
28
- # element :"sy:updateBase"
26
+ element :"sy:updatePeriod", as: :sy_update_period_string
27
+ element :"sy:updateFrequency", as: :sy_update_frequency_string
28
+ element :"sy:updateBase", as: :sy_update_base_string
29
29
 
30
30
  # Misc
31
31
 
32
32
  element :issn
33
+ element :network
34
+
35
+ def itunes_owner
36
+ _email = itunes_owner_object ? itunes_owner_object.email : nil
37
+ _name = itunes_owner_object ? itunes_owner_object.name : nil
38
+ Struct.new(:email, :name).new(_email, _name)
39
+ end
40
+
41
+ def itunes_image
42
+ Struct.new(:href).new(itunes_image_href)
43
+ end
33
44
 
34
45
  def itunes_explicit
35
46
  case itunes_explicit_string
@@ -63,6 +74,28 @@ module FeedzirraPodcast
63
74
  false
64
75
  end
65
76
  end
77
+
78
+ def sy_update_period
79
+ case sy_update_period_string
80
+ when "hourly" then :hourly
81
+ when "daily" then :daily
82
+ when "weekly" then :weekly
83
+ when "monthly" then :monthly
84
+ when "yearly" then :yearly
85
+ else nil
86
+ end
87
+ end
88
+ alias_method :sy_updatePeriod, :sy_update_period
89
+
90
+ def sy_update_frequency
91
+ sy_update_frequency_string.to_i if sy_update_frequency_string
92
+ end
93
+ alias_method :sy_updateFrequency, :sy_update_frequency
94
+
95
+ def sy_update_base
96
+ Time.parse(sy_update_base_string)
97
+ end
98
+ alias_method :sy_updateBase, :sy_update_base
66
99
  end
67
100
  end
68
101
  end
@@ -12,7 +12,7 @@ module FeedzirraPodcast
12
12
  element :"itunes:explicit", as: :itunes_explicit_string
13
13
  element :"itunes:duration", as: :itunes_duration_string
14
14
  element :"itunes:keywords", as: :itunes_keywords_string
15
- element :"itunes:image", as: :itunes_image, value: :href
15
+ element :"itunes:image", as: :itunes_image_href, value: :href
16
16
 
17
17
  element :"itunes:block", as: :itunes_block_string
18
18
  element :"itunes:isClosedCaptioned", as: :itunes_is_closed_captioned_string
@@ -22,6 +22,9 @@ module FeedzirraPodcast
22
22
 
23
23
  element :"dc:creator", as: :dc_creator
24
24
  element :"dc:created", as: :dc_created_string
25
+ element :"dc:modified", as: :dc_modified_string
26
+ element :"dc:replaces", as: :dc_replaces
27
+ element :"dc:isReplacedBy", as: :dc_is_replaced_by
25
28
 
26
29
  # Content
27
30
 
@@ -38,6 +41,10 @@ module FeedzirraPodcast
38
41
  end
39
42
  end
40
43
 
44
+ def itunes_image
45
+ Struct.new(:href).new(itunes_image_href)
46
+ end
47
+
41
48
  def itunes_duration
42
49
  Periodic.parse(itunes_duration_string) if itunes_duration_string.present?
43
50
  # rescue
@@ -65,6 +72,7 @@ module FeedzirraPodcast
65
72
  false
66
73
  end
67
74
  end
75
+ alias_method :itunes_isClosedCaptioned, :itunes_is_closed_captioned
68
76
 
69
77
  def itunes_order
70
78
  itunes_order_string.to_f if itunes_order_string.present?
@@ -75,6 +83,16 @@ module FeedzirraPodcast
75
83
  rescue ArgumentError
76
84
  nil
77
85
  end
86
+
87
+ def dc_modified
88
+ Time.parse(dc_modified_string).utc if dc_modified_string.present?
89
+ rescue ArgumentError
90
+ nil
91
+ end
92
+
93
+ def dc_isReplacedBy
94
+ dc_is_replaced_by
95
+ end
78
96
  end
79
97
  end
80
98
  end
@@ -21,7 +21,7 @@ module FeedzirraPodcast
21
21
  element :pubDate, as: :pub_date_string
22
22
  element :lastBuildDate, as: :last_build_date_string
23
23
  elements :category, as: :categories
24
- element :image, class: FeedzirraPodcast::Parser::RSS2ChannelImage
24
+ element :image, as: :image_object, class: FeedzirraPodcast::Parser::RSS2ChannelImage
25
25
  element :docs
26
26
 
27
27
  element :generator
@@ -44,21 +44,45 @@ module FeedzirraPodcast
44
44
  (/\<rss|\<rdf/ =~ xml)
45
45
  end
46
46
 
47
+ def image
48
+ _url = image_object ? image_object.url : nil
49
+ _title = image_object ? image_object.title : nil
50
+ _link = image_object ? image_object.link : nil
51
+ _width = image_object ? image_object.width : nil
52
+ _height = image_object ? image_object.height : nil
53
+ _description = image_object ? image_object.description : nil
54
+
55
+ Struct.new(:url, :title, :link, :width, :height, :description).new(_url, _title, _link, _width, _height, _description)
56
+ end
57
+
47
58
  def pubDate
48
59
  Time.parse(pub_date_string).utc if pub_date_string.present?
49
60
  rescue ArgumentError
50
61
  nil
51
62
  end
63
+ alias_method :pub_date, :pubDate
64
+ alias_method :pubdate, :pubDate
52
65
 
53
66
  def lastBuildDate
54
67
  Time.parse(last_build_date_string).utc if last_build_date_string.present?
55
68
  rescue ArgumentError
56
69
  nil
57
70
  end
71
+ alias_method :last_build_date, :lastBuildDate
58
72
 
59
73
  def feedburner?
60
74
  !!feedburner_info_xmlns || !!feedburner_info_uri
61
75
  end
76
+
77
+ def managing_editor
78
+ managingEditor
79
+ end
80
+ alias_method :managingeditor, :managing_editor
81
+
82
+ def web_master
83
+ webMaster
84
+ end
85
+ alias_method :webmaster, :web_master
62
86
  end
63
87
  end
64
88
  end
@@ -29,6 +29,8 @@ module FeedzirraPodcast
29
29
  rescue ArgumentError
30
30
  nil
31
31
  end
32
+ alias_method :pub_date, :pubDate
33
+ alias_method :pubdate, :pubDate
32
34
 
33
35
  def source
34
36
  Struct.new(:title, :url).new(source_title, source_url)
@@ -1,3 +1,3 @@
1
1
  module FeedzirraPodcast
2
- VERSION = '0.0.11'
2
+ VERSION = '0.0.12'
3
3
  end
@@ -11,4 +11,37 @@ class PodcastChannelTest < MiniTest::Unit::TestCase
11
11
  def test_itunes_author
12
12
  assert_equal 'Roman Mars', @feed.itunes_author
13
13
  end
14
+
15
+ def test_itunes_owner
16
+ assert_equal 'roman_mars@yahoo.com', @feed.itunes_owner.email
17
+ end
18
+
19
+ def test_excluded_tag
20
+ assert_equal nil, @feed.itunes_new_feed_url
21
+ end
22
+
23
+ def test_sy_update_frequency
24
+ assert_equal "1", @feed.sy_update_frequency_string
25
+ assert_equal 1, @feed.sy_update_frequency
26
+ end
27
+
28
+ def test_sy_update_period
29
+ assert_equal "hourly", @feed.sy_update_period_string
30
+ assert_equal :hourly, @feed.sy_update_period
31
+ end
32
+
33
+ def test_sy_update_base
34
+ assert_equal "2012-01-01T02:00:00+00:00", @feed.sy_update_base_string
35
+ assert_equal Time.parse('2012-01-01T02:00:00+00:00'), @feed.sy_update_base
36
+ assert_equal Time.parse('2012-01-01T02:00:00+00:00'), @feed.sy_updateBase
37
+ end
38
+
39
+ def test_itunes_image
40
+ url = 'http://cdn.99percentinvisible.org/wp-content/uploads/powerpress/99invisible-logo-1400.jpg'
41
+ assert_equal url, @feed.itunes_image.href
42
+ end
43
+
44
+ def test_itunes_categories
45
+ # assert_equal 1, @feed.itunes_categories
46
+ end
14
47
  end
@@ -22,4 +22,8 @@ class PodcastItemTest < MiniTest::Unit::TestCase
22
22
  assert_equal 'no', @item.itunes_explicit_string
23
23
  assert_equal false, @item.itunes_explicit
24
24
  end
25
+
26
+ def test_closed_captioned
27
+ assert_equal false, @item.itunes_is_closed_captioned
28
+ end
25
29
  end
@@ -15,4 +15,9 @@ class RSSChannelTest < MiniTest::Unit::TestCase
15
15
  def test_feedburner
16
16
  assert_equal true, @feed.feedburner?
17
17
  end
18
+
19
+ def test_image
20
+ assert_equal '99% Invisible', @feed.image.title
21
+ assert_equal nil, @feed.image.width
22
+ end
18
23
  end
metadata CHANGED
@@ -1,7 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: feedzirra-podcast
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Chris Kalafarski
@@ -13,57 +14,65 @@ dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: bundler
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
- - - "~>"
19
+ - - ~>
18
20
  - !ruby/object:Gem::Version
19
21
  version: '1.3'
20
22
  type: :development
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
- - - "~>"
27
+ - - ~>
25
28
  - !ruby/object:Gem::Version
26
29
  version: '1.3'
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: rake
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
- - - ">="
35
+ - - ! '>='
32
36
  - !ruby/object:Gem::Version
33
37
  version: '0'
34
38
  type: :development
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
- - - ">="
43
+ - - ! '>='
39
44
  - !ruby/object:Gem::Version
40
45
  version: '0'
41
46
  - !ruby/object:Gem::Dependency
42
47
  name: feedzirra
43
48
  requirement: !ruby/object:Gem::Requirement
49
+ none: false
44
50
  requirements:
45
- - - ">="
51
+ - - ! '>='
46
52
  - !ruby/object:Gem::Version
47
53
  version: '0'
48
54
  type: :runtime
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
51
58
  requirements:
52
- - - ">="
59
+ - - ! '>='
53
60
  - !ruby/object:Gem::Version
54
61
  version: '0'
55
62
  - !ruby/object:Gem::Dependency
56
63
  name: periodic
57
64
  requirement: !ruby/object:Gem::Requirement
65
+ none: false
58
66
  requirements:
59
- - - "~>"
67
+ - - ~>
60
68
  - !ruby/object:Gem::Version
61
69
  version: 1.2.2
62
70
  type: :runtime
63
71
  prerelease: false
64
72
  version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
65
74
  requirements:
66
- - - "~>"
75
+ - - ~>
67
76
  - !ruby/object:Gem::Version
68
77
  version: 1.2.2
69
78
  description: Strict RSS 2 podcast parsing with Feedzirra
@@ -73,7 +82,7 @@ executables: []
73
82
  extensions: []
74
83
  extra_rdoc_files: []
75
84
  files:
76
- - ".gitignore"
85
+ - .gitignore
77
86
  - Gemfile
78
87
  - LICENSE.txt
79
88
  - README.md
@@ -95,26 +104,27 @@ files:
95
104
  homepage: https://github.com/PRX/feedzirra-podcast
96
105
  licenses:
97
106
  - MIT
98
- metadata: {}
99
107
  post_install_message:
100
108
  rdoc_options: []
101
109
  require_paths:
102
110
  - lib
103
111
  required_ruby_version: !ruby/object:Gem::Requirement
112
+ none: false
104
113
  requirements:
105
- - - ">="
114
+ - - ! '>='
106
115
  - !ruby/object:Gem::Version
107
116
  version: '0'
108
117
  required_rubygems_version: !ruby/object:Gem::Requirement
118
+ none: false
109
119
  requirements:
110
- - - ">="
120
+ - - ! '>='
111
121
  - !ruby/object:Gem::Version
112
122
  version: '0'
113
123
  requirements: []
114
124
  rubyforge_project:
115
- rubygems_version: 2.2.0
125
+ rubygems_version: 1.8.23
116
126
  signing_key:
117
- specification_version: 4
127
+ specification_version: 3
118
128
  summary: Feedzirra parser classes strictly for handling podcasts strictly
119
129
  test_files:
120
130
  - test/podcast_channel_test.rb
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: c0a142950ca5ee21a1953aba7134cfa474138ef4
4
- data.tar.gz: 607e579dd5e7474a44347c427dffb0594662939c
5
- SHA512:
6
- metadata.gz: d4b2bc5e4e2328edebe7ce1bd13bdf983feb61e411c153c05cdbebe72ab29efedd98987060f8b1321067ddd042edaa6be53453dbbaa7a5c7cb9c5977b6913ab1
7
- data.tar.gz: 5a57bf6d891e67922fe5f3d65574b1bd1a8063b84de5ad3cbf354d992269df83ae90308aee6f346d4325c3b92040a6c6986d57a6263e5cff40cf0ab5c50d86a7