simple_fanout 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +19 -0
- data/lib/simple_fanout.rb +7 -0
- data/lib/simple_fanout/client.rb +43 -0
- metadata +91 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d21e0225588aa263f4fb99664c9f947afdd451b5
|
4
|
+
data.tar.gz: 5f317b0c65e766e10a04000b0d69387ebdf7939f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6ca697f0a9eb96aa1875e65168edf692bd4cc312a62b2cfcbf05f07dd99a12b481783afb91aef427306d0df6ffa4a84c1a927930e0f7c1934844fdd200d72256
|
7
|
+
data.tar.gz: 36a10e07f1329e2edd71ec7b5162f0f2721b73c1b1547e76493bd5aacdcf2bd613b2d9371c550ad50cb01712511b331f1fab8bda0d657f3fd7ca2e45dbf081c1
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2013 SOCIALCHORUS
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
= Simple Fanout: Send Messages to Fanout.io using simple HTTP POST requests
|
2
|
+
|
3
|
+
It's easy!
|
4
|
+
|
5
|
+
> channel = (channel name to publish to)
|
6
|
+
> client = SimpleFanout::Client.new
|
7
|
+
> client.send('jazz hands!')
|
8
|
+
|
9
|
+
Viola!
|
10
|
+
|
11
|
+
Feel free to specify your id, key, or channel when initializing, if you want.
|
12
|
+
|
13
|
+
> client = SimpleFanout::Client.new(id: '123581321', key: 'somekey', channel: 'danceparty')
|
14
|
+
|
15
|
+
Make sure you create a `simple_fanout.yml` file in your config directory that looks something like:
|
16
|
+
|
17
|
+
realm_id: (your Fanout.io id)
|
18
|
+
realm_key: (your Fanout.io id)
|
19
|
+
default_channel: (default channel name)
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module SimpleFanout
|
2
|
+
class Client
|
3
|
+
attr_reader :key, :id, :channel, :token
|
4
|
+
|
5
|
+
def initialize(opts={})
|
6
|
+
@key = opts[:key] || config["realm_key"]
|
7
|
+
@id = opts[:id] || config["realm_id"]
|
8
|
+
@channel = opts[:channel] || config["default_channel"]
|
9
|
+
end
|
10
|
+
|
11
|
+
def token
|
12
|
+
@token ||= "#{JWT.encode(claim, decoded_key)}"
|
13
|
+
end
|
14
|
+
|
15
|
+
def send(data)
|
16
|
+
RestClient.post(url, parse(data),
|
17
|
+
"Content-Type" => "application/json",
|
18
|
+
"Authorization" => "Bearer #{token}")
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def url
|
24
|
+
"https://api.fanout.io/realm/#{id}/publish/#{channel}/"
|
25
|
+
end
|
26
|
+
|
27
|
+
def config
|
28
|
+
@config ||= YAML.load_file('config/simple_fanout.yml')
|
29
|
+
end
|
30
|
+
|
31
|
+
def claim
|
32
|
+
@claim ||= {'iss' => id, 'exp' => Time.now.to_i + 3600}
|
33
|
+
end
|
34
|
+
|
35
|
+
def decoded_key
|
36
|
+
Base64.decode64(key)
|
37
|
+
end
|
38
|
+
|
39
|
+
def parse(data)
|
40
|
+
"{ \"items\": [{ \"fpp\": #{data}}] }"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
metadata
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: simple_fanout
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- SocialChorus
|
8
|
+
- Deepti Anand
|
9
|
+
- Roy Pfaffman
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2014-03-21 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: jwt
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - '>='
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: '0'
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: rest-client
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - '>='
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '0'
|
36
|
+
type: :runtime
|
37
|
+
prerelease: false
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - '>='
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
43
|
+
- !ruby/object:Gem::Dependency
|
44
|
+
name: rspec
|
45
|
+
requirement: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - '>='
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
type: :development
|
51
|
+
prerelease: false
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - '>='
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
57
|
+
description: A simple client for sending http post requests
|
58
|
+
email: developers@socialchorus.com
|
59
|
+
executables: []
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- lib/simple_fanout/client.rb
|
64
|
+
- lib/simple_fanout.rb
|
65
|
+
- MIT-LICENSE
|
66
|
+
- README.rdoc
|
67
|
+
homepage: http://rubygems.org/gems/simple_fanout
|
68
|
+
licenses:
|
69
|
+
- MIT
|
70
|
+
metadata: {}
|
71
|
+
post_install_message:
|
72
|
+
rdoc_options: []
|
73
|
+
require_paths:
|
74
|
+
- lib
|
75
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - '>='
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - '>='
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
requirements: []
|
86
|
+
rubyforge_project:
|
87
|
+
rubygems_version: 2.1.10
|
88
|
+
signing_key:
|
89
|
+
specification_version: 4
|
90
|
+
summary: Fanout.io client!
|
91
|
+
test_files: []
|