mns_timeline 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/mns_timeline.rb +40 -36
- metadata +13 -13
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f3990871c1224f957a2e1df07db7346d28d9cb6
|
4
|
+
data.tar.gz: d21fda35abe1f931bb4e00665187ef881c6acb18
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0410076073b440ccb4cda74083128028d1691d4e53b6581c90201eb15bdf1cef02f834e48b6ddb0be8bf8be2e5fefd39737d1919b9e0b7c011474eeab126c1c4
|
7
|
+
data.tar.gz: d83cd5a5dd0573b813c4f5dba39e4e1a231fe52da3c5fdf4dbd7b396d375160441b6b2f4bb2ca83e905b7f2b02e30aa0444dc498114e48bc07c6bddcd046c700
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/mns_timeline.rb
CHANGED
@@ -4,14 +4,15 @@
|
|
4
4
|
|
5
5
|
|
6
6
|
require 'sps-sub'
|
7
|
-
require "sqlite3"
|
8
7
|
require 'fileutils'
|
9
8
|
require 'daily_notices'
|
9
|
+
require 'recordx_sqlite'
|
10
10
|
|
11
11
|
|
12
12
|
class MNSTimeline < SPSSub
|
13
13
|
|
14
|
-
def initialize(timeline: 'notices', host: 'sps', port: 59000,
|
14
|
+
def initialize(timeline: 'notices', host: 'sps', port: 59000,
|
15
|
+
dir: '.', options: {})
|
15
16
|
|
16
17
|
# note: a valid url_base must be provided
|
17
18
|
|
@@ -24,8 +25,25 @@ class MNSTimeline < SPSSub
|
|
24
25
|
}.merge(options)
|
25
26
|
|
26
27
|
super(host: host, port: port)
|
27
|
-
|
28
|
-
|
28
|
+
|
29
|
+
timeline_dir = File.join(dir, timeline)
|
30
|
+
|
31
|
+
@notices = DailyNotices.new timeline_dir,
|
32
|
+
@options.merge(identifier: timeline, title: timeline.capitalize)
|
33
|
+
|
34
|
+
dbfilename = File.join(timeline_dir, 'timeline.db')
|
35
|
+
|
36
|
+
table = {
|
37
|
+
notices: {
|
38
|
+
id: 0,
|
39
|
+
date: Date.today,
|
40
|
+
topic: '',
|
41
|
+
title: '',
|
42
|
+
description: '',
|
43
|
+
link: ''
|
44
|
+
}
|
45
|
+
}
|
46
|
+
@rxnotices = RecordxSqlite.new(dbfilename, table: table)
|
29
47
|
|
30
48
|
end
|
31
49
|
|
@@ -37,52 +55,38 @@ class MNSTimeline < SPSSub
|
|
37
55
|
|
38
56
|
def ontopic(timeline_topic, msg)
|
39
57
|
|
40
|
-
puts "%s
|
58
|
+
puts "%s %s: %s" % [Time.now.to_s, timeline_topic, msg.inspect]
|
41
59
|
|
42
60
|
topic, id = msg.split('/').values_at 0, -1
|
61
|
+
|
43
62
|
url_base = @options[:url_base]
|
44
|
-
fileid = Time.at(id.to_i)
|
63
|
+
fileid = Time.at(id.to_i)
|
64
|
+
.strftime("%Y/%b/%-d/").downcase + id + '/index.xml'
|
45
65
|
|
46
66
|
url = "%s%s/%s" % [url_base, topic, fileid]
|
67
|
+
|
47
68
|
kvx = Kvx.new url
|
48
69
|
|
49
|
-
add_notice(kvx.body.clone.merge(topic: topic), id)
|
70
|
+
add_notice(kvx.body.clone.merge(topic: topic), id, topic)
|
50
71
|
|
51
72
|
end
|
52
73
|
|
53
|
-
def add_notice(h, id)
|
74
|
+
def add_notice(h, id, topic)
|
54
75
|
|
55
|
-
|
56
|
-
|
57
|
-
notices = DailyNotices.new timeline_dir,
|
58
|
-
@options.merge(identifier: @timeline, title: @timeline.capitalize)
|
59
|
-
|
60
|
-
return_status = notices.add(item: h, id: id)
|
76
|
+
return_status = @notices.add(item: h, id: id)
|
61
77
|
|
62
78
|
return if return_status == :duplicate
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
db = SQLite3::Database.new dbfilename
|
73
|
-
|
74
|
-
db.execute <<-SQL
|
75
|
-
create table notices (
|
76
|
-
ID INT PRIMARY KEY NOT NULL,
|
77
|
-
MESSAGE TEXT
|
78
|
-
);
|
79
|
-
SQL
|
79
|
+
|
80
|
+
record = {
|
81
|
+
id: id,
|
82
|
+
date: Time.at(id.to_i).to_s,
|
83
|
+
topic: topic,
|
84
|
+
title: h[:title],
|
85
|
+
description: h[:description],
|
86
|
+
link: h[:link]
|
87
|
+
}
|
80
88
|
|
81
|
-
|
82
|
-
|
83
|
-
db.execute("INSERT INTO notices (id, message)
|
84
|
-
VALUES (?, ?)", [id, msg=h[:description]])
|
85
|
-
sleep 1.5
|
89
|
+
@rxnotices.create record
|
86
90
|
|
87
91
|
end
|
88
92
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mns_timeline
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
31
31
|
YBz+URMHtVq6O+d7EkE/k4kCrvXbft0ECyMz6y5LS2066ci943uRhmBABvzPeO1K
|
32
32
|
tBQ+W56kQhJC1g==
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2017-
|
34
|
+
date: 2017-07-04 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: sps-sub
|
@@ -42,7 +42,7 @@ dependencies:
|
|
42
42
|
version: '0.3'
|
43
43
|
- - ">="
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: 0.3.
|
45
|
+
version: 0.3.5
|
46
46
|
type: :runtime
|
47
47
|
prerelease: false
|
48
48
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -52,47 +52,47 @@ dependencies:
|
|
52
52
|
version: '0.3'
|
53
53
|
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: 0.3.
|
55
|
+
version: 0.3.5
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: daily_notices
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
60
|
- - "~>"
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version: '0.
|
62
|
+
version: '0.6'
|
63
63
|
- - ">="
|
64
64
|
- !ruby/object:Gem::Version
|
65
|
-
version: 0.
|
65
|
+
version: 0.6.2
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
68
|
version_requirements: !ruby/object:Gem::Requirement
|
69
69
|
requirements:
|
70
70
|
- - "~>"
|
71
71
|
- !ruby/object:Gem::Version
|
72
|
-
version: '0.
|
72
|
+
version: '0.6'
|
73
73
|
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0.
|
75
|
+
version: 0.6.2
|
76
76
|
- !ruby/object:Gem::Dependency
|
77
|
-
name:
|
77
|
+
name: recordx_sqlite
|
78
78
|
requirement: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '0.2'
|
83
83
|
- - ">="
|
84
84
|
- !ruby/object:Gem::Version
|
85
|
-
version:
|
85
|
+
version: 0.2.7
|
86
86
|
type: :runtime
|
87
87
|
prerelease: false
|
88
88
|
version_requirements: !ruby/object:Gem::Requirement
|
89
89
|
requirements:
|
90
90
|
- - "~>"
|
91
91
|
- !ruby/object:Gem::Version
|
92
|
-
version: '
|
92
|
+
version: '0.2'
|
93
93
|
- - ">="
|
94
94
|
- !ruby/object:Gem::Version
|
95
|
-
version:
|
95
|
+
version: 0.2.7
|
96
96
|
description:
|
97
97
|
email: james@jamesrobertson.eu
|
98
98
|
executables: []
|
metadata.gz.sig
CHANGED
Binary file
|