-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathfeeds.rb
More file actions
76 lines (58 loc) · 1.76 KB
/
feeds.rb
File metadata and controls
76 lines (58 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
require 'newscast'
News.config.database = './news.db'
puts "::::::::::::::::::::::::::::::::::::"
puts ":: #{News.channels.count} channels, #{News.items.count} items"
puts
puts "Channels"
News.channels.reorder( 'items_last_updated DESC' ).each do |channel|
dates = channel.items.reduce( [] ) do |ary,item|
if item.published
ary << item.published.to_date.jd
end
ary
end
dates = dates.sort.reverse
diff = channel.items.count - dates.size
if diff > 0
puts "!!!! WARN - #{diff} dates missing !!!!"
end
days_diff = if dates.size > 1
"#{dates[0] - dates[-1]}d"
else
'?'
end
if channel.items_last_updated?
print "%4dd " % (Date.today.jd-channel.items_last_updated.to_date.jd)
else
print " ? "
end
print " #{channel.items_last_updated}"
print " - %4d" % channel.items.count
print " (#{days_diff})"
print " - #{channel.title}"
print " @ #{channel.feed_url}"
print "\n"
if channel.updated?
print "%4dd " % (Date.today.jd-channel.updated.to_date.jd)
else
print " ? "
end
print " >#{channel.data.updated}<" # from feed updated(atom) + lastBuildDate(rss)
print " / >#{channel.data.published}<" # from feed published(atom) + pubDate(rss) - note: published basically an alias for created
print " -- #{channel.format} >#{channel.generator}<"
print " @ >#{channel.http_server}<"
print "\n"
channel.items.latest.limit(6).each do |item|
print " * "
if item.updated?
print "%4dd " % (Date.today.jd-item.updated.to_date.jd)
else
print " ? "
end
print " >#{item.data.updated}<"
print " >#{item.data.published}<"
print " - >#{item.title}<"
print "\n"
end
puts
end