sps-pub 0.2.0 → 0.3.0

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: 22e572252f6a6dc79784c6c202a10403778a1003
4
- data.tar.gz: cd72e1257576f90d9e7b0eac6ca1cd6f3f3fbace
3
+ metadata.gz: d122d08cef7d23819d053ec58d3cea09d2d627d5
4
+ data.tar.gz: 1e8ad0b8e022b9cc7b10f7a57a1dd76fa89bcb02
5
5
  SHA512:
6
- metadata.gz: 9c721d487e4d48afb1fa8cb4cec7ec83ddd00cc3db8a15da06110a76fd4e7b546dbe4244c587b495e77c94e17ce98c49a13be3b9d9d11264a14749e93a223c99
7
- data.tar.gz: 051752b774310b1240bd320b9d01f95e65ccaf31f33dc0cb6b08856b8c2b86edba0554583c124584d9eb1ad26ce87d3304b0ff05df9fa6720cf2d75bfbfdecef
6
+ metadata.gz: 870c57fcb6d1beddaf4e6a84c755b4a328170927faea14fc267c9c5d9b6c4933f736295606ab1dd9aaa92482d7c25d358adf721b5b98f14e6f4b4952a79fbd0d
7
+ data.tar.gz: 1b6de1935c4cba6ea909e94ad7d83af3fb3f3c565b0aa1841a567dff422a2c18a84ad5172a53bb243abaa02f9dbab0fa53bbbf344cf007eb3789e05f59c40bd4
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/sps-pub.rb CHANGED
@@ -3,31 +3,40 @@
3
3
  # file: sps-pub.rb
4
4
 
5
5
  require 'simplepubsub'
6
+ require 'ws' # from gem 'simpleblockingwebsocketclient'
7
+
8
+
6
9
 
7
10
  class SPSPub
8
11
  include SimplePubSub
9
12
 
10
- def self.notice(s,sps_address='sps',port='59000')
13
+ def self.notice(s, address: 'sps', port: '59000')
11
14
 
12
- topic, msg = s.split(/:\s*/,2)
15
+ client = Net::WS.new "ws://%s:%s/" % [address, port]
16
+ client.send s
17
+ end
13
18
 
14
- Client.connect(sps_address, port, options={}) do |client|
19
+ def self.pub(s, address: 'sps', port: '59000')
20
+ self.notice(s, address: 'sps', port: '59000')
21
+ end
15
22
 
16
- opt = {stay_connected: false}.merge options
17
- puts "about to publish : topic: %s msg: %s" % [topic, msg]
18
- client.publish(topic, msg)
19
- :stop if opt[:stay_connected] == false
20
- end
21
-
23
+ def self.publish(s, address: 'sps', port: '59000')
24
+ self.notice(s, address: 'sps', port: '59000')
22
25
  end
26
+
23
27
 
24
- def self.listen(topic='#', sps_address='sps')
28
+ def self.listen(topic='#', address: 'sps')
25
29
 
26
- Client.connect(sps_address) do |client|
30
+ Client.connect(address) do |client|
27
31
  client.get(topic) do |topic, message|
28
32
  puts "[%s] SPS listener INFO %s: %s" %
29
33
  [Time.now.strftime("%Y-%m-%d %H:%M"), topic, message]
30
34
  end
31
35
  end
36
+ end
37
+
38
+ def self.subscribe(topic='#', address: 'sps')
39
+ self.listen(topic='#', address: 'sps')
32
40
  end
41
+
33
42
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sps-pub
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -31,7 +31,7 @@ cert_chain:
31
31
  2cSEZ0QYbEwC3czzwEism6iYWhlBI/srC6g8JIr7pq91FybciqI5dk5RB7SE5Xgf
32
32
  p7uZNkO8qc9/fg==
33
33
  -----END CERTIFICATE-----
34
- date: 2013-11-21 00:00:00.000000000 Z
34
+ date: 2014-05-22 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: simplepubsub
@@ -47,6 +47,20 @@ dependencies:
47
47
  - - ">="
48
48
  - !ruby/object:Gem::Version
49
49
  version: '0'
50
+ - !ruby/object:Gem::Dependency
51
+ name: simpleblockingwebsocketclient
52
+ requirement: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ type: :runtime
58
+ prerelease: false
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
50
64
  description:
51
65
  email: james@r0bertson.co.uk
52
66
  executables: []
@@ -74,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
88
  version: '0'
75
89
  requirements: []
76
90
  rubyforge_project:
77
- rubygems_version: 2.0.0.rc.2
91
+ rubygems_version: 2.1.11
78
92
  signing_key:
79
93
  specification_version: 4
80
94
  summary: A SimplePubSub client for publishing or subscribing to messages in 1 line
metadata.gz.sig CHANGED
Binary file