zooniverse_social 0.1.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/zooniverse_social/data.rb +3 -1
- data/lib/zooniverse_social/posts.rb +10 -3
- data/lib/zooniverse_social/task_observer.rb +16 -0
- data/lib/zooniverse_social/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2170887303b63833125fc8442597b5b40310bf0
|
4
|
+
data.tar.gz: b9b132c059cc39f2e5801e9e1158ba1e3596237d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 550e4e0a5ae8e3dd2fc3a48509065ec0ec9578206134601c76eb6ac962c81e439ea8f9b2ec72831d3faba79ceff2b74d1a8c6be0feac7408b7280afa05f2bb35
|
7
|
+
data.tar.gz: 686211f3d27eb7215a817bbc112ba56a3e1fbc4b741a89eaf4ec845ca10c781f1c51f677e2a3e6608ac5616dd19d02677176191274ca91adab44765c2c94b1ec
|
@@ -3,6 +3,7 @@ require 'concurrent'
|
|
3
3
|
require 'zooniverse_social/posts'
|
4
4
|
require 'zooniverse_social/statuses'
|
5
5
|
require 'zooniverse_social/tweets'
|
6
|
+
require 'zooniverse_social/task_observer'
|
6
7
|
|
7
8
|
module ZooniverseSocial
|
8
9
|
class Data
|
@@ -35,7 +36,8 @@ module ZooniverseSocial
|
|
35
36
|
end
|
36
37
|
|
37
38
|
def self.start
|
38
|
-
Concurrent::TimerTask.new(execution_interval: 600, run_now: true){ update }.execute
|
39
|
+
task = Concurrent::TimerTask.new(execution_interval: 600, timeout_interval: 20, run_now: true){ update }.execute
|
40
|
+
TaskObserver.new task, method(:start)
|
39
41
|
end
|
40
42
|
end
|
41
43
|
end
|
@@ -5,13 +5,20 @@ module ZooniverseSocial
|
|
5
5
|
attr_reader :data
|
6
6
|
|
7
7
|
def initialize
|
8
|
-
@
|
8
|
+
@blog_updater = Updater.new 'https://public-api.wordpress.com', '/rest/v1.1/sites/36711287/posts'
|
9
|
+
@daily_updater = Updater.new 'https://public-api.wordpress.com', '/rest/v1.1/sites/57182749/posts'
|
9
10
|
update
|
10
11
|
end
|
11
12
|
|
12
13
|
def update
|
13
|
-
|
14
|
-
|
14
|
+
blog_data = _update @blog_updater
|
15
|
+
daily_data = _update @daily_updater
|
16
|
+
@data = (blog_data + daily_data).sort{ |a, b| b[:created_at] <=> a[:created_at] }.take 3
|
17
|
+
end
|
18
|
+
|
19
|
+
def _update(updater)
|
20
|
+
response = updater.update number: 3, fields: 'ID,URL,title,date'
|
21
|
+
response.fetch('posts', []).collect do |post|
|
15
22
|
{
|
16
23
|
id: post['ID'],
|
17
24
|
title: post['title'],
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module ZooniverseSocial
|
2
|
+
class TaskObserver
|
3
|
+
def initialize(task, restart)
|
4
|
+
@task = task
|
5
|
+
@restart = restart
|
6
|
+
@task.add_observer self
|
7
|
+
end
|
8
|
+
|
9
|
+
def update(time, result, error)
|
10
|
+
if error.is_a?(Concurrent::TimeoutError)
|
11
|
+
@task.shutdown
|
12
|
+
@restart.call
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zooniverse_social
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Parrish
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-07-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: puma
|
@@ -214,6 +214,7 @@ files:
|
|
214
214
|
- lib/zooniverse_social/posts.rb
|
215
215
|
- lib/zooniverse_social/server.rb
|
216
216
|
- lib/zooniverse_social/statuses.rb
|
217
|
+
- lib/zooniverse_social/task_observer.rb
|
217
218
|
- lib/zooniverse_social/tweets.rb
|
218
219
|
- lib/zooniverse_social/updater.rb
|
219
220
|
- lib/zooniverse_social/version.rb
|