firebell 0.1.3 → 0.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.
- checksums.yaml +4 -4
- data/lib/firebell/client.rb +10 -3
- data/lib/firebell/version.rb +1 -1
- data/lib/firebell.rb +5 -2
- data/spec/firebell/client_spec.rb +28 -0
- data/spec/firebell/configuration_spec.rb +0 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 202311c076b2651523fbf9579ffdf9577b2f33c4
|
4
|
+
data.tar.gz: 8eb21252cfcf79d973997a600c93a77efa439dbc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 438aff20a6ee4948409e48dc6178e08135032985d4988a0b425127172655bd1bb1071b677a2f79611239726ed84d9b4f11fe2a307cb18c56ecc7641f02a6bbc6
|
7
|
+
data.tar.gz: 47d5be5aca2f1a631a1d3aa7dc02568de7fbcb900000626ad183d8cae95602bb1538b89af5ccb453d4fc6dabae59f98b738a57c44837ebb2d76db2f8327d63a2
|
data/lib/firebell/client.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require "net/http"
|
2
|
-
require "json"
|
3
2
|
|
4
3
|
class Firebell::Client
|
5
4
|
attr_accessor :token
|
@@ -20,13 +19,13 @@ class Firebell::Client
|
|
20
19
|
attributes = { "tag" => tag }
|
21
20
|
end
|
22
21
|
|
23
|
-
send_request attributes
|
22
|
+
send_request attributes if requestable?
|
24
23
|
end
|
25
24
|
|
26
25
|
private
|
27
26
|
def send_request(attrs)
|
28
27
|
request = Net::HTTP::Post.new uri.request_uri, "Authorization" => "Token #{@token}"
|
29
|
-
request.
|
28
|
+
request.set_form_data attrs
|
30
29
|
|
31
30
|
http.request(request)
|
32
31
|
end
|
@@ -42,4 +41,12 @@ class Firebell::Client
|
|
42
41
|
def uri
|
43
42
|
@uri ||= URI.parse Firebell.configuration.url
|
44
43
|
end
|
44
|
+
|
45
|
+
def requestable?
|
46
|
+
if Firebell.configuration.notify_release_stages.any?
|
47
|
+
Firebell.configuration.notify_release_stages.include? Firebell.configuration.release_stage
|
48
|
+
else
|
49
|
+
true
|
50
|
+
end
|
51
|
+
end
|
45
52
|
end
|
data/lib/firebell/version.rb
CHANGED
data/lib/firebell.rb
CHANGED
@@ -11,8 +11,8 @@ module Firebell
|
|
11
11
|
end
|
12
12
|
|
13
13
|
class Configuration
|
14
|
-
attr_writer :host, :url
|
15
|
-
attr_accessor :token
|
14
|
+
attr_writer :host, :url, :notify_release_stages
|
15
|
+
attr_accessor :token, :release_stage
|
16
16
|
|
17
17
|
def host
|
18
18
|
@host ||= "https://firebellapp.com"
|
@@ -26,6 +26,9 @@ module Firebell
|
|
26
26
|
@url ||= "#{host}#{path}"
|
27
27
|
end
|
28
28
|
|
29
|
+
def notify_release_stages
|
30
|
+
@notify_release_stages ||= []
|
31
|
+
end
|
29
32
|
end
|
30
33
|
end
|
31
34
|
|
@@ -48,4 +48,32 @@ describe Firebell::Client do
|
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
|
+
describe "release stages" do
|
52
|
+
context "with a correct release stage set" do
|
53
|
+
before do
|
54
|
+
Firebell.configuration.notify_release_stages = %w{production staging}
|
55
|
+
Firebell.configuration.release_stage = "production"
|
56
|
+
end
|
57
|
+
|
58
|
+
it "makes a request" do
|
59
|
+
Firebell::Client.any_instance.expects(:send_request)
|
60
|
+
.with("tag" => "test.subject")
|
61
|
+
|
62
|
+
client.notify "test.subject"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
context "with an incorrect release stage set" do
|
67
|
+
before do
|
68
|
+
Firebell.configuration.notify_release_stages = %w{production staging}
|
69
|
+
Firebell.configuration.release_stage = "development"
|
70
|
+
end
|
71
|
+
|
72
|
+
it "makes a request" do
|
73
|
+
Firebell::Client.any_instance.expects(:send_request).never
|
74
|
+
|
75
|
+
client.notify "test.subject"
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
51
79
|
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.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luke Carpenter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|