mns_subscriber 0.3.0 → 0.4.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
- checksums.yaml.gz.sig +0 -0
- data/lib/mns_subscriber.rb +43 -30
- data.tar.gz.sig +0 -0
- metadata +16 -16
- metadata.gz.sig +1 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b958aaf19191730c5bdc42f5497f9d16bb1ffbd
|
4
|
+
data.tar.gz: 7b8cb6cdb2e9274b0d8b5a5cf98b2746353ac817
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6dbc91d24adfde108c55c1e6d38bde31ba37af24c005cf69c1c4def49fe075dabab3aa7376ca312a86efa21d038611036fc5e744261cf6c6e748ba50f5ccb033
|
7
|
+
data.tar.gz: 334024bc57cc0c3f7a82543e71f588393767205bda4e655bc3dab140ad0ddda5a59f74fd86afacb69c567bf430177df70f54ad0b99214c512af96757daff346b
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/mns_subscriber.rb
CHANGED
@@ -5,9 +5,8 @@
|
|
5
5
|
|
6
6
|
require 'mtlite'
|
7
7
|
require 'sps-sub'
|
8
|
-
require "sqlite3"
|
9
|
-
require 'fileutils'
|
10
8
|
require 'daily_notices'
|
9
|
+
require 'recordx_sqlite'
|
11
10
|
|
12
11
|
|
13
12
|
class MNSSubscriber < SPSSub
|
@@ -42,20 +41,24 @@ class MNSSubscriber < SPSSub
|
|
42
41
|
puts "%s: %s %s" % [topic, Time.now.to_s, msg.inspect]
|
43
42
|
|
44
43
|
|
45
|
-
case a.last
|
44
|
+
case a.last.to_sym
|
46
45
|
|
47
|
-
when
|
46
|
+
when :profile
|
48
47
|
|
49
48
|
update_attributes(:description, subtopic=a[-2], profile=msg)
|
50
49
|
|
51
|
-
when
|
50
|
+
when :link
|
52
51
|
|
53
52
|
update_attributes(:link, subtopic=a[-2], link=msg)
|
54
53
|
|
55
|
-
when
|
54
|
+
when :title
|
56
55
|
|
57
56
|
update_attributes(:title, subtopic=a[-2], title=msg)
|
58
57
|
|
58
|
+
when :delete
|
59
|
+
|
60
|
+
delete_notice(subtopic=a[-2], msg)
|
61
|
+
|
59
62
|
else
|
60
63
|
|
61
64
|
subtopic = a.last
|
@@ -65,52 +68,62 @@ class MNSSubscriber < SPSSub
|
|
65
68
|
|
66
69
|
end
|
67
70
|
|
68
|
-
def add_notice(topic,
|
71
|
+
def add_notice(topic, raw_msg)
|
69
72
|
|
70
73
|
topic_dir = File.join(@filepath, topic)
|
71
74
|
notices = DailyNotices.new topic_dir, @options.merge(identifier: topic,
|
72
75
|
title: topic.capitalize + ' daily notices')
|
76
|
+
|
77
|
+
id = Time.now.to_i
|
73
78
|
|
79
|
+
# strip out any JSON from the end of the message
|
80
|
+
msg, raw_json = raw_msg.split(/(?=\{.*)/)
|
74
81
|
|
75
|
-
|
76
|
-
id = Time.now.to_i.to_s
|
77
|
-
|
78
82
|
h = {
|
79
83
|
description: MTLite.new(msg).to_html,
|
80
84
|
topic: topic
|
81
85
|
}
|
82
|
-
return_status = notices.add(item: h, id: id)
|
86
|
+
return_status = notices.add(item: h, id: id.to_s)
|
83
87
|
|
84
88
|
return if return_status == :duplicate
|
85
|
-
|
86
|
-
dbfilename = File.join(topic_dir, topic + '.db')
|
87
89
|
|
88
|
-
|
89
|
-
|
90
|
-
|
90
|
+
notices = RecordxSqlite.new(File.join(topic_dir, 'notices.db'),
|
91
|
+
table: {notices: {id: 0, message: ''}})
|
92
|
+
notices.create id: id.to_s, message: msg
|
93
|
+
|
94
|
+
if raw_json then
|
91
95
|
|
92
|
-
|
93
|
-
|
94
|
-
|
96
|
+
record = {id: id}.merge(JSON.parse(raw_json))
|
97
|
+
index = RecordxSqlite.new(File.join(topic_dir, 'index.db'),
|
98
|
+
table: {items: record})
|
99
|
+
index.create record
|
95
100
|
|
96
|
-
db.execute <<-SQL
|
97
|
-
create table notices (
|
98
|
-
ID INT PRIMARY KEY NOT NULL,
|
99
|
-
MESSAGE TEXT
|
100
|
-
);
|
101
|
-
SQL
|
102
|
-
|
103
101
|
end
|
104
102
|
|
105
|
-
|
106
|
-
db.execute("INSERT INTO notices (id, message)
|
107
|
-
VALUES (?, ?)", [id, msg])
|
108
|
-
|
109
103
|
self.notice "%s/add: %s/status/%s" % [@timeline, topic, id] if @timeline
|
110
104
|
|
111
105
|
sleep 0.3
|
112
106
|
|
113
107
|
end
|
108
|
+
|
109
|
+
def delete_notice(topic, msg)
|
110
|
+
|
111
|
+
topic_dir = File.join(@filepath, topic)
|
112
|
+
|
113
|
+
notices = RecordxSqlite.new(File.join(topic_dir, 'notices.db'),
|
114
|
+
table: 'notices')
|
115
|
+
id = msg.to_i
|
116
|
+
notices.delete id
|
117
|
+
|
118
|
+
indexdb = File.join(topic_dir, 'index.db')
|
119
|
+
|
120
|
+
if File.exists? indexdb then
|
121
|
+
|
122
|
+
RecordxSqlite.new(indexdb, table: 'items').delete id
|
123
|
+
|
124
|
+
end
|
125
|
+
|
126
|
+
end
|
114
127
|
|
115
128
|
def update_attributes(attribute, topic, value)
|
116
129
|
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mns_subscriber
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
31
31
|
wBAv1HG6hlSk9BepsW4e+NbsgNYQdx0NkPtppfh502tww8DydLyWZNnEte5tAbjg
|
32
32
|
mBoofo/5xUxN5A==
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2017-
|
34
|
+
date: 2017-07-01 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: mtlite
|
@@ -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.3
|
46
46
|
type: :runtime
|
47
47
|
prerelease: false
|
48
48
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -52,7 +52,7 @@ dependencies:
|
|
52
52
|
version: '0.3'
|
53
53
|
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: 0.3.
|
55
|
+
version: 0.3.3
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: sps-sub
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
@@ -62,7 +62,7 @@ dependencies:
|
|
62
62
|
version: '0.3'
|
63
63
|
- - ">="
|
64
64
|
- !ruby/object:Gem::Version
|
65
|
-
version: 0.3.
|
65
|
+
version: 0.3.5
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
68
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -72,47 +72,47 @@ dependencies:
|
|
72
72
|
version: '0.3'
|
73
73
|
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0.3.
|
75
|
+
version: 0.3.5
|
76
76
|
- !ruby/object:Gem::Dependency
|
77
|
-
name:
|
77
|
+
name: daily_notices
|
78
78
|
requirement: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '0.5'
|
83
83
|
- - ">="
|
84
84
|
- !ruby/object:Gem::Version
|
85
|
-
version:
|
85
|
+
version: 0.5.9
|
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.5'
|
93
93
|
- - ">="
|
94
94
|
- !ruby/object:Gem::Version
|
95
|
-
version:
|
95
|
+
version: 0.5.9
|
96
96
|
- !ruby/object:Gem::Dependency
|
97
|
-
name:
|
97
|
+
name: recordx_sqlite
|
98
98
|
requirement: !ruby/object:Gem::Requirement
|
99
99
|
requirements:
|
100
100
|
- - "~>"
|
101
101
|
- !ruby/object:Gem::Version
|
102
|
-
version: '0.
|
102
|
+
version: '0.2'
|
103
103
|
- - ">="
|
104
104
|
- !ruby/object:Gem::Version
|
105
|
-
version: 0.4
|
105
|
+
version: 0.2.4
|
106
106
|
type: :runtime
|
107
107
|
prerelease: false
|
108
108
|
version_requirements: !ruby/object:Gem::Requirement
|
109
109
|
requirements:
|
110
110
|
- - "~>"
|
111
111
|
- !ruby/object:Gem::Version
|
112
|
-
version: '0.
|
112
|
+
version: '0.2'
|
113
113
|
- - ">="
|
114
114
|
- !ruby/object:Gem::Version
|
115
|
-
version: 0.4
|
115
|
+
version: 0.2.4
|
116
116
|
description:
|
117
117
|
email: james@jamesrobertson.eu
|
118
118
|
executables: []
|
metadata.gz.sig
CHANGED