rss_watcher 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +2 -1
- data/lib/rss_watcher.rb +1 -1
- data/lib/rss_watcher/feed_manager.rb +4 -4
- data/lib/rss_watcher/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a8a392f2b60824f13208dca90b367442fc0deecfeebfc1ffa9b81c74a629f562
|
4
|
+
data.tar.gz: 35367aefae2f6764c4dba351042c4d075cd6df6ac326e861a35c2d705ba3d238
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e517afda6abe648cf9efd125c2155d1b5c7476f384e0d0508a8d09dc1b667ae5486292f127301a38164d60cc867a09691b2fb321373145ae85224e9e475c5e02
|
7
|
+
data.tar.gz: 72bce0cb4e1a5027cf6d33f0cde259a59759110f19a2aebc5ca086a02a22b1cc4aac8cde3b1e7c782d69976386cfb823ad13dedcd9c55b929dad5597e63448e6
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# RssWatcher
|
2
|
-
[![Gem Version](https://badge.fury.io/rb/rss_watcher.svg)](https://badge.fury.io/rb/rss_watcher) [![Gem](https://img.shields.io/gem/dt/rss_watcher.svg?colorB=brightgreen&maxAge=3600)](https://badge.fury.io/rb/rss_watcher)
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/rss_watcher.svg)](https://badge.fury.io/rb/rss_watcher) [![Gem](https://img.shields.io/gem/dt/rss_watcher.svg?colorB=brightgreen&maxAge=3600)](https://badge.fury.io/rb/rss_watcher)
|
3
|
+
|
3
4
|
A Ruby Gem For Watching RSS Feeds
|
4
5
|
|
5
6
|
## Installation
|
data/lib/rss_watcher.rb
CHANGED
@@ -11,7 +11,7 @@ module RssWatcher
|
|
11
11
|
#updated_interval - Seconds to wait for between checking for updates to the RSS feed
|
12
12
|
#cache_file - Path to a file that this gem uses internally for remembering the last seen item
|
13
13
|
while true
|
14
|
-
open(url) do |rss|
|
14
|
+
open(url, {"Cache-Control" => "no-cache", "Pragma" => "no-cache"}) do |rss|
|
15
15
|
feed = RSS::Parser.parse(rss)
|
16
16
|
RssWatcher::FeedManager.new(cache_file).get_new_feed_items(feed.items).each do |item|
|
17
17
|
yield item if block_given?
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
1
3
|
module RssWatcher
|
2
4
|
class FeedManager
|
3
5
|
def initialize cache_file_path
|
@@ -36,7 +38,7 @@ module RssWatcher
|
|
36
38
|
|
37
39
|
def load_cache
|
38
40
|
if File.exists? @cache_file_path
|
39
|
-
@cache =
|
41
|
+
@cache = YAML.load File.read(@cache_file_path)
|
40
42
|
else
|
41
43
|
@cache = {time: Time.now.to_i, items_title: []}
|
42
44
|
end
|
@@ -50,9 +52,7 @@ module RssWatcher
|
|
50
52
|
end
|
51
53
|
|
52
54
|
def dump_cache
|
53
|
-
File.
|
54
|
-
file.write Marshal.dump(@cache)
|
55
|
-
end
|
55
|
+
File.write(@cache_file_path, YAML.dump(@cache))
|
56
56
|
end
|
57
57
|
end
|
58
58
|
end
|
data/lib/rss_watcher/version.rb
CHANGED