class Podcast

Attributes

author[RW]
cover[RW]
email[RW]
episodes[RW]
episodes_path[RW]
explicit[RW]
formats[RW]
handle[RW]
language[RW]
media_url[RW]
rss_output_path[RW]
subtitle[RW]
summary[RW]
title[RW]
website[RW]

Public Class Methods

from_yaml(yaml_file="podcast.yml") click to toggle source
# 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.author = 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

Public Instance Methods

cover_url() click to toggle source
# 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) click to toggle source
# File lib/gst-kitchen/podcast.rb, line 49
def create_episode_from_auphonic(production)
  Episode.from_auphonic(self, production)
end
episode_by_handle(handle) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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() click to toggle source
# 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) click to toggle source
# File lib/gst-kitchen/podcast.rb, line 105
def other_formats(format)
  self.formats - [format]
end
podcast() click to toggle source
# File lib/gst-kitchen/podcast.rb, line 83
def podcast
  self
end
render_all_feeds() click to toggle source
# 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) click to toggle source
# 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

Private Instance Methods

rss_file(format) click to toggle source
# File lib/gst-kitchen/podcast.rb, line 111
def rss_file(format)
  "episodes.#{format.file_ext}.rss"
end