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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a79f1b4d8a57ff34c2371e3d90cb1a67edeccdfc
4
- data.tar.gz: 8397eb827da7224bdee04051acaee53dccf847f2
3
+ metadata.gz: 202311c076b2651523fbf9579ffdf9577b2f33c4
4
+ data.tar.gz: 8eb21252cfcf79d973997a600c93a77efa439dbc
5
5
  SHA512:
6
- metadata.gz: d9b328974843101fd80d464137c1c9c0314e445ecfb77a187b3fa790291d2868a23efc5dfa73805554283c3b624333d91ac55e2cf78fce55c582b87cee8704ca
7
- data.tar.gz: 185343d4d6444be0f6976c82f8dfbe42352055c29884cd8dc2e19304ac5a47051e216a6a5ae08cf4edeb99b448e2fede059da1ea47fde96beb237ae8e75bb7b0
6
+ metadata.gz: 438aff20a6ee4948409e48dc6178e08135032985d4988a0b425127172655bd1bb1071b677a2f79611239726ed84d9b4f11fe2a307cb18c56ecc7641f02a6bbc6
7
+ data.tar.gz: 47d5be5aca2f1a631a1d3aa7dc02568de7fbcb900000626ad183d8cae95602bb1538b89af5ccb453d4fc6dabae59f98b738a57c44837ebb2d76db2f8327d63a2
@@ -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.body = JSON.generate attrs
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
@@ -1,3 +1,3 @@
1
1
  module Firebell
2
- VERSION = "0.1.3"
2
+ VERSION = "0.2.0"
3
3
  end
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
@@ -20,6 +20,5 @@ describe Firebell::Configuration do
20
20
  c = Firebell::Configuration.new
21
21
  c.host = "http://cowbell.dev"
22
22
  expect(c.url).to eq "http://cowbell.dev/api/v1/events"
23
-
24
23
  end
25
24
  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.1.3
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-05-23 00:00:00.000000000 Z
11
+ date: 2014-10-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler