fanout 1.1.2 → 1.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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/fanout.rb +11 -29
  3. metadata +5 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c00a6654cc9a1afe647949d47e308e7e26a9cd3c
4
- data.tar.gz: 779264dc8a6f2b90ee91ee53b4bcf91a12f15c49
3
+ metadata.gz: 857315e0ee2081c96c072f6295f9ee58086e459a
4
+ data.tar.gz: 8adf56221d8a4f10a3d531476979e10ee68fe137
5
5
  SHA512:
6
- metadata.gz: 6dc3caeb96825aa789e7493abe3a06c5d56412703aeb09b7c3a443d5bb53c4416c3e4f39ca9e2da10f6732b2e8047a13cf74e5d10c3720b1834908e54aeb36b6
7
- data.tar.gz: 2f030df94aa915a6c5f2a55e52d6929e72a45206163c00a2cb38b941bfc0d7ed6c14c3daf7faf8654590bd162788ec7d03630a032e0422b30090ce49c525fe51
6
+ metadata.gz: 97faeda87ee4be778929ca6a26331ee2badb2c13e6fa88519422eaf67a8125a984c0362dc72305aa8c1ef7cc375450f7cb2ecedec5c0be53fd727a50f34504c4
7
+ data.tar.gz: 577ada5bd31f10ab24f1c75df2e6808d8dd65828422c04c404e6c61722061f38cc31e09a8efc38b8429e3231f6cda01d5460eb66da8e736e0467edc56c21c54e
data/lib/fanout.rb CHANGED
@@ -2,7 +2,7 @@
2
2
  # ~~~~~~~~~
3
3
  # This module implements the Fanout class.
4
4
  # :authors: Konstantin Bokarius.
5
- # :copyright: (c) 2015 by Fanout, Inc.
5
+ # :copyright: (c) 2015-2016 by Fanout, Inc.
6
6
  # :license: MIT, see LICENSE for more details.
7
7
 
8
8
  require 'base64'
@@ -30,17 +30,21 @@ class Fanout
30
30
  if key.nil?
31
31
  key = ENV['FANOUT_KEY']
32
32
  end
33
- @realm = realm
34
- @key = key
35
- @ssl = ssl
33
+ if ssl
34
+ scheme = 'https'
35
+ else
36
+ scheme = 'http'
37
+ end
38
+ uri = '%s://api.fanout.io/realm/%s' % [scheme, realm]
39
+ @pub = PubControl.new({'uri' => uri, 'iss' => realm,
40
+ 'key' => Base64.decode64(key)})
36
41
  end
37
42
 
38
43
  # Synchronously publish the specified data to the specified channel for
39
44
  # the configured Fanout.io realm. Optionally provide an ID and previous
40
45
  # ID to send along with the message.
41
46
  def publish(channel, data, id=nil, prev_id=nil)
42
- pub = get_pubcontrol
43
- pub.publish(channel, Item.new(JsonObjectFormat.new(data), id, prev_id))
47
+ @pub.publish(channel, Item.new(JsonObjectFormat.new(data), id, prev_id))
44
48
  end
45
49
 
46
50
  # Asynchronously publish the specified data to the specified channel for
@@ -49,29 +53,7 @@ class Fanout
49
53
  # called after publishing is complete and passed the result and error message
50
54
  # if an error was encountered.
51
55
  def publish_async(channel, data, id=nil, prev_id=nil, callback=nil)
52
- pub = get_pubcontrol
53
- pub.publish_async(channel, Item.new(JsonObjectFormat.new(data), id,
56
+ @pub.publish_async(channel, Item.new(JsonObjectFormat.new(data), id,
54
57
  prev_id), callback)
55
58
  end
56
-
57
- private
58
-
59
- # An internal method used for retrieving the PubControl instance. The
60
- # PubControl instance is saved as a thread variable and if an instance
61
- # is not available when this method is called then one will be created.
62
- def get_pubcontrol
63
- if Thread.current['pubcontrol'].nil?
64
- if @ssl
65
- scheme = 'https'
66
- else
67
- scheme = 'http'
68
- end
69
- pub = PubControlClient.new(
70
- '%s://api.fanout.io/realm/%s' % [scheme, @realm])
71
- pub.set_auth_jwt({'iss' => @realm}, Base64.decode64(@key))
72
- at_exit { pub.finish }
73
- Thread.current['pubcontrol'] = pub
74
- end
75
- return Thread.current['pubcontrol']
76
- end
77
59
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fanout
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.2.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: 2016-07-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pubcontrol
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1'
19
+ version: '1.2'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1'
26
+ version: '1.2'
27
27
  description: A Ruby convenience library for publishing messages to Fanout.io using
28
28
  the EPCP protocol
29
29
  email: bokarius@comcast.net
@@ -53,7 +53,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
53
53
  version: '0'
54
54
  requirements: []
55
55
  rubyforge_project:
56
- rubygems_version: 2.2.2
56
+ rubygems_version: 2.4.5
57
57
  signing_key:
58
58
  specification_version: 4
59
59
  summary: Fanout.io library for Ruby