mns_subscriber 0.6.0 → 0.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 55df9bad963044ed01313c1c749b43e8ae3d746a9107dbb3bb9c9ff938837f91
4
- data.tar.gz: 706bda2bdeba756c74e945f0b73f810de3c7cadef841f48692e80ca17a53dc8a
3
+ metadata.gz: ba7ffb83b3ae3627fe99ba11f1d3c6ca5b20beadf702ba658bf87a596a877dbb
4
+ data.tar.gz: 5070727cf3f6443a3653edfa9cee25a81fbdb7a91a9253a72a42a8a7fa122ecb
5
5
  SHA512:
6
- metadata.gz: 7ddd48242e49bc872922772f622c4f3f33e32718a8b4e09b880506a9f1b8be3c074428620757e8fa32b2af6db32123846b896019050b80fa412e6e448f784bc5
7
- data.tar.gz: 79b6e558a22ba819116dffac11a1c873a8d5982730f2f0f2159cde9cecd109e673e4c300d4386c4f435f07104215007f5bbc1c405bdaa8713e37b7dda550647f
6
+ metadata.gz: 8773c8013caf65d54f7bb8a75543e5826f47a46c92235f4ea9766ea095f8cdcca4ae256ea9c65e8ef112f597eb8e5c46fb46d25b7a14d016d71630d6216b4fe2
7
+ data.tar.gz: 448558190b8e5082a8226cdf617b7c572a9125c6f57e2d5e9566f31bcc20b06e536ffeb5d1f334275f21cc0b3a1410ceaa1b143f3e26c589e383f3bffe45abf3
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -12,7 +12,7 @@ require 'recordx_sqlite'
12
12
  class MNSSubscriber < SPSSub
13
13
 
14
14
  def initialize(host: 'sps', port: 59000, dir: '.', options: {},
15
- timeline: nil, log: nil)
15
+ timeline: nil, log: nil, hashtag_url: nil)
16
16
 
17
17
  @log = log
18
18
  log.info 'mns_subscriber/initialize: active' if log
@@ -31,6 +31,21 @@ class MNSSubscriber < SPSSub
31
31
  @filepath, @timeline = dir, timeline
32
32
 
33
33
  @index = nil
34
+ @hashtags = nil
35
+
36
+
37
+ if hashtag_url then
38
+
39
+ @hashtag_url = @options[:url_base] + hashtag_url.sub(/^\//,'')
40
+
41
+ hashtag_path = File.join(dir, 'hashtag')
42
+ tagdb = File.join(hashtag_path, 'index.db')
43
+ FileUtils.mkdir_p File.dirname(tagdb)
44
+
45
+ h = {hashtags: {id: '', tag: '', topic: '', noticeid: ''}}
46
+ @hashtags = RecordxSqlite.new(tagdb, table: h )
47
+
48
+ end
34
49
 
35
50
  end
36
51
 
@@ -79,14 +94,15 @@ class MNSSubscriber < SPSSub
79
94
 
80
95
  end
81
96
 
82
- def add_notice(topic, raw_msg, raw_id=Time.now)
97
+ def add_notice(topic, raw_msg, raw_id=nil)
83
98
 
84
99
  @log.info 'mns_subscriber/add_notice: active' if @log
85
100
  topic_dir = File.join(@filepath, topic)
86
101
  notices = DailyNotices.new topic_dir, @options.merge(identifier: topic,
87
102
  title: topic.capitalize + ' daily notices', log: @log)
88
103
 
89
- id = (raw_id || Time.now).to_i
104
+ t = Time.now
105
+ id = (raw_id || t.to_i.to_s + t.strftime("%2N")).to_i
90
106
 
91
107
  # strip out any JSON from the end of the message
92
108
  msg, raw_json = raw_msg.split(/(?=\{.*)/)
@@ -99,6 +115,27 @@ class MNSSubscriber < SPSSub
99
115
  mtlite.to_s
100
116
  end
101
117
 
118
+ if @hashtag_url then
119
+
120
+ tags = desc.scan(/(?<=#)\w+/)
121
+
122
+ desc.gsub!(/#\w+/) do |x|
123
+ "<a href='%s%s'>%s</a>" % [@hashtag_url, x[1..-1], x]
124
+ end
125
+
126
+ # add the record to the database
127
+ tags.each do |tag|
128
+
129
+ t = Time.now
130
+ id2 = (t.to_i.to_s + t.strftime("%2N")).to_i
131
+ h = {id: id2, tag: tag, topic: topic, noticeid: id}
132
+
133
+ @hashtags.create h if @hashtags
134
+
135
+ end
136
+
137
+ end
138
+
102
139
  title = mtlite.to_s.lines.first.chomp
103
140
  title = title[0..136] + ' ...' if title.length > 140
104
141
 
@@ -113,10 +150,10 @@ class MNSSubscriber < SPSSub
113
150
  return if return_status == :duplicate
114
151
 
115
152
  rxnotices = RecordxSqlite.new(File.join(topic_dir, 'notices.db'),
116
- table: {notices: {id: 0, message: ''}})
153
+ table: {notices: {id: 0, description: '', message: ''}})
117
154
 
118
155
  begin
119
- rxnotices.create id: id.to_s, message: msg
156
+ rxnotices.create id: id.to_s, description: desc, message: msg
120
157
  rescue
121
158
  puts 'warning: rxnotices.create -> ' + ($!).inspect
122
159
  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.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -35,7 +35,7 @@ cert_chain:
35
35
  yOAycOYzp7fxmPl3/HV5D0YOJwuy1XslA50GQJwq12A5vMyUGUCHuxH/zKZcM/zr
36
36
  0QZaKiVqq5ZeGvni0eQSavhQ
37
37
  -----END CERTIFICATE-----
38
- date: 2021-02-24 00:00:00.000000000 Z
38
+ date: 2021-02-27 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: mtlite
@@ -101,22 +101,22 @@ dependencies:
101
101
  name: recordx_sqlite
102
102
  requirement: !ruby/object:Gem::Requirement
103
103
  requirements:
104
- - - ">="
105
- - !ruby/object:Gem::Version
106
- version: 0.3.0
107
104
  - - "~>"
108
105
  - !ruby/object:Gem::Version
109
106
  version: '0.3'
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: 0.3.1
110
110
  type: :runtime
111
111
  prerelease: false
112
112
  version_requirements: !ruby/object:Gem::Requirement
113
113
  requirements:
114
- - - ">="
115
- - !ruby/object:Gem::Version
116
- version: 0.3.0
117
114
  - - "~>"
118
115
  - !ruby/object:Gem::Version
119
116
  version: '0.3'
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: 0.3.1
120
120
  description:
121
121
  email: james@jamesrobertson.eu
122
122
  executables: []
metadata.gz.sig CHANGED
Binary file