Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions db/news.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,43 @@
- id: 14
url: https://news.coderdojo.jp/2025/11/02/dojoletter-vol-90-2025%e5%b9%b409%e6%9c%88%e5%8f%b7/
title: DojoLetter Vol.90 2025年09月号
published_at: Sun, 02 Nov 2025 13:10:18 +0000
published_at: '2025-11-02T13:10:18+00:00'
- id: 13
url: https://news.coderdojo.jp/2025/10/04/dojoletter-vol-89-2025%e5%b9%b408%e6%9c%88%e5%8f%b7/
title: DojoLetter Vol.89 2025年08月号
published_at: Sat, 04 Oct 2025 13:20:16 +0000
published_at: '2025-10-04T13:20:16+00:00'
- id: 12
url: https://news.coderdojo.jp/2025/09/10/dojoletter-vol-88-2025%e5%b9%b407%e6%9c%88%e5%8f%b7/
title: DojoLetter Vol.88 2025年07月号
published_at: Wed, 10 Sep 2025 03:45:56 +0000
published_at: '2025-09-10T03:45:56+00:00'
- id: 11
url: https://news.coderdojo.jp/2025/08/12/dojoletter-vol-87-2025%e5%b9%b406%e6%9c%88%e5%8f%b7/
title: DojoLetter Vol.87 2025年06月号
published_at: Tue, 12 Aug 2025 04:00:02 +0000
published_at: '2025-08-12T04:00:02+00:00'
- id: 10
url: https://news.coderdojo.jp/2025/07/14/233-laptops-to-coderdojo/
title: 米国系 IT 企業から CoderDojo へ、233 台のノート PC 寄贈
published_at: Mon, 14 Jul 2025 05:50:31 +0000
published_at: '2025-07-14T05:50:31+00:00'
- id: 9
url: https://news.coderdojo.jp/2025/07/10/dojoletter-vol-86-2025%e5%b9%b405%e6%9c%88%e5%8f%b7/
title: DojoLetter Vol.86 2025年05月号
published_at: Thu, 10 Jul 2025 04:00:07 +0000
published_at: '2025-07-10T04:00:07+00:00'
- id: 8
url: https://news.coderdojo.jp/2025/06/10/dojoletter-vol-85-2025%e5%b9%b404%e6%9c%88%e5%8f%b7/
title: DojoLetter Vol.85 2025年04月号
published_at: Tue, 10 Jun 2025 03:30:18 +0000
published_at: '2025-06-10T03:30:18+00:00'
- id: 7
url: https://news.coderdojo.jp/2025/05/12/dojoletter-vol-84-2025%e5%b9%b403%e6%9c%88%e5%8f%b7/
title: DojoLetter Vol.84 2025年03月号
published_at: Mon, 12 May 2025 04:00:33 +0000
published_at: '2025-05-12T04:00:33+00:00'
- id: 6
url: https://news.coderdojo.jp/2025/04/10/dojoletter-vol-83-2025%e5%b9%b402%e6%9c%88%e5%8f%b7/
title: DojoLetter Vol.83 2025年02月号
published_at: Thu, 10 Apr 2025 03:45:27 +0000
published_at: '2025-04-10T03:45:27+00:00'
- id: 5
url: https://news.coderdojo.jp/2025/04/04/55-laptops-to-coderdojo/
title: 米国系 IT 企業から CoderDojo へ、55 台のノート PC 寄贈
published_at: Fri, 04 Apr 2025 10:00:32 +0000
published_at: '2025-04-04T10:00:32+00:00'
- id: 4
url: https://news.coderdojo.jp/2025/03/10/dojoletter-vol-82-2025%e5%b9%b401%e6%9c%88%e5%8f%b7/
title: DojoLetter Vol.82 2025年01月号
Expand Down
17 changes: 15 additions & 2 deletions lib/tasks/news.rake
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,32 @@ namespace :news do

# 本番/開発環境では実フィード、それ以外(テスト環境など)ではテスト用フィード
DOJO_NEWS_FEED = 'https://news.coderdojo.jp/feed/'
PR_TIMES_FEED = 'https://prtimes.jp/companyrdf.php?company_id=38935'
TEST_NEWS_FEED = Rails.root.join('spec', 'fixtures', 'sample_news.rss')
RSS_FEED_LIST = (Rails.env.test? || Rails.env.staging?) ?
[TEST_NEWS_FEED] :
[DOJO_NEWS_FEED]
[DOJO_NEWS_FEED, PR_TIMES_FEED]

# RSS のデータ構造を、News のデータ構造に変換
fetched_items = RSS_FEED_LIST.flat_map do |feed|
feed = RSS::Parser.parse(feed, false)
feed.items.map { |item|
# RSS 1.0 (RDF) と RSS 2.0 の両方に対応
# RSS 2.0: pubDate, RSS 1.0 (RDF): dc:date
# - PR TIMES: RSS 1.0 (RDF) 形式 - <rdf:RDF> タグ、dc:date フィールドを使用
# - CoderDojo News: RSS 2.0 形式 - <rss version="2.0"> タグ、pubDate フィールドを使用
published_at = if item.respond_to?(:pubDate) && item.pubDate
item.pubDate
elsif item.respond_to?(:dc_date) && item.dc_date
item.dc_date
else
raise "Unexpected RSS format: neither pubDate nor dc:date found for item: #{item.link}"
end

{
'url' => item.link,
'title' => item.title,
'published_at' => item.pubDate.to_s
'published_at' => published_at.iso8601 # ISO 8601 形式に統一
}
}
end
Expand Down