rss_timeline 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +1 -0
- data/lib/rss_timeline.rb +105 -0
- data.tar.gz.sig +0 -0
- metadata +107 -0
- metadata.gz.sig +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 08e236c5c78beb3593d44089b3684f6368f6c9c9
|
4
|
+
data.tar.gz: 3c457c9b1fd5346d66434982e050ffc2ee7d0f7b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2cc2c32f70a4b74e45d9e308aa6e6a4d1aba9d9327de0c82baaa0019ef3419dd6afa4d9544f08c904199d93ae4918e57a76bfcef79f36ec5b70bb01f273c746f
|
7
|
+
data.tar.gz: 9df2ceeab9c4c290e476bbb61804e0f5c66f532a9a584b2460eeb5937023b6db6c1af68c341a355ebb05b8432f5fd06d3ecdd51a72554b69910df33704f5af73
|
checksums.yaml.gz.sig
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
k�$$Z�(6��?�n���e��u�������`��WaYO �f~٣�����6TwV��3wQB���%Ɵ�K���,�cdv�IN�Mez��(����H���u�d�r8�N�վN'\{6��c�
|
data/lib/rss_timeline.rb
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# file: rss_timeline.rb
|
4
|
+
|
5
|
+
require 'simple-rss'
|
6
|
+
require 'open-uri'
|
7
|
+
require 'fileutils'
|
8
|
+
require 'rss_creator'
|
9
|
+
|
10
|
+
|
11
|
+
class RSStimeline
|
12
|
+
|
13
|
+
attr_accessor :rssfile
|
14
|
+
|
15
|
+
def initialize(feeds=[], rssfile: 'timeline.rss')
|
16
|
+
|
17
|
+
@source_feeds = feeds
|
18
|
+
|
19
|
+
# create a cache directory if it doesn't alread exist
|
20
|
+
FileUtils.mkdir_p 'cache'
|
21
|
+
|
22
|
+
if File.exists? rssfile then
|
23
|
+
@timeline = RSScreator.new rssfile
|
24
|
+
else
|
25
|
+
@timeline = RSScreator.new
|
26
|
+
@timeline.title = @title || 'My RSStimeline feed'
|
27
|
+
@timeline.description = @description || \
|
28
|
+
'Generated using the RSStimeline gem'
|
29
|
+
end
|
30
|
+
|
31
|
+
@rssfile = rssfile
|
32
|
+
@newupdate = false
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
def update()
|
37
|
+
|
38
|
+
# fetch the feeds from the web
|
39
|
+
feeds = @source_feeds.map {|feed| [feed, SimpleRSS.parse(open(feed))] }
|
40
|
+
|
41
|
+
# check for each feed from the cache.
|
42
|
+
# if the feed is in the cache, compare the 2 to find any new items.
|
43
|
+
# New items should be added to the main timeline RSS feed
|
44
|
+
|
45
|
+
feeds.each do |feed, rss|
|
46
|
+
|
47
|
+
rssfile = File.join('cache', feed[6..-1].gsub(/\W+/,'').\
|
48
|
+
reverse.slice(0,40).reverse)
|
49
|
+
|
50
|
+
if File.exists? rssfile then
|
51
|
+
|
52
|
+
rss_cache = SimpleRSS.parse File.read(rssfile)
|
53
|
+
new_rss_items = rss.items - rss_cache.items
|
54
|
+
new_rss_items.each {|item| add_new item}
|
55
|
+
|
56
|
+
else
|
57
|
+
|
58
|
+
add_new rss.items.first
|
59
|
+
File.write rssfile, rss.source
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
if @newupdate then
|
65
|
+
on_update()
|
66
|
+
@newupdate = false
|
67
|
+
end
|
68
|
+
|
69
|
+
@timeline.save @rssfile
|
70
|
+
end
|
71
|
+
|
72
|
+
protected
|
73
|
+
|
74
|
+
def on_new_item(item)
|
75
|
+
# you can override this method to create your
|
76
|
+
# own notifier, callback, or webhook
|
77
|
+
end
|
78
|
+
|
79
|
+
def on_update()
|
80
|
+
# you can override this method to create your
|
81
|
+
# own notifier, callback, or webhook
|
82
|
+
end
|
83
|
+
|
84
|
+
private
|
85
|
+
|
86
|
+
def add_new(item)
|
87
|
+
|
88
|
+
@timeline.add new_item(item)
|
89
|
+
@newupdate = true
|
90
|
+
on_new_item(item)
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
def new_item(x)
|
95
|
+
|
96
|
+
{
|
97
|
+
title: x[:title],
|
98
|
+
link: x[:link],
|
99
|
+
description: x[:description],
|
100
|
+
date: x[:date] || Time.now.strftime("%a, %d %b %Y %H:%M:%S %z")
|
101
|
+
}
|
102
|
+
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
data.tar.gz.sig
ADDED
Binary file
|
metadata
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rss_timeline
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- James Robertson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIDljCCAn6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBIMRIwEAYDVQQDDAlnZW1t
|
14
|
+
YXN0ZXIxHjAcBgoJkiaJk/IsZAEZFg5qYW1lc3JvYmVydHNvbjESMBAGCgmSJomT
|
15
|
+
8ixkARkWAmV1MB4XDTE1MTAyNTEyNDAyN1oXDTE2MTAyNDEyNDAyN1owSDESMBAG
|
16
|
+
A1UEAwwJZ2VtbWFzdGVyMR4wHAYKCZImiZPyLGQBGRYOamFtZXNyb2JlcnRzb24x
|
17
|
+
EjAQBgoJkiaJk/IsZAEZFgJldTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
|
18
|
+
ggEBANvq4jalaj3tw/5HHNB70rlQ+bcsYzzoq+wMTnB01er3a2GwVTxpHFZdRL/8
|
19
|
+
BnR6jg/3ekbC4rLs7hNw8BJR0Kl0J0t00tbljSk9lDDO5sylF0lB8AxL1aM9xbXa
|
20
|
+
fvdYNi05ePRFCU/HcaFUrebJENX6WGey8460sJU+MRxxuDJRZ4UNyUyrGXDzP8x2
|
21
|
+
RVKG/RXHd1KjVuwf43ybshCxEoR2UBcYBMrQrxFev6+CipZcXYr7reeqIftgXPB/
|
22
|
+
p+aGBUWIgZkkmDOWvqiuDLwFZ+Nsu6Tyi+1u8okC+LSfHjjCg4PtEIplZ4jIYouw
|
23
|
+
mg5kZVtD0MCWakZasIYahuKXoRcCAwEAAaOBijCBhzAJBgNVHRMEAjAAMAsGA1Ud
|
24
|
+
DwQEAwIEsDAdBgNVHQ4EFgQUUWWnzGoDxUaDGACHLhaHA/ky66MwJgYDVR0RBB8w
|
25
|
+
HYEbZ2VtbWFzdGVyQGphbWVzcm9iZXJ0c29uLmV1MCYGA1UdEgQfMB2BG2dlbW1h
|
26
|
+
c3RlckBqYW1lc3JvYmVydHNvbi5ldTANBgkqhkiG9w0BAQUFAAOCAQEAXMVH26ji
|
27
|
+
PxVqXMVVLn+9zLZ32bjCmcMFaBy47YM+zC1kK7+LxhUy26RJ7UIaxAspIvTDxSEL
|
28
|
+
NF2l/GOm2H/46JYB5mJZJHZuOR28Z48tHU0RvqUOm/3A+G5plpUVY5eviKvse+rh
|
29
|
+
lX4fxfBdOU1t+GNFlp83F0DPKLlISaaKSjf/lzzSf0pIlWDd2ZKJUyzR26BXCZrP
|
30
|
+
rBzwKUtyKQvyhyjRNwq4FSQGxUrbFobJ3h5C8kKDerroTF25tGCNnzwy1T6Ci0VC
|
31
|
+
26qxA73KaDd6nfVQPejofU2jI+U/vMx42ra5PUEsN7+k5XRLYmswW6g6jLHoqvDn
|
32
|
+
IUYo7zgQ2bCoWg==
|
33
|
+
-----END CERTIFICATE-----
|
34
|
+
date: 2015-10-25 00:00:00.000000000 Z
|
35
|
+
dependencies:
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: simple-rss
|
38
|
+
requirement: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - "~>"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '1.3'
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 1.3.1
|
46
|
+
type: :runtime
|
47
|
+
prerelease: false
|
48
|
+
version_requirements: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - "~>"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '1.3'
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 1.3.1
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: rss_creator
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0.2'
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: 0.2.3
|
66
|
+
type: :runtime
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - "~>"
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0.2'
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.2.3
|
76
|
+
description:
|
77
|
+
email: james@r0bertson.co.uk
|
78
|
+
executables: []
|
79
|
+
extensions: []
|
80
|
+
extra_rdoc_files: []
|
81
|
+
files:
|
82
|
+
- lib/rss_timeline.rb
|
83
|
+
homepage: https://github.com/jrobertson/rss_timeline
|
84
|
+
licenses:
|
85
|
+
- MIT
|
86
|
+
metadata: {}
|
87
|
+
post_install_message:
|
88
|
+
rdoc_options: []
|
89
|
+
require_paths:
|
90
|
+
- lib
|
91
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
requirements: []
|
102
|
+
rubyforge_project:
|
103
|
+
rubygems_version: 2.4.8
|
104
|
+
signing_key:
|
105
|
+
specification_version: 4
|
106
|
+
summary: An RSS aggregator which generates an RSS file
|
107
|
+
test_files: []
|
metadata.gz.sig
ADDED
Binary file
|