mns_subscriber 0.2.0 → 0.2.1
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.tar.gz.sig +0 -0
- data/lib/mns_subscriber.rb +42 -8
- metadata +1 -1
- 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: 8dec7b2b661610d050fb0385766c6df3ce134cce
|
4
|
+
data.tar.gz: 15a9d63f0edf6c95b99456bc673c73b2b5726bdd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57ea1ce811ca86cca2e08729a704aa102e15d133614306bcae73dd323582d104f06ecf1d75fa70526b607f69f34bfd9fd5f6dd1a6f9f60c295424d944002b2fb
|
7
|
+
data.tar.gz: 8aef5909737bfb7d3f2512eceb478c2a804bf8513a143b7b8f5a60546aac1a35e6c32cfe9f10fa93522ec80077fd3448c8c526b35f8090ad7517a6bc81d5e914
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/mns_subscriber.rb
CHANGED
@@ -36,22 +36,48 @@ class MNSSubscriber < SPSSub
|
|
36
36
|
|
37
37
|
def ontopic(topic, msg)
|
38
38
|
|
39
|
-
|
39
|
+
a = topic.split('/')
|
40
40
|
puts "%s: %s %s" % [topic, Time.now.to_s, msg.inspect]
|
41
|
-
|
42
|
-
|
41
|
+
|
42
|
+
|
43
|
+
case a.last
|
44
|
+
|
45
|
+
when 'profile'
|
46
|
+
|
47
|
+
update_attributes(:description, subtopic=a[-2], profile=msg)
|
48
|
+
|
49
|
+
when 'link'
|
50
|
+
|
51
|
+
update_attributes(:link, subtopic=a[-2], link=msg)
|
52
|
+
|
53
|
+
when 'title'
|
54
|
+
|
55
|
+
update_attributes(:title, subtopic=a[-2], title=msg)
|
56
|
+
|
57
|
+
else
|
58
|
+
|
59
|
+
subtopic = a.last
|
60
|
+
add_notice(subtopic, msg)
|
61
|
+
|
62
|
+
end
|
43
63
|
|
44
64
|
end
|
45
65
|
|
46
66
|
def add_notice(topic, msg)
|
47
67
|
|
48
68
|
topic_dir = File.join(@filepath, topic)
|
49
|
-
|
69
|
+
notices = DailyNotices.new topic_dir, @options.merge(identifier: topic)
|
50
70
|
|
51
|
-
|
71
|
+
dbfilename = File.join(topic_dir, topic + '.db')
|
52
72
|
|
53
|
-
|
73
|
+
if File.exists? dbfilename then
|
54
74
|
|
75
|
+
db = SQLite3::Database.new dbfilename
|
76
|
+
|
77
|
+
else
|
78
|
+
|
79
|
+
db = SQLite3::Database.new dbfilename
|
80
|
+
|
55
81
|
db.execute <<-SQL
|
56
82
|
create table notices (
|
57
83
|
ID INT PRIMARY KEY NOT NULL,
|
@@ -64,12 +90,20 @@ SQL
|
|
64
90
|
|
65
91
|
id = Time.now.to_i.to_s
|
66
92
|
|
67
|
-
notices = DailyNotices.new topic_dir, @options.merge(identifier: topic)
|
68
93
|
notices.add msg, id: id
|
69
94
|
|
70
95
|
db.execute("INSERT INTO notices (id, message)
|
71
96
|
VALUES (?, ?)", [id, msg])
|
72
97
|
|
73
|
-
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def update_attributes(attribute, topic, value)
|
101
|
+
|
102
|
+
topic_dir = File.join(@filepath, topic)
|
103
|
+
notices = DailyNotices.new topic_dir, @options.merge(identifier: topic)
|
104
|
+
notices.method((attribute.to_s + '=').to_sym).call(value)
|
105
|
+
notices.save
|
106
|
+
|
107
|
+
end
|
74
108
|
|
75
109
|
end
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|