podrick 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.bundle/config +2 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +38 -0
- data/README.md +11 -0
- data/Rakefile +8 -0
- data/bin/coderay +16 -0
- data/bin/nokogiri +16 -0
- data/bin/pry +16 -0
- data/test/assets/back_to_work.xml +6056 -0
- data/test/assets/by_the_way.xml +67 -0
- data/test/assets/radio_lab.xml +3605 -0
- data/test/assets/roderick_on_the_line.xml +267 -0
- data/test/assets/unprofessional.xml +879 -0
- data/test/assets/you_look_nice_today.xml +2223 -0
- data/test/helper.rb +12 -0
- data/test/podrick/test_episode.rb +72 -0
- data/test/podrick/test_podcast.rb +91 -0
- metadata +126 -0
data/test/helper.rb
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
module Podrick
|
4
|
+
class TestEpisode < MiniTest::Unit::TestCase
|
5
|
+
describe "episode loading" do
|
6
|
+
it "loads the metadata from a nokogiri xml doc" do
|
7
|
+
item_xml = Nokogiri::XML(File.read('test/assets/back_to_work.xml')).at_xpath("//item")
|
8
|
+
episode = Episode.new(item_xml)
|
9
|
+
|
10
|
+
assert_equal "Back to Work 105: Fissures of Men", episode.title
|
11
|
+
assert_equal "http://5by5.tv/b2w/105", episode.link
|
12
|
+
assert_equal "http://5by5.tv/b2w/105", episode.guid
|
13
|
+
assert_equal Time.parse("2013-02-05 20:30:00 GMT"), episode.published_date
|
14
|
+
assert episode.description.include?("he and Dan talk about a bunch of cool apps")
|
15
|
+
assert_equal "http://d.ahoy.co/redirect.mp3/fly.5by5.tv/audio/broadcasts/b2w/2013/b2w-105.mp3", episode.enclosure.url
|
16
|
+
assert_equal "40815332", episode.enclosure.length
|
17
|
+
assert_equal "audio/mpeg", episode.enclosure.type
|
18
|
+
assert episode.content.include?("<p>This week, Merlin is delirious and may be in a fugue state, so he and Dan talk about a bunch of cool apps and gadgets--stuff that Merlin likes and really recommends.</p>")
|
19
|
+
assert_equal "Merlin Mann & Dan Benjamin", episode.itunes.author
|
20
|
+
assert_equal "1:24:27", episode.itunes.duration
|
21
|
+
assert_equal "TOPIC: Cool stuff Merlin loves.", episode.itunes.subtitle
|
22
|
+
assert episode.itunes.summary.include?("This week, Merlin is delirious and may be in a fugue state, so he and Dan talk about a bunch of cool apps")
|
23
|
+
assert_equal "productivity, communication, work, barriers, constraints, tools, gadgets", episode.itunes.keywords
|
24
|
+
assert_equal "http://icebox.5by5.tv/images/broadcasts/19/cover.jpg", episode.itunes.image.href
|
25
|
+
end
|
26
|
+
|
27
|
+
it "loads the metadata from another format" do
|
28
|
+
item_xml = Nokogiri::XML(File.read('test/assets/radio_lab.xml')).at_xpath("//item")
|
29
|
+
episode = Episode.new(item_xml)
|
30
|
+
|
31
|
+
assert_equal "Speed\n", episode.title
|
32
|
+
assert_equal "http://feeds.wnyc.org/~r/radiolab/~3/aD0MohGPUvo/", episode.link
|
33
|
+
assert_equal "http://www.radiolab.org/2013/feb/05/", episode.guid
|
34
|
+
assert_equal Time.parse("2013-02-05 17:35:00 -0500"), episode.published_date
|
35
|
+
assert episode.description.include?("We live our lives at human speed, we experience and interact with the world")
|
36
|
+
assert_equal "http://feeds.wnyc.org/~r/radiolab/~5/HrqM1JwInZE/radiolab020513.mp3", episode.enclosure.url
|
37
|
+
assert_equal "0", episode.enclosure.length
|
38
|
+
assert_equal "audio/mpeg", episode.enclosure.type
|
39
|
+
assert_equal nil, episode.content
|
40
|
+
assert_equal "Jad Abumrad & Robert Krulwich", episode.itunes.author
|
41
|
+
assert_equal nil, episode.itunes.duration
|
42
|
+
assert_equal " We live our lives at human speed, we experience and interact with the world on a human time scale. But this hour, we put ourselves through the paces, peek inside a microsecond, and master the fastest thing in the universe. ", episode.itunes.subtitle
|
43
|
+
assert episode.itunes.summary.include?("We live our lives at human speed, we experience and interact with the world on a human time scale.")
|
44
|
+
assert_equal "Science,Technology,Philosophy,Education,radiolab,jad,abumrad,krulwich,Radio,Lab", episode.itunes.keywords
|
45
|
+
assert_equal nil, episode.itunes.image.href
|
46
|
+
end
|
47
|
+
|
48
|
+
it "loads the metadata removing images in description" do
|
49
|
+
item_xml = Nokogiri::XML(File.read('test/assets/you_look_nice_today.xml')).at_xpath("//item")
|
50
|
+
episode = Episode.new(item_xml)
|
51
|
+
|
52
|
+
assert episode.description.include?("As part of a pilot program")
|
53
|
+
|
54
|
+
assert !episode.description.include?("<img src"), "Description still contains img tag"
|
55
|
+
assert !episode.description.include?("https://dl.dropbox.com/u/3423/i/ylnt/ylnt_s02e11_wish/ylnt_s02e11.jpg"), "Description still contains image url"
|
56
|
+
assert !episode.description.include?("http://feeds.feedburner.com/~r/YouLookNiceToday/~4/CLx_UnRTK2U"), "Description still contains tracking image url"
|
57
|
+
assert episode.itunes.summary.include?("You win awards by confusing people.")
|
58
|
+
|
59
|
+
assert_equal 2, episode.images.count
|
60
|
+
end
|
61
|
+
|
62
|
+
it "loads another failing format" do
|
63
|
+
item_xml = Nokogiri::XML(File.read('test/assets/roderick_on_the_line.xml')).at_xpath("//item")
|
64
|
+
episode = Episode.new(item_xml)
|
65
|
+
|
66
|
+
assert_equal nil, episode.content, "Episode description should be nil"
|
67
|
+
assert episode.description.include?("<strong>The Problem</strong>"), "Episode description does not contain first given string"
|
68
|
+
assert episode.description.include?("in a mine shaft"), "Episode description does not contain second given string"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
module Podrick
|
4
|
+
class TestPodcast < MiniTest::Unit::TestCase
|
5
|
+
describe "podcast metadata loading" do
|
6
|
+
it "loads the metadata from xml" do
|
7
|
+
podcast = Podcast.from_xml(File.read('test/assets/back_to_work.xml'))
|
8
|
+
assert_equal "Back to Work", podcast.title
|
9
|
+
assert_equal "http://5by5.tv/b2w", podcast.link
|
10
|
+
|
11
|
+
description = "Back to Work is an award winning talk show with Merlin Mann and Dan Benjamin discussing productivity, communication, work, barriers, constraints, tools, and more. Hosted by Merlin Mann & Dan Benjamin."
|
12
|
+
assert_equal description, podcast.description
|
13
|
+
|
14
|
+
assert_equal "en-us", podcast.language
|
15
|
+
|
16
|
+
assert_equal "Back to Work", podcast.itunes.subtitle
|
17
|
+
assert_equal "5by5", podcast.itunes.author
|
18
|
+
assert_equal description, podcast.itunes.summary
|
19
|
+
assert_equal "http://icebox.5by5.tv/images/broadcasts/19/cover.jpg", podcast.itunes.image.href
|
20
|
+
assert_equal "productivity, communication, work, barriers, constraints, tools", podcast.itunes.keywords
|
21
|
+
assert_equal "no", podcast.itunes.explicit
|
22
|
+
assert_equal "5by5 Broadcasting", podcast.itunes.owner.name
|
23
|
+
assert_equal "itunes@5by5.tv", podcast.itunes.owner.email
|
24
|
+
assert_equal "Technology", podcast.itunes.category
|
25
|
+
assert_equal "Software How-To", podcast.itunes.subcategories[0]
|
26
|
+
assert_equal "Tech News", podcast.itunes.subcategories[1]
|
27
|
+
end
|
28
|
+
|
29
|
+
it "loads the metadata from feed url" do
|
30
|
+
stub_request(:get, "http://feeds.feedburner.com/unprofessional-podcast")
|
31
|
+
.to_return(:body => File.read('test/assets/unprofessional.xml'))
|
32
|
+
|
33
|
+
podcast = Podcast.from_url("http://feeds.feedburner.com/unprofessional-podcast")
|
34
|
+
assert_equal "Unprofessional", podcast.title
|
35
|
+
assert_equal "http://muleradio.net/unprofessional", podcast.link
|
36
|
+
|
37
|
+
description = "Lex and Dave have unprofessional conversations with interesting people."
|
38
|
+
|
39
|
+
assert_equal description, podcast.description
|
40
|
+
assert_equal "en", podcast.language
|
41
|
+
|
42
|
+
# itunes info
|
43
|
+
assert_equal description, podcast.itunes.subtitle
|
44
|
+
assert_equal "Mule Radio Syndicate", podcast.itunes.author
|
45
|
+
assert_equal description, podcast.itunes.summary
|
46
|
+
assert_equal "http://media.muleradio.net/images/shows/unprofessional/itunes.jpg", podcast.itunes.image.href
|
47
|
+
assert_equal "lex friedman, dave wiskus, unprofessional, origin stories", podcast.itunes.keywords
|
48
|
+
assert_equal "no", podcast.itunes.explicit
|
49
|
+
assert_equal " Dave Wiskus and Lex Friedman ", podcast.itunes.owner.name
|
50
|
+
assert_equal "unprofessional@muleradio.net", podcast.itunes.owner.email
|
51
|
+
assert_equal "Society & Culture", podcast.itunes.category
|
52
|
+
assert_equal " Personal Journals", podcast.itunes.subcategories[0]
|
53
|
+
end
|
54
|
+
|
55
|
+
it "loads the metadata from another format" do
|
56
|
+
stub_request(:get, "http://rss.earwolf.com/by-the-way-in-conversation-with-jeff-garlin")
|
57
|
+
.to_return(:body => File.read('test/assets/by_the_way.xml'))
|
58
|
+
|
59
|
+
podcast = Podcast.from_url("http://rss.earwolf.com/by-the-way-in-conversation-with-jeff-garlin")
|
60
|
+
assert_equal "By The Way, In Conversation with Jeff Garlin", podcast.title
|
61
|
+
assert_equal "http://www.earwolf.com/show/by-the-way-in-conversation-with-jeff-garlin/", podcast.link
|
62
|
+
|
63
|
+
description = "By The Way, In Conversation with Jeff Garlin is an eavesdroppers paradise. Recorded live at Largo in LA, its a series of casual talks between the host and his most interesting show business friends. Agendas are out the window and no topics are off limits in these revealing chats."
|
64
|
+
|
65
|
+
assert_equal description, podcast.description
|
66
|
+
assert_equal "en-us", podcast.language
|
67
|
+
|
68
|
+
# itunes info
|
69
|
+
assert_equal "", podcast.itunes.subtitle
|
70
|
+
assert_equal "Earwolf", podcast.itunes.author
|
71
|
+
assert_equal "", podcast.itunes.summary
|
72
|
+
assert_equal "http://cdn.earwolf.com/wp-content/uploads/2013/01/BTW-Logo.jpg", podcast.itunes.image.href
|
73
|
+
assert_equal nil, podcast.itunes.keywords
|
74
|
+
assert_equal "Yes", podcast.itunes.explicit
|
75
|
+
assert_equal "Earwolf", podcast.itunes.owner.name
|
76
|
+
assert_equal "jeff@earwolf.com", podcast.itunes.owner.email
|
77
|
+
assert_equal "Comedy", podcast.itunes.category
|
78
|
+
assert_equal nil, podcast.itunes.subcategories[0]
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
describe "podcast episode loading" do
|
83
|
+
it "loads each episode from xml" do
|
84
|
+
podcast = Podcast.from_xml(File.read('test/assets/back_to_work.xml'))
|
85
|
+
assert_equal 105, podcast.episodes.length
|
86
|
+
assert_kind_of Episode, podcast.episodes.first
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
metadata
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: podrick
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Scott Bader
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-09-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.8.5
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.8.5
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: nokogiri
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.5.6
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.5.6
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '4'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '4'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: webmock
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.9'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.9'
|
69
|
+
description: Podrick is a library that allows you to quickly, and easily work with
|
70
|
+
a podcast feed. You can parse a feed, see the newest episodes, and download files
|
71
|
+
email: sbader2@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- .bundle/config
|
77
|
+
- Gemfile
|
78
|
+
- Gemfile.lock
|
79
|
+
- README.md
|
80
|
+
- Rakefile
|
81
|
+
- bin/coderay
|
82
|
+
- bin/nokogiri
|
83
|
+
- bin/pry
|
84
|
+
- test/assets/back_to_work.xml
|
85
|
+
- test/assets/by_the_way.xml
|
86
|
+
- test/assets/radio_lab.xml
|
87
|
+
- test/assets/roderick_on_the_line.xml
|
88
|
+
- test/assets/unprofessional.xml
|
89
|
+
- test/assets/you_look_nice_today.xml
|
90
|
+
- test/helper.rb
|
91
|
+
- test/podrick/test_episode.rb
|
92
|
+
- test/podrick/test_podcast.rb
|
93
|
+
homepage: http://sbader.github.com/castpod
|
94
|
+
licenses:
|
95
|
+
- MIT
|
96
|
+
metadata: {}
|
97
|
+
post_install_message:
|
98
|
+
rdoc_options: []
|
99
|
+
require_paths:
|
100
|
+
- lib
|
101
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - '>='
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
requirements: []
|
112
|
+
rubyforge_project:
|
113
|
+
rubygems_version: 2.0.3
|
114
|
+
signing_key:
|
115
|
+
specification_version: 4
|
116
|
+
summary: A simple library to work with podcasts
|
117
|
+
test_files:
|
118
|
+
- test/assets/back_to_work.xml
|
119
|
+
- test/assets/by_the_way.xml
|
120
|
+
- test/assets/radio_lab.xml
|
121
|
+
- test/assets/roderick_on_the_line.xml
|
122
|
+
- test/assets/unprofessional.xml
|
123
|
+
- test/assets/you_look_nice_today.xml
|
124
|
+
- test/helper.rb
|
125
|
+
- test/podrick/test_episode.rb
|
126
|
+
- test/podrick/test_podcast.rb
|