fanout 0.0.2
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 +7 -0
- data/lib/fanout.rb +45 -0
- data/lib/fppformat.rb +21 -0
- metadata +46 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: cd497cbca684f7058c6d2bb90d75f51044064a58
|
4
|
+
data.tar.gz: f1af6037a48edb0c0e99921ae233488274369ee2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 23bc22f515eb0dd09c99dd4cd4093e16b5c82586bf0660384690a45f8e14b756ad773b2549f57344961660d909432ef6b36bc26ed66bdc1b312ba13f61b8827f
|
7
|
+
data.tar.gz: ad362207f7ff0ad5d07bf67f9478f9b752ecad7dd29d0a5a73896ffa02a95d652ad13d419db436df81e8b2aa09be41742b7f4a9f18684d9aed919994a2f03511
|
data/lib/fanout.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# fanout.rb
|
2
|
+
# ~~~~~~~~~
|
3
|
+
# This module implements the Fanout class.
|
4
|
+
# :copyright: (c) 2014 by Konstantin Bokarius.
|
5
|
+
# :license: MIT, see LICENSE for more details.
|
6
|
+
|
7
|
+
require 'base64'
|
8
|
+
require 'thread'
|
9
|
+
require 'pubcontrol'
|
10
|
+
require_relative 'fppformat.rb'
|
11
|
+
|
12
|
+
class Fanout
|
13
|
+
def initialize(realm, key, ssl=true)
|
14
|
+
@realm = realm
|
15
|
+
@key = key
|
16
|
+
@ssl = ssl
|
17
|
+
end
|
18
|
+
|
19
|
+
def publish(channel, data, id=nil, prev_id=nil)
|
20
|
+
pub = get_pubcontrol
|
21
|
+
pub.publish(channel, Item.new(FppFormat.new(data), id, prev_id))
|
22
|
+
end
|
23
|
+
|
24
|
+
def publish_async(channel, data, id=nil, prev_id=nil, callback=nil)
|
25
|
+
pub = get_pubcontrol
|
26
|
+
pub.publish_async(channel, Item.new(FppFormat.new(data), id, prev_id),
|
27
|
+
callback)
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def get_pubcontrol
|
33
|
+
if Thread.current.thread_variable_get('pubcontrol').nil?
|
34
|
+
if @ssl
|
35
|
+
scheme = 'https'
|
36
|
+
else
|
37
|
+
scheme = 'http'
|
38
|
+
end
|
39
|
+
pub = PubControl.new('%s://api.fanout.io/realm/%s' % [scheme, @realm])
|
40
|
+
pub.set_auth_jwt({'iss' => @realm}, Base64.decode64(@key))
|
41
|
+
Thread.current.thread_variable_set('pubcontrol', pub)
|
42
|
+
end
|
43
|
+
return Thread.current.thread_variable_get('pubcontrol')
|
44
|
+
end
|
45
|
+
end
|
data/lib/fppformat.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# fppformat.rb
|
2
|
+
# ~~~~~~~~~
|
3
|
+
# This module implements the FppFormat class.
|
4
|
+
# :copyright: (c) 2014 by Konstantin Bokarius.
|
5
|
+
# :license: MIT, see LICENSE for more details.
|
6
|
+
|
7
|
+
require 'pubcontrol'
|
8
|
+
|
9
|
+
class FppFormat < Format
|
10
|
+
def initialize(value)
|
11
|
+
@value = value
|
12
|
+
end
|
13
|
+
|
14
|
+
def name
|
15
|
+
return 'fpp'
|
16
|
+
end
|
17
|
+
|
18
|
+
def export
|
19
|
+
return @value
|
20
|
+
end
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fanout
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Konstantin Bokarius
|
8
|
+
- Justin Karneges
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2015-01-02 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: A Ruby implementation for publishing FPP messages
|
15
|
+
email: bokarius@comcast.net
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- lib/fanout.rb
|
21
|
+
- lib/fppformat.rb
|
22
|
+
homepage: http://rubygems.org/gems/fanout
|
23
|
+
licenses:
|
24
|
+
- MIT
|
25
|
+
metadata: {}
|
26
|
+
post_install_message:
|
27
|
+
rdoc_options: []
|
28
|
+
require_paths:
|
29
|
+
- lib
|
30
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
requirements: []
|
41
|
+
rubyforge_project:
|
42
|
+
rubygems_version: 2.2.2
|
43
|
+
signing_key:
|
44
|
+
specification_version: 4
|
45
|
+
summary: Fanout.io library for Ruby
|
46
|
+
test_files: []
|