feedjira-podcast 0.9.8 → 0.9.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -15,14 +15,8 @@ module Feedjira
15
15
  Addressable::URI.parse(link)
16
16
  end
17
17
 
18
- element :width do |width|
19
- width.to_f
20
- end
21
-
22
- element :height do |height|
23
- height.to_f
24
- end
25
-
18
+ element :width, &:to_f
19
+ element :height, &:to_f
26
20
  element :description
27
21
  end
28
22
  end
@@ -2,7 +2,64 @@ module Feedjira
2
2
  module Podcast
3
3
  module Channel
4
4
  module Optional
5
+ module InstanceMethods
6
+ def categories
7
+ category.map(&:strip).uniq
8
+ end
9
+
10
+ def cloud
11
+ @cloud ||= cloud_struct.new(*cloud_params)
12
+ end
13
+
14
+ def image
15
+ @image ||= image_struct.new(*image_params)
16
+ end
17
+
18
+ def skip
19
+ @skip ||= Struct.new(:hours, :days).new(
20
+ skip_hours.hours,
21
+ skip_days.days
22
+ )
23
+ end
24
+
25
+ private
26
+
27
+ def cloud_struct
28
+ Struct.new(:domain, :port, :path, :registerProcedure, :protocol)
29
+ end
30
+
31
+ def cloud_params
32
+ return [] unless _cloud
33
+
34
+ [
35
+ _cloud.domain,
36
+ _cloud.port,
37
+ _cloud.path,
38
+ _cloud.registerProcedure,
39
+ _cloud.protocol
40
+ ]
41
+ end
42
+
43
+ def image_struct
44
+ Struct.new(:url, :title, :link, :width, :height, :description)
45
+ end
46
+
47
+ def image_params
48
+ return [] unless _image
49
+
50
+ [
51
+ _image.url,
52
+ _image.title,
53
+ _image.link,
54
+ _image.width,
55
+ _image.height,
56
+ _image.description
57
+ ]
58
+ end
59
+ end
60
+
5
61
  def self.included(base)
62
+ base.include(InstanceMethods)
6
63
 
7
64
  base.element :language
8
65
  base.element :copyright
@@ -27,53 +84,22 @@ module Feedjira
27
84
 
28
85
  base.elements :category
29
86
 
30
- def categories
31
- category.map{|c|c.strip}.uniq
32
- end
33
-
34
87
  base.element :generator
35
88
 
36
89
  base.element :docs do |docs|
37
90
  Addressable::URI.parse(docs)
38
91
  end
39
92
 
40
- # base.element :cloud
41
- # A has five required attributes: domain is the domain name or IP
42
- # address of the cloud, port is the TCP port that the cloud is running
43
- # on, path is the location of its responder, registerProcedure is the
44
- # name of the procedure to call to request notification, and protocol
45
- # is xml-rpc, soap or http-post (case-sensitive), indicating which
46
- # protocol is to be used.
93
+ base.element :cloud, as: :_cloud, class: Cloud
47
94
 
48
- base.element :ttl do |ttl|
49
- ttl.to_f
50
- end
95
+ base.element :ttl, &:to_f
51
96
 
52
97
  base.element :image, as: :_image, class: Image
53
98
 
54
- def image
55
- @image ||= Struct.new(:url, :title, :link, :width, :height, :description).new(
56
- _image && _image.url,
57
- _image && _image.title,
58
- _image && _image.link,
59
- _image && _image.width,
60
- _image && _image.height,
61
- _image && _image.description,
62
- )
63
- end
64
-
65
99
  # base.element :rating
66
100
  base.element :textInput, as: :text_input, class: TextInput, default: Struct.new(:title, :description, :name, :link).new
67
101
  base.element :skipHours, as: :skip_hours, class: SkipHours
68
102
  base.element :skipDays, as: :skip_days, class: SkipDays
69
-
70
- def skip
71
- @skip ||= Struct.new(:hours, :days).new(
72
- skip_hours.hours,
73
- skip_days.days
74
- )
75
- end
76
-
77
103
  end
78
104
  end
79
105
  end
@@ -3,14 +3,12 @@ module Feedjira
3
3
  module Channel
4
4
  module Required
5
5
  def self.included(base)
6
-
7
6
  base.element :link do |link|
8
7
  Addressable::URI.parse(link)
9
8
  end
10
9
 
11
10
  base.element :title
12
11
  base.element :description
13
-
14
12
  end
15
13
  end
16
14
  end
@@ -5,9 +5,7 @@ module Feedjira
5
5
  include SAXMachine
6
6
  include FeedUtilities
7
7
 
8
- elements :day, as: :day do |day|
9
- day.to_sym
10
- end
8
+ elements :day, as: :day, &:to_sym
11
9
 
12
10
  def days
