mns_subscriber 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/mns_subscriber.rb +79 -0
- metadata +128 -0
- metadata.gz.sig +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ca77015ce38d49cdc27af18af56f46fc9ce99885
|
4
|
+
data.tar.gz: 340b37d63262515928f6eab9ed3dd0a7c27de8ac
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bb10f5289a892366dcacce14a1fc7252e0c93b42bc11303b148f4c15d327a69164fd6a848af276099c41c89b62bcc60b7491c6811fb69ffc07519928a9185053
|
7
|
+
data.tar.gz: e33851e9f53ce5596621923bc3858e1032704018448d8c7d70e4d3fa2587850dd917b7e956d20f87426a5eb88bcc0f0c59175f89874eb27094a24b2aa90a7be8
|
checksums.yaml.gz.sig
ADDED
Binary file
|
data.tar.gz.sig
ADDED
Binary file
|
@@ -0,0 +1,79 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# file: mns_subscriber.rb
|
4
|
+
|
5
|
+
|
6
|
+
require 'sps-sub'
|
7
|
+
require 'dynarex'
|
8
|
+
require "sqlite3"
|
9
|
+
require 'fileutils'
|
10
|
+
|
11
|
+
|
12
|
+
class MNSSubscriber < SPSSub
|
13
|
+
|
14
|
+
def initialize(host: 'sps', port: 59000, dir: '.', timeline_xsl: nil)
|
15
|
+
|
16
|
+
super(host: host, port: port)
|
17
|
+
@filepath, @timeline_xsl = dir, timeline_xsl
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
def subscribe(topic='notice/*')
|
22
|
+
super(topic)
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def ontopic(topic, msg)
|
28
|
+
|
29
|
+
subtopic = topic.split('/').last
|
30
|
+
puts "%s: %s %s" % [topic, Time.now.to_s, msg.inspect]
|
31
|
+
|
32
|
+
add_notice(subtopic, msg)
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
def add_notice(topic, msg)
|
37
|
+
|
38
|
+
topic_dir = File.join(@filepath, topic)
|
39
|
+
filename = File.join(topic_dir, topic + '.xml')
|
40
|
+
|
41
|
+
db = SQLite3::Database.new File.join(topic_dir, topic + '.db')
|
42
|
+
|
43
|
+
dx = if File.exists? filename then
|
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
|
+
|
56
|
+
db.execute <<-SQL
|
57
|
+
create table notices (
|
58
|
+
ID INT PRIMARY KEY NOT NULL,
|
59
|
+
MESSAGE TEXT
|
60
|
+
);
|
61
|
+
SQL
|
62
|
+
|
63
|
+
dx
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
id = Time.now.to_i
|
68
|
+
dx.create message: msg, id: id
|
69
|
+
|
70
|
+
dx.save filename
|
71
|
+
puts "%s: saved file %s" % [Time.now, filename]
|
72
|
+
|
73
|
+
db.execute("INSERT INTO notices (id, message)
|
74
|
+
VALUES (?, ?)", [id, msg])
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
|
metadata
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mns_subscriber
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- James Robertson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIDljCCAn6gAwI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U54nK2e45U0Q
|
28
|
+
tw6jmHbp+1gfXuul+tVro6wZ/M1WBiotQfgzEPAtMENm/Jqs5BqUsa/BQwzRBBjM
|
29
|
+
EychMLNZt6rP/b1sOZ3RODk3OsZ0whwMBzNNR/h20qnAd0q5Y6I++xHFoW2mwjJ7
|
30
|
+
NLA6oOgvCF/KXGNlj7vHzhzzWsFGlEIawFhzvbQ9C4eJoAwFSrrzH+RvD1sMpq2Y
|
31
|
+
wBAv1HG6hlSk9BepsW4e+NbsgNYQdx0NkPtppfh502tww8DydLyWZNnEte5tAbjg
|
32
|
+
mBoofo/5xUxN5A==
|
33
|
+
-----END CERTIFICATE-----
|
34
|
+
date: 2016-11-12 00:00:00.000000000 Z
|
35
|
+
dependencies:
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: sps-sub
|
38
|
+
requirement: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - "~>"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0.4'
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 0.4.3
|
46
|
+
type: :runtime
|
47
|
+
prerelease: false
|
48
|
+
version_requirements: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - "~>"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0.4'
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 0.4.3
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: dynarex
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '1.7'
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: 1.7.15
|
66
|
+
type: :runtime
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - "~>"
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '1.7'
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 1.7.15
|
76
|
+
- !ruby/object:Gem::Dependency
|
77
|
+
name: sqlite3
|
78
|
+
requirement: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.3'
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 1.3.12
|
86
|
+
type: :runtime
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - "~>"
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '1.3'
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: 1.3.12
|
96
|
+
description:
|
97
|
+
email: james@r0bertson.co.uk
|
98
|
+
executables: []
|
99
|
+
extensions: []
|
100
|
+
extra_rdoc_files: []
|
101
|
+
files:
|
102
|
+
- lib/mns_subscriber.rb
|
103
|
+
homepage: https://github.com/jrobertson/mns_subscriber
|
104
|
+
licenses:
|
105
|
+
- MIT
|
106
|
+
metadata: {}
|
107
|
+
post_install_message:
|
108
|
+
rdoc_options: []
|
109
|
+
require_paths:
|
110
|
+
- lib
|
111
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - ">="
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
requirements: []
|
122
|
+
rubyforge_project:
|
123
|
+
rubygems_version: 2.5.1
|
124
|
+
signing_key:
|
125
|
+
specification_version: 4
|
126
|
+
summary: Creates microblog posts from different identities by subscribing to the SPS
|
127
|
+
topic 'notices/*' by default.
|
128
|
+
test_files: []
|
metadata.gz.sig
ADDED
Binary file
|