pubcontrol 1.0.3 → 1.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2b9cbc03efff0d5b151b06fe26ae636a3bd2b051
4
- data.tar.gz: 080f28bded46f251eaf25d259f3628c6142759bc
3
+ metadata.gz: a8535c6bdbb6bfd0abeb75b7dc08a4d561bb679b
4
+ data.tar.gz: 9f019cc934e4cebdd07d84b7f662503eb44d1661
5
5
  SHA512:
6
- metadata.gz: 35d714d4f918aadfd8ce7b59be9f66a98e1a1a85344e284e55185db13ea2330063c31af682fcb67b672a4ddc56d19433b3e8b734d0ec4373170551a813d01334
7
- data.tar.gz: cb0649c9d4ad939ab10daedcf68783a0f0e1d08f0d977846ae01a55cd8169511ab183d22a18d53ce110a69b8dc72e697fc6f642e77dbd0d2d718985725a5573d
6
+ metadata.gz: f159d79255a34f0969f4ad71a9e00ec29518ec7e743298e35023b4037e91782e613fea8fc2bada8ff90475b0306841f207c39565523c8a43e58feff2bfadff00
7
+ data.tar.gz: 6eef70a1cb4d6049218dc5d69347b74c85e200a9d563ca33a6cf7b44605d2db9f446d5b755dfca59767c675a94cfb0d30c1e6a785f864877ef43cfc275284adf
data/lib/pubcontrol.rb CHANGED
@@ -64,27 +64,27 @@ class PubControl
64
64
  end
65
65
 
66
66
  # The synchronous publish method for publishing the specified item to the
67
- # specified channel for all of the configured PubControlClient instances.
68
- def publish(channel, item)
67
+ # specified channels for all of the configured PubControlClient instances.
68
+ def publish(channels, item)
69
69
  @clients.each do |pub|
70
- pub.publish(channel, item)
70
+ pub.publish(channels, item)
71
71
  end
72
72
  end
73
73
 
74
74
  # The asynchronous publish method for publishing the specified item to the
75
- # specified channel on the configured endpoint. The callback method is
75
+ # specified channels on the configured endpoint. The callback method is
76
76
  # optional and will be passed the publishing results after publishing is
77
77
  # complete. Note that a failure to publish in any of the configured
78
78
  # PubControlClient instances will result in a failure result being passed
79
79
  # to the callback method along with the first encountered error message.
80
- def publish_async(channel, item, callback=nil)
80
+ def publish_async(channels, item, callback=nil)
81
81
  cb = nil
82
82
  if !callback.nil?
83
83
  cb = PubControlClientCallbackHandler.new(@clients.length, callback).
84
84
  handler_method_symbol
85
85
  end
86
86
  @clients.each do |pub|
87
- pub.publish_async(channel, item, cb)
87
+ pub.publish_async(channels, item, cb)
88
88
  end
89
89
  end
90
90
  end
@@ -55,34 +55,40 @@ class PubControlClient
55
55
  end
56
56
 
57
57
  # The synchronous publish method for publishing the specified item to the
58
- # specified channel on the configured endpoint.
59
- def publish(channel, item)
60
- export = item.export
61
- export['channel'] = channel
62
- uri = nil
63
- auth = nil
58
+ # specified channels on the configured endpoint.
59
+ def publish(channels, item)
60
+ exports = [channels].flatten.map do |channel|
61
+ export = item.export
62
+ export['channel'] = channel
63
+ export
64
+ end
65
+ uri = nil
66
+ auth = nil
64
67
  @lock.synchronize do
65
- uri = @uri
66
- auth = gen_auth_header
68
+ uri = @uri
69
+ auth = gen_auth_header
67
70
  end
68
- pubcall(uri, auth, [export])
71
+ pubcall(uri, auth, exports)
69
72
  end
70
73
 
71
74
  # The asynchronous publish method for publishing the specified item to the
72
- # specified channel on the configured endpoint. The callback method is
75
+ # specified channels on the configured endpoint. The callback method is
73
76
  # optional and will be passed the publishing results after publishing is
74
77
  # complete.
75
- def publish_async(channel, item, callback=nil)
76
- export = item.export
77
- export['channel'] = channel
78
- uri = nil
79
- auth = nil
78
+ def publish_async(channels, item, callback=nil)
79
+ exports = [channels].flatten.map do |channel|
80
+ export = item.export
81
+ export['channel'] = channel
82
+ export
83
+ end
84
+ uri = nil
85
+ auth = nil
80
86
  @lock.synchronize do
81
- uri = @uri
82
- auth = gen_auth_header
87
+ uri = @uri
88
+ auth = gen_auth_header
83
89
  ensure_thread
84
90
  end
85
- queue_req(['pub', uri, auth, export, callback])
91
+ queue_req(['pub', uri, auth, exports, callback])
86
92
  end
87
93
 
88
94
  # The finish method is a blocking method that ensures that all asynchronous
@@ -149,7 +155,11 @@ class PubControlClient
149
155
  items = Array.new
150
156
  callbacks = Array.new
151
157
  reqs.each do |req|
152
- items.push(req[2])
158
+ if req[2].is_a? Array
159
+ items = items + req[2]
160
+ else
161
+ items.push(req[2])
162
+ end
153
163
  callbacks.push(req[3])
154
164
  end
155
165
  begin
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pubcontrol
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Konstantin Bokarius
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-12 00:00:00.000000000 Z
11
+ date: 2015-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: algorithms