guard-webhook-notifier 0.0.2 → 0.0.3

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: 1349f31883866481ae35cda6b4596c19e9b33be1
4
- data.tar.gz: 9503712a8033c4d94aabb5a64168830f3ded2b1e
3
+ metadata.gz: 0103c6d5adb4796888ffab23358d70785e4c2ca2
4
+ data.tar.gz: c6f2064f3262c9b5e42e731f7cf33551e3035e14
5
5
  SHA512:
6
- metadata.gz: 171da3a6aa4f426eeb2b84c583f0439b87b96823a99c96a0eb8e7e523091c67f113b8b5a04bb0456e3fc63851995be5e08841820dd5d55211f1fc145c406f304
7
- data.tar.gz: 011863f497bfe31b8edf8fd640cff9473ef1e12fbbefefefbbd41600ff7173eaaf95da9180b2507d42f89c4b5b96d93d72321fa5958463e7733c459e634ad6b9
6
+ metadata.gz: 7b6110eaf764727c33c497ec5dad13f829d478b90d8559c2189d057bf7c26a637f8d085c31bfa3d72c9954da1cbfc9aa32bef94f1dcf49b8469697407fd58d7e
7
+ data.tar.gz: 2d7e66ed298646f744a407bcce348be80ccd94651bdfa743293c088a3b6eaf16e77091c61ad7920ccdb52532a0aa43a6cd47d37b00943d507b25bc87c1f26e7e
@@ -6,7 +6,8 @@ module GuardWebHookNotifier
6
6
  class Notifier < Guard::Notifier::Base
7
7
  DEFAULTS = {
8
8
  user_agent: "GuardWebHookNotifier/#{VERSION}",
9
- url: "http://10.0.2.2:4001/"
9
+ url: "http://10.0.2.2:4001/",
10
+ timeout: 1
10
11
  }
11
12
 
12
13
  def initialize(opts = {})
@@ -16,11 +17,19 @@ module GuardWebHookNotifier
16
17
 
17
18
  def notify(message, opts = {})
18
19
  super
20
+ send(message, opts) rescue Faraday::Error
21
+ end
22
+
23
+ private
24
+
25
+ def send(message, opts)
19
26
  conn = Faraday.new(url: opts[:url])
20
27
  conn.post do |req|
21
28
  req.headers["Content-Type"] = "application/json"
22
29
  req.headers["User-Agent"] = opts[:user_agent]
23
30
  req.body = { message: message, options: opts }.to_json
31
+ req.options.timeout = opts[:timeout]
32
+ req.options.open_timeout = opts[:timeout]
24
33
  end
25
34
  end
26
35
  end
@@ -1,3 +1,3 @@
1
1
  module GuardWebHookNotifier
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -27,5 +27,13 @@ describe GuardWebHookNotifier::Notifier do
27
27
  subject
28
28
  expect(stub).to have_been_requested.once
29
29
  end
30
+
31
+ context 'when timeout occurs' do
32
+ before do
33
+ stub_request(:post, '10.0.2.2:4001').to_timeout
34
+ end
35
+
36
+ it { expect { subject }.not_to raise_error }
37
+ end
30
38
  end
31
39
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard-webhook-notifier
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuku Takahashi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-24 00:00:00.000000000 Z
11
+ date: 2014-11-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday