mns_subscriber 0.1.0 → 0.2.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 +23 -27
- data.tar.gz.sig +0 -0
- metadata +6 -6
- 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: f0e9cbe2f58e193cdb32c69c14ab4b4e1cf9da51
|
4
|
+
data.tar.gz: 21cbea14ae6dc360fc4e1dfb2dce3a723a9bac70
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0ea0b5fd78320bf0f5c02cdc5ba5acf444ce4444de927c5b020b6216f95b2473396087a92670dae9616df2d7aa589a2da65643e4389cf2ce7dfd412bb3a78a6
|
7
|
+
data.tar.gz: e52fcee1b3784ef98559dc6cebf13aea5db36a18150e4698ca2da6cd83f2a1baf4a7804c734084152da4307d19ab905a106cd387971d5ee41457ad4c1f444598
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/mns_subscriber.rb
CHANGED
@@ -4,17 +4,27 @@
|
|
4
4
|
|
5
5
|
|
6
6
|
require 'sps-sub'
|
7
|
-
require 'dynarex'
|
8
7
|
require "sqlite3"
|
9
8
|
require 'fileutils'
|
9
|
+
require 'daily_notices'
|
10
10
|
|
11
11
|
|
12
12
|
class MNSSubscriber < SPSSub
|
13
13
|
|
14
|
-
def initialize(host: 'sps', port: 59000, dir: '.',
|
14
|
+
def initialize(host: 'sps', port: 59000, dir: '.', options: {})
|
15
|
+
|
16
|
+
# note: a valid url_base must be provided
|
17
|
+
|
18
|
+
@options = {
|
19
|
+
url_base: 'http://yourwebsitehere.co.uk/',
|
20
|
+
dx_xslt: '/xsl/dynarex.xsl',
|
21
|
+
rss_xslt: '/xsl/feed.xsl',
|
22
|
+
target_page: :page,
|
23
|
+
target_xslt: '/xsl/page.xsl'
|
24
|
+
}.merge(options)
|
15
25
|
|
16
26
|
super(host: host, port: port)
|
17
|
-
@filepath
|
27
|
+
@filepath = dir
|
18
28
|
|
19
29
|
end
|
20
30
|
|
@@ -36,44 +46,30 @@ class MNSSubscriber < SPSSub
|
|
36
46
|
def add_notice(topic, msg)
|
37
47
|
|
38
48
|
topic_dir = File.join(@filepath, topic)
|
39
|
-
filename = File.join(topic_dir,
|
49
|
+
filename = File.join(topic_dir, 'feed.xml')
|
40
50
|
|
41
51
|
db = SQLite3::Database.new File.join(topic_dir, topic + '.db')
|
42
52
|
|
43
|
-
|
44
|
-
|
45
|
-
Dynarex.new(filename)
|
46
|
-
|
47
|
-
|
48
|
-
else
|
49
|
-
|
50
|
-
FileUtils.mkdir_p File.dirname(filename)
|
51
|
-
dx = Dynarex.new('notices[identity]/notice(message)')
|
52
|
-
dx.identity = topic
|
53
|
-
dx.xslt = @timeline_xsl if @timeline_xsl
|
54
|
-
|
55
|
-
|
53
|
+
unless File.exists? filename then
|
54
|
+
|
56
55
|
db.execute <<-SQL
|
57
56
|
create table notices (
|
58
57
|
ID INT PRIMARY KEY NOT NULL,
|
59
58
|
MESSAGE TEXT
|
60
59
|
);
|
61
60
|
SQL
|
62
|
-
|
63
|
-
dx
|
64
|
-
|
61
|
+
|
65
62
|
end
|
63
|
+
|
66
64
|
|
67
|
-
id = Time.now.to_i
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
puts "%s: saved file %s" % [Time.now, filename]
|
65
|
+
id = Time.now.to_i.to_s
|
66
|
+
|
67
|
+
notices = DailyNotices.new topic_dir, @options.merge(identifier: topic)
|
68
|
+
notices.add msg, id: id
|
72
69
|
|
73
70
|
db.execute("INSERT INTO notices (id, message)
|
74
71
|
VALUES (?, ?)", [id, msg])
|
75
72
|
|
76
73
|
end
|
77
74
|
|
78
|
-
end
|
79
|
-
|
75
|
+
end
|
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.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -54,25 +54,25 @@ dependencies:
|
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: 0.4.3
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
|
-
name:
|
57
|
+
name: daily_notices
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
60
|
- - "~>"
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version: '
|
62
|
+
version: '0.4'
|
63
63
|
- - ">="
|
64
64
|
- !ruby/object:Gem::Version
|
65
|
-
version:
|
65
|
+
version: 0.4.3
|
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: '
|
72
|
+
version: '0.4'
|
73
73
|
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 0.4.3
|
76
76
|
- !ruby/object:Gem::Dependency
|
77
77
|
name: sqlite3
|
78
78
|
requirement: !ruby/object:Gem::Requirement
|
metadata.gz.sig
CHANGED
Binary file
|