xify 0.4.2 → 0.5.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 +4 -4
- data/lib/xify/input/rss.rb +51 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 04a670e575c49812f3bd6edb9cf7194a658f9c8139ce2881029bb9184ca2b7c4
|
4
|
+
data.tar.gz: afc511486b6ad38b8ade7d19f59a6df9582676bcc9ec47b4ad81fddaee918419
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 561cb4f1f6e05e9949fa10855be28a1ee598288333ab21f181a685cfcde79d377d284ed7fb8415a1b5c11f86bfb08274a5a3eed4be3b215365295cbf93a57496
|
7
|
+
data.tar.gz: 202dcef89a95e41bf98e2a35318803c2a299d1fac45a267a0a89da673c933d60f44f56010fc4d916bdc38a5b82346736265a8b116e0b1f8a0ca877266732a737
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'rss'
|
2
|
+
require 'open-uri'
|
3
|
+
|
4
|
+
module Input
|
5
|
+
class Rss
|
6
|
+
def initialize(config)
|
7
|
+
@config = config
|
8
|
+
|
9
|
+
@uri = URI.parse config['uri']
|
10
|
+
|
11
|
+
working_dir = "#{ENV['HOME']}/.xify/Rss"
|
12
|
+
Dir.mkdir working_dir rescue Errno::EEXIST
|
13
|
+
@latest_file = "#{working_dir}/#{@uri.to_s.gsub(/\W+/, '_')}"
|
14
|
+
end
|
15
|
+
|
16
|
+
def updates
|
17
|
+
opts = {}
|
18
|
+
opts[:first] = :now if @config['trigger']['now']
|
19
|
+
Rufus::Scheduler.singleton.repeat @config['trigger']['schedule'], opts do
|
20
|
+
open(@uri) do |rss|
|
21
|
+
latest = Time.parse File.read(@latest_file) rescue Time.now - 24*60*60
|
22
|
+
feed = RSS::Parser.parse(rss)
|
23
|
+
feed.items
|
24
|
+
.select do |item|
|
25
|
+
item.pubDate > latest
|
26
|
+
end
|
27
|
+
.sort_by do |item|
|
28
|
+
item.pubDate
|
29
|
+
end
|
30
|
+
.each do |item|
|
31
|
+
yield Xify::Event.new(
|
32
|
+
item.dc_creator,
|
33
|
+
"*#{item.title}*\n\n#{item.description}",
|
34
|
+
link: item.link,
|
35
|
+
parent: feed.channel.title,
|
36
|
+
parent_link: feed.channel.link,
|
37
|
+
time: item.pubDate
|
38
|
+
)
|
39
|
+
update_latest item
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def update_latest(latest)
|
48
|
+
File.write @latest_file, latest.pubDate.to_s
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Finn Glöe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-08-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -50,6 +50,7 @@ files:
|
|
50
50
|
- lib/xify/event.rb
|
51
51
|
- lib/xify/input/pipe.rb
|
52
52
|
- lib/xify/input/prompt.rb
|
53
|
+
- lib/xify/input/rss.rb
|
53
54
|
- lib/xify/input/shell.rb
|
54
55
|
- lib/xify/output/stdout.rb
|
55
56
|
homepage:
|