Skip to content

Commit f20c888

Browse files
committed
日付形式を ISO 8601 に統一し、Fail-Fast 原則を適用
- すべての published_at を ISO 8601 形式(例: 2025-10-24T20:00:07+09:00)に統一 - 予期しない RSS 形式の場合は例外を発生させて早期にエラー検出 - YAGNI原則に従い不要な防御的コードを削除
1 parent 45bf67d commit f20c888

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

lib/tasks/news.rake

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,18 @@ namespace :news do
2727
feed.items.map { |item|
2828
# RSS 1.0 (RDF) と RSS 2.0 の両方に対応
2929
# 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
30+
published_at = if item.respond_to?(:pubDate) && item.pubDate
31+
item.pubDate
32+
elsif item.respond_to?(:dc_date) && item.dc_date
33+
item.dc_date
3434
else
35-
Time.current.to_s
35+
raise "Unexpected RSS format: neither pubDate nor dc:date found for item: #{item.link}"
3636
end
3737

3838
{
3939
'url' => item.link,
4040
'title' => item.title,
41-
'published_at' => published_at
41+
'published_at' => published_at.iso8601 # ISO 8601 形式に統一
4242
}
4343
}
4444
end

0 commit comments

Comments
 (0)