mns_subscriber 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f0e9cbe2f58e193cdb32c69c14ab4b4e1cf9da51
4
- data.tar.gz: 21cbea14ae6dc360fc4e1dfb2dce3a723a9bac70
3
+ metadata.gz: 8dec7b2b661610d050fb0385766c6df3ce134cce
4
+ data.tar.gz: 15a9d63f0edf6c95b99456bc673c73b2b5726bdd
5
5
  SHA512:
6
- metadata.gz: f0ea0b5fd78320bf0f5c02cdc5ba5acf444ce4444de927c5b020b6216f95b2473396087a92670dae9616df2d7aa589a2da65643e4389cf2ce7dfd412bb3a78a6
7
- data.tar.gz: e52fcee1b3784ef98559dc6cebf13aea5db36a18150e4698ca2da6cd83f2a1baf4a7804c734084152da4307d19ab905a106cd387971d5ee41457ad4c1f444598
6
+ metadata.gz: 57ea1ce811ca86cca2e08729a704aa102e15d133614306bcae73dd323582d104f06ecf1d75fa70526b607f69f34bfd9fd5f6dd1a6f9f60c295424d944002b2fb
7
+ data.tar.gz: 8aef5909737bfb7d3f2512eceb478c2a804bf8513a143b7b8f5a60546aac1a35e6c32cfe9f10fa93522ec80077fd3448c8c526b35f8090ad7517a6bc81d5e914
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -36,22 +36,48 @@ class MNSSubscriber < SPSSub
36
36
 
37
37
  def ontopic(topic, msg)
38
38
 
39
- subtopic = topic.split('/').last
39
+ a = topic.split('/')
40
40
  puts "%s: %s %s" % [topic, Time.now.to_s, msg.inspect]
41
-
42
- add_notice(subtopic, msg)
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
- filename = File.join(topic_dir, 'feed.xml')
69
+ notices = DailyNotices.new topic_dir, @options.merge(identifier: topic)
50
70
 
51
- db = SQLite3::Database.new File.join(topic_dir, topic + '.db')
71
+ dbfilename = File.join(topic_dir, topic + '.db')
52
72
 
53
- unless File.exists? filename then
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
@@ -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.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
metadata.gz.sig CHANGED
Binary file