Skip to content

Commit 45bf67d

Browse files
committed
RSS 1.0 (RDF) と RSS 2.0 の両形式に対応
PR TIMES の RSS フィードが RSS 1.0 (RDF) 形式を使用しているため、 既存の RSS 2.0 形式と両方に対応できるよう修正しました。 - RSS 2.0: pubDate フィールドを使用 - RSS 1.0 (RDF): dc:date フィールドを使用 - respond_to? メソッドで動的に判定 これによりPR TIMESフィードから11件の新しいニュースを正常に取得できました。
1 parent d97bf29 commit 45bf67d

File tree

2 files changed

+56
-1
lines changed

2 files changed

+56
-1
lines changed

db/news.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
url: https://news.coderdojo.jp/2025/11/02/dojoletter-vol-90-2025%e5%b9%b409%e6%9c%88%e5%8f%b7/
44
title: DojoLetter Vol.90 2025年09月号
55
published_at: Sun, 02 Nov 2025 13:10:18 +0000
6+
- id: 25
7+
url: https://prtimes.jp/main/html/rd/p/000000016.000038935.html
8+
title: CoderDojo のオープンデータが、デジタル庁が推進する地域の Well-Being 指標のデジタル生活指数に採用
9+
published_at: '2025-10-24T20:00:07+09:00'
610
- id: 13
711
url: https://news.coderdojo.jp/2025/10/04/dojoletter-vol-89-2025%e5%b9%b408%e6%9c%88%e5%8f%b7/
812
title: DojoLetter Vol.89 2025年08月号
@@ -11,6 +15,11 @@
1115
url: https://news.coderdojo.jp/2025/09/10/dojoletter-vol-88-2025%e5%b9%b407%e6%9c%88%e5%8f%b7/
1216
title: DojoLetter Vol.88 2025年07月号
1317
published_at: Wed, 10 Sep 2025 03:45:56 +0000
18+
- id: 24
19+
url: https://prtimes.jp/main/html/rd/p/000000017.000038935.html
20+
title: 日本各地に 200 以上!全国の CoderDojo 関係者が集まるカンファレンス「DojoCon Japan 2025」が、10月25日 (土曜)
21+
に福岡県久留米市で開催
22+
published_at: '2025-09-02T17:30:01+09:00'
1423
- id: 11
1524
url: https://news.coderdojo.jp/2025/08/12/dojoletter-vol-87-2025%e5%b9%b406%e6%9c%88%e5%8f%b7/
1625
title: DojoLetter Vol.87 2025年06月号
@@ -55,3 +64,39 @@
5564
url: https://news.coderdojo.jp/2025/01/14/dojoletter-vol-79-2024%e5%b9%b411%e6%9c%88%e5%8f%b7/
5665
title: DojoLetter Vol.79 2024年11月号
5766
published_at: Tue, 14 Jan 2025 03:30:45 +0000
67+
- id: 23
68+
url: https://prtimes.jp/main/html/rd/p/000000014.000038935.html
69+
title: Box Japan からの支援を受け、全国の CoderDojo へ 128 台のノート PC 寄贈
70+
published_at: '2024-12-25T20:00:31+09:00'
71+
- id: 22
72+
url: https://prtimes.jp/main/html/rd/p/000000012.000038935.html
73+
title: 国際的な非営利活動「CoderDojo」の共同発起人が来日、高田馬場でトークイベント開催
74+
published_at: '2024-02-29T15:00:02+09:00'
75+
- id: 21
76+
url: https://prtimes.jp/main/html/rd/p/000000011.000038935.html
77+
title: TFabWorks と連携し、全国の CoderDojo を対象とした Scratch 用コントローラー「Takoratch」の無償レンタルプログラムをスタート
78+
published_at: '2023-08-30T12:10:01+09:00'
79+
- id: 20
80+
url: https://prtimes.jp/main/html/rd/p/000000010.000038935.html
81+
title: 国内の CoderDojo 関係者が集まる「DojoCon Japan 2023 “Be Cool”」、2023年8月27日(日曜)に奈良で開催
82+
published_at: '2023-06-22T10:00:03+09:00'
83+
- id: 19
84+
url: https://prtimes.jp/main/html/rd/p/000000008.000038935.html
85+
title: Geolonia の支援を得て、全国の CoderDojo が地図から探せる「DojoMap」を開発
86+
published_at: '2022-12-01T13:59:22+09:00'
87+
- id: 18
88+
url: https://prtimes.jp/main/html/rd/p/000000007.000038935.html
89+
title: ポケットサイズの教育用コンピューター「micro:bit」、CoderDojo に 1500 台寄贈
90+
published_at: '2022-05-16T17:00:03+09:00'
91+
- id: 17
92+
url: https://prtimes.jp/main/html/rd/p/000000005.000038935.html
93+
title: 発売3周年のロボットトイ「toio」、CoderDojo 向けレンタルプログラム開始
94+
published_at: '2022-03-18T10:00:20+09:00'
95+
- id: 16
96+
url: https://prtimes.jp/main/html/rd/p/000000003.000038935.html
97+
title: プログラミングでポケモンを動かすワークショップが、全国のCoderDojoで実施可能に。
98+
published_at: '2021-04-23T14:00:05+09:00'
99+
- id: 15
100+
url: https://prtimes.jp/main/html/rd/p/000000002.000038935.html
101+
title: TFabWorksと連携し、micro:bitなどの無償レンタルプログラムを全国のCoderDojo向けに提供
102+
published_at: '2020-11-26T14:00:06+09:00'

lib/tasks/news.rake

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,20 @@ namespace :news do
2525
fetched_items = RSS_FEED_LIST.flat_map do |feed|
2626
feed = RSS::Parser.parse(feed, false)
2727
feed.items.map { |item|
28+
# RSS 1.0 (RDF) と RSS 2.0 の両方に対応
29+
# RSS 2.0: pubDate, RSS 1.0 (RDF): dc:date
30+
published_at = if item.respond_to?(:pubDate)
31+
item.pubDate.to_s
32+
elsif item.respond_to?(:dc_date)
33+
item.dc_date.to_s
34+
else
35+
Time.current.to_s
36+
end
37+
2838
{
2939
'url' => item.link,
3040
'title' => item.title,
31-
'published_at' => item.pubDate.to_s
41+
'published_at' => published_at
3242
}
3343
}
3444
end

0 commit comments

Comments
 (0)