13
11
  @days ||= day ? day : []
@@ -5,9 +5,7 @@ module Feedjira
5
5
  include SAXMachine
6
6
  include FeedUtilities
7
7
 
8
- elements :hour, as: :hour do |hour|
9
- hour.to_f
10
- end
8
+ elements :hour, as: :hour, &:to_f
11
9
 
12
10
  def hours
13
11
  @hours ||= hour ? hour : []
@@ -2,8 +2,7 @@ module Feedjira
2
2
  module Podcast
3
3
  module Channel
4
4
  module Syndication
5
- def self.included(base)
6
-
5
+ def self.included(_base)
7
6
  end
8
7
  end
9
8
  end
@@ -2,7 +2,6 @@ module Feedjira
2
2
  module Podcast
3
3
  class Error
4
4
  def initialize
5
-
6
5
  end
7
6
  end
8
7
  end
@@ -2,38 +2,7 @@ module Feedjira
2
2
  module Podcast
3
3
  module Item
4
4
  module Apple
5
- def self.included(base)
6
-
7
- base.element :"itunes:author", as: :itunes_author
8
- base.element :"itunes:block", as: :_itunes_block
9
-
10
- base.element :"itunes:image", as: :itunes_image_href, value: :href do |href|
11
- Addressable::URI.parse(href)
12
- end
13
-
14
- base.element :"itunes:duration", as: :itunes_duration do |d|
15
- ["0:0:0:#{d}".split(":")[-3, 3].map(&:to_i)].inject(0) do |m, i|
16
- (i[0] * 3600) + (i[1] * 60) + i[2]
17
- end
18
- end
19
-
20
- base.element :"itunes:explicit", as: :_itunes_explicit
21
-
22
- base.element :"itunes:isClosedCaptioned", as: :_itunes_is_closed_captioned
23
-
24
- base.element :"itunes:order", as: :itunes_order do |order|
25
- order.to_f
26
- end
27
-
28
- base.element :"itunes:subtitle", as: :itunes_subtitle
29
- base.element :"itunes:summary", as: :itunes_summary
30
-
31
- # Legacy support
32
-
33
- base.element :"itunes:keywords", as: :itunes_keywords do |keywords|
34
- keywords.split(',').map(&:strip).select { |k| !k.empty? }
35
- end
36
-
5
+ module InstanceMethods
37
6
  def itunes
