firebell 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.buildkite/pipeline.yml +6 -0
- data/.gitignore +0 -1
- data/Dockerfile +20 -0
- data/Gemfile.lock +39 -0
- data/docker-compose.yml +2 -0
- data/firebell.gemspec +4 -4
- data/lib/firebell/client.rb +9 -13
- data/lib/firebell/version.rb +1 -1
- data/spec/firebell/client_spec.rb +11 -11
- metadata +8 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e19d89f9d93440ba3bf645efbee32f6b6d38eac1fc6d906ef5401ef248a7b498
|
4
|
+
data.tar.gz: 7f672ca351b30a5f881e2df5ae0ae7930b2766fe17bfe28dc7742ca54718f45a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b738e7d6ccdc58738f33e4bff9c107e012626e903d8e2a7cf4befc67dabb8136159fc0fb3c5e6d8349e3075fbf255693e4c3005bc65901319ef41344a6ce5fe0
|
7
|
+
data.tar.gz: 2254d8964e1ec02ea680059fb7a5b146542c5563317ca8315731116f6a2a4e877a35353ae47e268a2bb0d8ea81ff2596ef3eddd9730d15092620bcbe718e6794
|
data/.gitignore
CHANGED
data/Dockerfile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
FROM ruby:2.5.1
|
2
|
+
LABEL maintainer="x@rubynerd.net"
|
3
|
+
|
4
|
+
RUN bundle config --global frozen 1
|
5
|
+
|
6
|
+
WORKDIR /usr/src/app
|
7
|
+
|
8
|
+
COPY lib/firebell/version.rb lib/firebell/version.rb
|
9
|
+
COPY Gemfile Gemfile.lock firebell.gemspec ./
|
10
|
+
RUN pwd
|
11
|
+
RUN find .
|
12
|
+
RUN echo $PATH
|
13
|
+
RUN find /usr/local/bundle/bin
|
14
|
+
RUN bundle install --verbose
|
15
|
+
|
16
|
+
RUN find /usr/local/bundle/bin
|
17
|
+
|
18
|
+
COPY . .
|
19
|
+
|
20
|
+
CMD ['ruby']
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
firebell (0.3.2)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
diff-lcs (1.3)
|
10
|
+
metaclass (0.0.4)
|
11
|
+
mocha (1.5.0)
|
12
|
+
metaclass (~> 0.0.1)
|
13
|
+
rake (12.3.1)
|
14
|
+
rspec (3.7.0)
|
15
|
+
rspec-core (~> 3.7.0)
|
16
|
+
rspec-expectations (~> 3.7.0)
|
17
|
+
rspec-mocks (~> 3.7.0)
|
18
|
+
rspec-core (3.7.1)
|
19
|
+
rspec-support (~> 3.7.0)
|
20
|
+
rspec-expectations (3.7.0)
|
21
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
22
|
+
rspec-support (~> 3.7.0)
|
23
|
+
rspec-mocks (3.7.0)
|
24
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
25
|
+
rspec-support (~> 3.7.0)
|
26
|
+
rspec-support (3.7.1)
|
27
|
+
|
28
|
+
PLATFORMS
|
29
|
+
ruby
|
30
|
+
|
31
|
+
DEPENDENCIES
|
32
|
+
bundler (~> 1.5)
|
33
|
+
firebell!
|
34
|
+
mocha
|
35
|
+
rake
|
36
|
+
rspec
|
37
|
+
|
38
|
+
BUNDLED WITH
|
39
|
+
1.16.1
|
data/docker-compose.yml
ADDED
data/firebell.gemspec
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'firebell/version'
|
2
|
+
# lib = File.expand_path('../lib', __FILE__)
|
3
|
+
# $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require './lib/firebell/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "firebell"
|
8
8
|
spec.version = Firebell::VERSION
|
9
|
-
spec.authors = ["
|
9
|
+
spec.authors = ["@rubynerd"]
|
10
10
|
spec.email = ["x@rubynerd.net"]
|
11
11
|
spec.summary = %q{Push notifications as a service}
|
12
12
|
spec.description = %q{A ruby client for https://firebellapp.com - push notifications as a service}
|
data/lib/firebell/client.rb
CHANGED
@@ -8,17 +8,10 @@ class Firebell::Client
|
|
8
8
|
@token = token
|
9
9
|
end
|
10
10
|
|
11
|
-
def notify(tag
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
attributes.merge!("body" => body) if body
|
16
|
-
else
|
17
|
-
attributes = { "tag" => tag, "body" => body_or_params }
|
18
|
-
end
|
19
|
-
else
|
20
|
-
attributes = { "tag" => tag }
|
21
|
-
end
|
11
|
+
def notify(tag:, body: nil, params: {})
|
12
|
+
attributes = { tag: tag }
|
13
|
+
attributes.merge!(params: params) if params.any?
|
14
|
+
attributes.merge!(body: body) if body
|
22
15
|
|
23
16
|
send_request attributes if requestable?
|
24
17
|
end
|
@@ -26,12 +19,15 @@ class Firebell::Client
|
|
26
19
|
private
|
27
20
|
def send_request(attrs)
|
28
21
|
if @token
|
29
|
-
request = Net::HTTP::Post.new uri.request_uri, "Authorization" => "Token #{@token}"
|
22
|
+
request = Net::HTTP::Post.new uri.request_uri, "Authorization" => "Token #{@token}", "Content-Type" => "application/json"
|
30
23
|
request.body = JSON.generate attrs
|
31
24
|
|
32
25
|
response = http.request(request)
|
33
|
-
|
26
|
+
|
27
|
+
if response['Content-Type'] == "application/json"
|
34
28
|
JSON.parse response.body
|
29
|
+
else
|
30
|
+
response.body
|
35
31
|
end
|
36
32
|
else
|
37
33
|
raise Firebell::NoTokenError
|
data/lib/firebell/version.rb
CHANGED
@@ -16,35 +16,35 @@ describe Firebell::Client do
|
|
16
16
|
|
17
17
|
context "with a tag and body" do
|
18
18
|
it "makes a request" do
|
19
|
-
Firebell::Client.any_instance.expects(:send_request).with(
|
20
|
-
client.notify "test.subject", "hello"
|
19
|
+
Firebell::Client.any_instance.expects(:send_request).with(tag: "test.subject", body: "hello")
|
20
|
+
client.notify tag: "test.subject", body: "hello"
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
24
|
context "with a tag and parameters" do
|
25
25
|
it "makes a request" do
|
26
26
|
Firebell::Client.any_instance.expects(:send_request)
|
27
|
-
.with(
|
27
|
+
.with(tag: "test.subject", params: { "p1" => 1 })
|
28
28
|
|
29
|
-
client.notify "test.subject", "p1" => 1
|
29
|
+
client.notify tag: "test.subject", params: { "p1" => 1 }
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
33
|
context "with a tag, parameters, and body" do
|
34
34
|
it "makes a request" do
|
35
35
|
Firebell::Client.any_instance.expects(:send_request)
|
36
|
-
.with(
|
36
|
+
.with(tag: "test.subject", params: { "p1" => 1 }, body: "hello")
|
37
37
|
|
38
|
-
client.notify "test.subject", { "p1" => 1 }, "hello"
|
38
|
+
client.notify tag: "test.subject", params: { "p1" => 1 }, body: "hello"
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
42
|
context "with just a tag" do
|
43
43
|
it "makes a request" do
|
44
44
|
Firebell::Client.any_instance.expects(:send_request)
|
45
|
-
.with(
|
45
|
+
.with(tag: "test.subject")
|
46
46
|
|
47
|
-
client.notify "test.subject"
|
47
|
+
client.notify tag: "test.subject"
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
@@ -57,9 +57,9 @@ describe Firebell::Client do
|
|
57
57
|
|
58
58
|
it "makes a request" do
|
59
59
|
Firebell::Client.any_instance.expects(:send_request)
|
60
|
-
.with(
|
60
|
+
.with(tag: "test.subject")
|
61
61
|
|
62
|
-
client.notify "test.subject"
|
62
|
+
client.notify tag: "test.subject"
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
@@ -72,7 +72,7 @@ describe Firebell::Client do
|
|
72
72
|
it "makes a request" do
|
73
73
|
Firebell::Client.any_instance.expects(:send_request).never
|
74
74
|
|
75
|
-
client.notify "test.subject"
|
75
|
+
client.notify tag: "test.subject"
|
76
76
|
end
|
77
77
|
end
|
78
78
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: firebell
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- "@rubynerd"
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-05-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -73,12 +73,16 @@ executables: []
|
|
73
73
|
extensions: []
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
|
+
- ".buildkite/pipeline.yml"
|
76
77
|
- ".gitignore"
|
77
78
|
- ".rspec"
|
79
|
+
- Dockerfile
|
78
80
|
- Gemfile
|
81
|
+
- Gemfile.lock
|
79
82
|
- LICENSE.txt
|
80
83
|
- README.md
|
81
84
|
- Rakefile
|
85
|
+
- docker-compose.yml
|
82
86
|
- env.rb
|
83
87
|
- firebell.gemspec
|
84
88
|
- lib/firebell.rb
|
@@ -108,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
108
112
|
version: '0'
|
109
113
|
requirements: []
|
110
114
|
rubyforge_project:
|
111
|
-
rubygems_version: 2.
|
115
|
+
rubygems_version: 2.7.6
|
112
116
|
signing_key:
|
113
117
|
specification_version: 4
|
114
118
|
summary: Push notifications as a service
|