Class: Podcast

Inherits:
Object
  • Object
show all
Defined in:
lib/gst-kitchen/podcast.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#authorObject

Returns the value of attribute author.



2
3
4
# File 'lib/gst-kitchen/podcast.rb', line 2

def author
  @author
end

#coverObject

Returns the value of attribute cover.



2
3
4
# File 'lib/gst-kitchen/podcast.rb', line 2

def cover
  @cover
end

#emailObject

Returns the value of attribute email.



2
3
4
# File 'lib/gst-kitchen/podcast.rb', line 2

def email
  @email
end

#episodesObject

Returns the value of attribute episodes.



2
3
4
# File 'lib/gst-kitchen/podcast.rb', line 2

def episodes
  @episodes
end

#episodes_pathObject

Returns the value of attribute episodes_path.



2
3
4
# File 'lib/gst-kitchen/podcast.rb', line 2

def episodes_path
  @episodes_path
end

#explicitObject

Returns the value of attribute explicit.



2
3
4
# File 'lib/gst-kitchen/podcast.rb', line 2

def explicit
  @explicit
end

#formatsObject

Returns the value of attribute formats.



17
18
19
# File 'lib/gst-kitchen/podcast.rb', line 17

def formats
  @formats
end

#handleObject

Returns the value of attribute handle.



2
3
4
# File 'lib/gst-kitchen/podcast.rb', line 2

def handle
  @handle
end

#languageObject

Returns the value of attribute language.



2
3
4
# File 'lib/gst-kitchen/podcast.rb', line 2

def language
  @language
end

#media_urlObject

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_pathObject

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

#subtitleObject

Returns the value of attribute subtitle.



2
3
4
# File 'lib/gst-kitchen/podcast.rb', line 2

def subtitle
  @subtitle
end

#summaryObject

Returns the value of attribute summary.



2
3
4
# File 'lib/gst-kitchen/podcast.rb', line 2

def summary
  @summary
end

#titleObject

Returns the value of attribute title.



2
3
4
# File 'lib/gst-kitchen/podcast.rb', line 2

def title
  @title
end

#websiteObject

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.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

Instance Method Details

#cover_urlObject



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


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_episodesObject



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

#podcastObject



83
84
85
# File 'lib/gst-kitchen/podcast.rb', line 83

def podcast
  self
end

#render_all_feedsObject



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