Skip to content

Commit 94464fe

Browse files
committed
Add recent podcast episodes
We fetch the most recent episodes from both the Giant Robots and Bike Shed feeds, then list them in the README. The two feeds are combined in order, so it appears like there's one list even though it comes from different sources.
1 parent 5d5c862 commit 94464fe

File tree

9 files changed

+243461
-0
lines changed

9 files changed

+243461
-0
lines changed

bin/update_readme

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,12 @@ require "github_readme"
1010

1111
readme = Readme.new("profile/README.md")
1212
blog = RssFeed.new(url: "https://feeds.feedburner.com/GiantRobotsSmashingIntoOtherGiantRobots")
13+
podcasts = CombinedRssFeed.new(
14+
feed_urls: [
15+
"https://podcast.thoughtbot.com/rss",
16+
"https://bikeshed.thoughtbot.com/rss"
17+
]
18+
)
1319

1420
readme.update(section: "blog", items: blog.take(5))
21+
readme.update(section: "podcasts", items: podcasts.take(5))

lib/combined_rss_feed.rb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
require "rss_feed"
2+
3+
class CombinedRssFeed
4+
include Enumerable
5+
6+
def initialize(feed_urls:)
7+
@rss_feeds = feed_urls.map { |url| RssFeed.new(url: url) }
8+
end
9+
10+
def each
11+
rss_feeds
12+
.map(&:entries)
13+
.flatten
14+
.compact
15+
.sort_by(&:created_at)
16+
.reverse!
17+
.each { |entry| yield entry }
18+
end
19+
20+
private
21+
22+
attr_reader :rss_feeds
23+
end

lib/github_readme.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,7 @@
22

33
require "feed_item"
44
require "rss_feed"
5+
require "combined_rss_feed"
56
require "readme"
7+
8+
Excon.defaults[:middlewares].push(Excon::Middleware::RedirectFollower)

lib/rss_feed.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
require "excon"
33
require "feedjira"
44

5+
require "feed_item"
6+
57
class RssFeed
68
include Enumerable
79

profile/README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,24 @@ products at every stage of the product lifecycle. Since 2003, we have produced
1010
high-quality products for over [1,000 clients][3]. We are proud to leave every
1111
project with a stronger team and improved processes.
1212

13+
<table><tr><td valign="top" width="50%">
14+
15+
### Podcasts
16+
17+
<!-- podcasts starts -->
18+
[554: Founding a Life Saving Business from your dorm room with Luká Yancopoulos](https://podcast.thoughtbot.com/554)
19+
20+
[451: Making Time for and Managing Focus](https://bikeshed.thoughtbot.com/451)
21+
22+
[450: Javascript-Driven Development?](https://bikeshed.thoughtbot.com/450)
23+
24+
[553: The One with Sami and Chad](https://podcast.thoughtbot.com/553)
25+
26+
[449: Evergreen skills for new-ish developers](https://bikeshed.thoughtbot.com/449)
27+
28+
<!-- podcasts ends -->
29+
</td><td valign="top" width="50%">
30+
1331
### Writing
1432

1533
<!-- blog starts -->
@@ -18,6 +36,7 @@ project with a stronger team and improved processes.
1836
[The digital nomad thoughtbottle](https://thoughtbot.com/blog/the-digital-nomad-thoughtbottle)
1937

2038
<!-- blog ends -->
39+
</td></tr></table>
2140

2241
[1]: https://thoughtbot.com
2342
[2]: https://thoughtbot.com/services

spec/combined_rss_feed_spec.rb

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
require "spec_helper"
2+
require "combined_rss_feed"
3+
4+
RSpec.describe CombinedRssFeed do
5+
it "combines a given set of feeds into an ordered list by most recent" do
6+
Excon.stub(
7+
{host: "podcast.thoughtbot.com"},
8+
{status: 200, body: giant_robots_feed}
9+
)
10+
Excon.stub(
11+
{host: "bikeshed.thoughtbot.com"},
12+
{status: 200, body: bike_shed_feed}
13+
)
14+
15+
combined_items = described_class.new(
16+
feed_urls: [
17+
"https://podcast.thoughtbot.com/rss",
18+
"https://bikeshed.thoughtbot.com/rss"
19+
]
20+
)
21+
recent = combined_items.take(3)
22+
23+
expect(recent).to include(
24+
have_attributes(
25+
title: "451: Making Time for and Managing Focus",
26+
url: "https://bikeshed.thoughtbot.com/451",
27+
created_at: match_date(Date.new(2024, 12, 17))
28+
),
29+
have_attributes(
30+
title: "450: Javascript-Driven Development?",
31+
url: "https://bikeshed.thoughtbot.com/450",
32+
created_at: match_date(Date.new(2024, 12, 10))
33+
),
34+
have_attributes(
35+
title: "553: The One with Sami and Chad",
36+
url: "https://podcast.thoughtbot.com/553",
37+
created_at: match_date(Date.new(2024, 12, 5))
38+
)
39+
)
40+
end
41+
42+
def giant_robots_feed
43+
File.read("spec/fixtures/giant_robots_feed.xml")
44+
end
45+
46+
def bike_shed_feed
47+
File.read("spec/fixtures/bike_shed_feed.xml")
48+
end
49+
end

spec/fixtures/bike_shed_feed.xml

Lines changed: 114837 additions & 0 deletions
Large diffs are not rendered by default.

spec/fixtures/giant_robots_feed.xml

Lines changed: 128515 additions & 0 deletions
Large diffs are not rendered by default.

spec/spec_helper.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,9 @@
99
Excon.stubs.clear
1010
end
1111
end
12+
13+
RSpec::Matchers.define :match_date do |expected|
14+
match do |actual|
15+
expect(expected.strftime("%d-%m-%Y")).to eq(actual.strftime("%d-%m-%Y"))
16+
end
17+
end

0 commit comments

Comments
 (0)