38
7
  @itunes ||= Struct.new(
39
8
  :author,
@@ -69,21 +38,52 @@ module Feedjira
69
38
  end
70
39
 
71
40
  def itunes_block
72
- @itunes_block ||= (_itunes_block == 'yes')
41
+ @itunes_block ||= (_itunes_block == "yes")
73
42
  end
74
43
 
75
44
  def itunes_is_closed_captioned
76
- @itunes_is_closed_captioned ||= (_itunes_is_closed_captioned == 'yes')
45
+ @itunes_is_closed_captioned ||= (_itunes_is_closed_captioned == "yes")
77
46
  end
78
47
 
79
48
  def itunes_explicit
80
- @itunes_explicit ||= (_itunes_explicit == 'yes')
49
+ @itunes_explicit ||= (_itunes_explicit == "yes")
81
50
  end
82
51
 
83
52
  def itunes_clean
84
- @itunes_clean ||= (_itunes_explicit == 'clean')
53
+ @itunes_clean ||= (_itunes_explicit == "clean")
54
+ end
55
+ end
56
+
57
+ def self.included(base)
58
+ base.include(InstanceMethods)
59
+
60
+ base.element :"itunes:author", as: :itunes_author
61
+ base.element :"itunes:block", as: :_itunes_block
62
+
63
+ base.element :"itunes:image", as: :itunes_image_href, value: :href do |href|
64
+ Addressable::URI.parse(href)
85
65
  end
86
66
 
67
+ base.element :"itunes:duration", as: :itunes_duration do |d|
68
+ ["0:0:0:#{d}".split(":")[-3, 3].map(&:to_i)].inject(0) do |_m, i|
69
+ (i[0] * 3600) + (i[1] * 60) + i[2]
70
+ end
71
+ end
72
+
73
+ base.element :"itunes:explicit", as: :_itunes_explicit
74
+
75
+ base.element :"itunes:isClosedCaptioned", as: :_itunes_is_closed_captioned
76
+
77
+ base.element :"itunes:order", as: :itunes_order, &:to_f
78
+
79
+ base.element :"itunes:subtitle", as: :itunes_subtitle
80
+ base.element :"itunes:summary", as: :itunes_summary
81
+
82
+ # Legacy support
83
+
84
+ base.element :"itunes:keywords", as: :itunes_keywords do |keywords|
85
+ keywords.split(",").map(&:strip).select { |k| !k.empty? }
86
+ end
87
87
  end
88
88
  end
89
89
  end
@@ -2,14 +2,16 @@ module Feedjira
2
2
  module Podcast
3
3
  module Item
4
4
  module Content
5
- def self.included(base)
6
-
7
- base.element :"content:encoded", as: :content_encoded
8
-
5
+ module InstanceMethods
9
6
  def content
10
7
  @content ||= Struct.new(:encoded).new(content_encoded)
11
8
  end
9
+ end
10
+
11
+ def self.included(base)
12
+ base.include(InstanceMethods)
12
13
 
14
+ base.element :"content:encoded", as: :content_encoded
13
15
  end
14
16
  end
15
17
  end
@@ -2,16 +2,18 @@ module Feedjira
2
2
  module Podcast
3
3
  module Item
4
4
  module Dublin
5
- def self.included(base)
6
-
7
- base.element :"dc:creator", as: :dc_creator
8
-
5
+ module InstanceMethods
9
6
  def dc
10
7
  @dc ||= Struct.new(:creator).new(
11
8
  dc_creator,
12
9
  )
13
10
  end
11
+ end
12
+
13
+ def self.included(base)
14
+ base.include(InstanceMethods)
14
15
 
16
+ base.element :"dc:creator", as: :dc_creator
15
17
  end
16
18
  end
17
19
  end
@@ -8,13 +8,12 @@ module Feedjira
8
8
  value :guid do |guid|
9
9
  perma_link? ? Addressable::URI.parse(guid) : guid
10
10
  end
11
-
11
+
12
12
  attribute :isPermaLink, as: :is_perma_link
13
13
 
14
14
  def perma_link?
15
- is_perma_link == 'false' ? false : true
15
+ is_perma_link == "false" ? false : true
16
16
  end
17
-
18
17
  end
19
18
  end
20
19
  end
@@ -2,7 +2,22 @@ module Feedjira
2
2
  module Podcast
3
3
  module Item
4
4
  module Optional
5
+ module InstanceMethods
6
+ def categories
7
+ category.map(&:strip).uniq
8
+ end
9
+
10
+ def enclosure
11
+ @enclosure ||= Struct.new(:url, :length, :type).new(
12
+ enclosure_url,
13
+ enclosure_length,
14
+ enclosure_type,
15
+ )
16
+ end
17
+ end
18
+
5
19
  def self.included(base)
20
+ base.include(InstanceMethods)
6
21
 
7
22
  base.element :link do |link|
8
23
  Addressable::URI.parse(link)
@@ -16,28 +31,14 @@ module Feedjira
16
31
  Addressable::URI.parse(comments)
17
32
  end
18
33
 
19
- def categories
20
- category.map{|c|c.strip}.uniq
21
- end
22
-
23
34
  base.element :enclosure, as: :enclosure_url, value: :url do |url|
24
35
  Addressable::URI.parse(url)
25
36
  end
26
37
 
27
- base.element :enclosure, as: :enclosure_length, value: :length do |length|
28
- length.to_f
29
- end
38
+ base.element :enclosure, as: :enclosure_length, value: :length, &:to_f
30
39
 
31
40
  base.element :enclosure, as: :enclosure_type, value: :type
32
41
 
33
- def enclosure
34
- @enclosure ||= Struct.new(:url, :length, :type).new(
35
- enclosure_url,
36
- enclosure_length,
37
- enclosure_type,
38
- )
39
- end
40
-
41
42
  base.element :guid, as: :guid, class: GUID, default: Struct.new(:guid, :perma_link?).new
42
43
 
43
44
  base.element :pubDate, as: :pub_date do |date|
@@ -49,7 +50,6 @@ module Feedjira
49
50
  end
50
51
 
51
52
  base.element :source, class: Source, default: Struct.new(:name, :url).new
52
-
53
53
  end
54
54
  end
55
55
  end
@@ -3,10 +3,8 @@ module Feedjira
3
3
  module Item
4
4
  module Required
5
5
  def self.included(base)
6
-
7
6
  base.element :title
8
7
  base.element :description
9
-
10
8
  end
11
9
  end
12
10
  end
@@ -10,7 +10,6 @@ module Feedjira
10
10
  attribute :url do |url|
11
11
  Addressable::URI.parse(url)
12
12
  end
13
-
14
13
  end
15
14
  end
16
15
  end
@@ -1,5 +1,5 @@
1
1
  module Feedjira
2
2
  module Podcast
3
- VERSION = "0.9.8"
3
+ VERSION = "0.9.9"
4
4
  end
5
5
  end
@@ -2,7 +2,6 @@ module Feedjira
2
2
  module Podcast
3
3
  class Warning
4
4
  def initialize
5
-
6
5
  end
7
6
  end
8
7
  end