Class: Podcast
- Inherits:
-
Object
- Object
- Podcast
- Defined in:
- lib/gst-kitchen/podcast.rb
Instance Attribute Summary collapse
-
#author ⇒ Object
Returns the value of attribute author.
-
#cover ⇒ Object
Returns the value of attribute cover.
-
#email ⇒ Object
Returns the value of attribute email.
-
#episodes ⇒ Object
Returns the value of attribute episodes.
-
#episodes_path ⇒ Object
Returns the value of attribute episodes_path.
-
#explicit ⇒ Object
Returns the value of attribute explicit.
-
#formats ⇒ Object
Returns the value of attribute formats.
-
#handle ⇒ Object
Returns the value of attribute handle.
-
#language ⇒ Object
Returns the value of attribute language.
-
#media_url ⇒ Object
Returns the value of attribute media_url.
-
#rss_output_path ⇒ Object
Returns the value of attribute rss_output_path.
-
#subtitle ⇒ Object
Returns the value of attribute subtitle.
-
#summary ⇒ Object
Returns the value of attribute summary.
-
#title ⇒ Object
Returns the value of attribute title.
-
#website ⇒ Object
Returns the value of attribute website.
Class Method Summary collapse
Instance Method Summary collapse
- #cover_url ⇒ Object
- #create_episode_from_auphonic(production) ⇒ Object
- #deep_link_url(episode) ⇒ Object
- #episode_by_handle(handle) ⇒ Object
- #episode_media_url(episode, format) ⇒ Object
- #export_episode(episode) ⇒ Object
- #feed_url(format) ⇒ Object
- #load_episodes ⇒ Object
- #other_formats(format) ⇒ Object
- #podcast ⇒ Object
- #render_all_feeds ⇒ Object
- #render_feed(format) ⇒ Object
Instance Attribute Details
#author ⇒ Object
Returns the value of attribute author.
2 3 4 |
# File 'lib/gst-kitchen/podcast.rb', line 2 def @author end |
#cover ⇒ Object
Returns the value of attribute cover.
2 3 4 |
# File 'lib/gst-kitchen/podcast.rb', line 2 def cover @cover end |
#email ⇒ Object
Returns the value of attribute email.
2 3 4 |
# File 'lib/gst-kitchen/podcast.rb', line 2 def email @email end |
#episodes ⇒ Object
Returns the value of attribute episodes.
2 3 4 |
# File 'lib/gst-kitchen/podcast.rb', line 2 def episodes @episodes end |
#episodes_path ⇒ Object
Returns the value of attribute episodes_path.
2 3 4 |
# File 'lib/gst-kitchen/podcast.rb', line 2 def episodes_path @episodes_path end |
#explicit ⇒ Object
Returns the value of attribute explicit.
2 3 4 |
# File 'lib/gst-kitchen/podcast.rb', line 2 def explicit @explicit end |
#formats ⇒ Object
Returns the value of attribute formats.
17 18 19 |
# File 'lib/gst-kitchen/podcast.rb', line 17 def formats @formats end |
#handle ⇒ Object
Returns the value of attribute handle.
2 3 4 |
# File 'lib/gst-kitchen/podcast.rb', line 2 def handle @handle end |
#language ⇒ Object
Returns the value of attribute language.
2 3 4 |
# File 'lib/gst-kitchen/podcast.rb', line 2 def language @language end |
#media_url ⇒ Object
Returns the value of attribute media_url.
2 3 4 |
# File 'lib/gst-kitchen/podcast.rb', line 2 def media_url @media_url end |
#rss_output_path ⇒ Object
Returns the value of attribute rss_output_path.
2 3 4 |
# File 'lib/gst-kitchen/podcast.rb', line 2 def rss_output_path @rss_output_path end |
#subtitle ⇒ Object
Returns the value of attribute subtitle.
2 3 4 |
# File 'lib/gst-kitchen/podcast.rb', line 2 def subtitle @subtitle end |
#summary ⇒ Object
Returns the value of attribute summary.
2 3 4 |
# File 'lib/gst-kitchen/podcast.rb', line 2 def summary @summary end |
#title ⇒ Object
Returns the value of attribute title.
2 3 4 |
# File 'lib/gst-kitchen/podcast.rb', line 2 def title @title end |
#website ⇒ Object
Returns the value of attribute website.
2 3 4 |
# File 'lib/gst-kitchen/podcast.rb', line 2 def website @website end |
Class Method Details
.from_yaml(yaml_file = "podcast.yml") ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/gst-kitchen/podcast.rb', line 19 def self.from_yaml(yaml_file="podcast.yml") hash = YAML.load_file(yaml_file) podcast = self.new podcast.title = hash["title"] podcast.subtitle = hash["subtitle"] podcast. = hash["author"] podcast.email = hash["email"] podcast.language = hash["language"] podcast.summary = hash["summary"] podcast.handle = hash["handle"] podcast.website = hash["website"] podcast.cover = hash["cover"] podcast.media_url = hash["media_url"] podcast.explicit = hash["explicit"] || false podcast.formats = hash["formats"].map { |format| Media.format(format) } podcast.episodes_path = hash["episodes_path"] || "episodes/" podcast.rss_output_path = hash["rss_output_path"] || "." podcast.load_episodes podcast end |
Instance Method Details
#cover_url ⇒ Object
71 72 73 74 75 |
# File 'lib/gst-kitchen/podcast.rb', line 71 def cover_url url = URI(self.website) url.path = self.cover url.to_s end |
#create_episode_from_auphonic(production) ⇒ Object
49 50 51 |
# File 'lib/gst-kitchen/podcast.rb', line 49 def create_episode_from_auphonic(production) Episode.from_auphonic(self, production) end |
#deep_link_url(episode) ⇒ Object
77 78 79 80 81 |
# File 'lib/gst-kitchen/podcast.rb', line 77 def deep_link_url(episode) url = URI(self.website) url.fragment = episode.handle url.to_s end |
#episode_by_handle(handle) ⇒ Object
53 54 55 56 57 |
# File 'lib/gst-kitchen/podcast.rb', line 53 def episode_by_handle(handle) self.episodes.find do |episode| episode.handle.downcase == handle.downcase end end |
#episode_media_url(episode, format) ⇒ Object
65 66 67 68 69 |
# File 'lib/gst-kitchen/podcast.rb', line 65 def episode_media_url(episode, format) url = URI(self.media_url) url.path += "/#{episode.handle.downcase}.#{format.file_ext}" url.to_s end |
#export_episode(episode) ⇒ Object
94 95 96 97 |
# File 'lib/gst-kitchen/podcast.rb', line 94 def export_episode(episode) destination = File.join(episodes_path, "#{episode.handle.downcase}.yml") File.open(destination, "w") { |file| file.write episode.to_yaml} end |
#feed_url(format) ⇒ Object
59 60 61 62 63 |
# File 'lib/gst-kitchen/podcast.rb', line 59 def feed_url(format) url = URI(self.website) url.path = "/#{rss_file(format)}" url.to_s end |
#load_episodes ⇒ Object
43 44 45 46 47 |
# File 'lib/gst-kitchen/podcast.rb', line 43 def load_episodes self.episodes = Dir[File.join(self.episodes_path, "#{handle.downcase}*.yml")].map do |yml| Episode.from_yaml(self, yml) end end |
#other_formats(format) ⇒ Object
105 106 107 |
# File 'lib/gst-kitchen/podcast.rb', line 105 def other_formats(format) self.formats - [format] end |
#podcast ⇒ Object
83 84 85 |
# File 'lib/gst-kitchen/podcast.rb', line 83 def podcast self end |
#render_all_feeds ⇒ Object
99 100 101 102 103 |
# File 'lib/gst-kitchen/podcast.rb', line 99 def render_all_feeds self.formats.each do |format| render_feed(format) end end |
#render_feed(format) ⇒ Object
87 88 89 90 91 92 |
# File 'lib/gst-kitchen/podcast.rb', line 87 def render_feed(format) feed = GstKitchen::Feed.new format: format, template: "episodes" File.open(File.join(rss_output_path, rss_file(format)), "w") do |rss| rss.write feed.to_xml(podcast: podcast) end end |