canary-client 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/canary/client.rb +14 -6
- data/lib/canary/client/version.rb +1 -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: 354e4992a8200b8a3196da9adca37a3d61e409e8
|
4
|
+
data.tar.gz: 6a3e9accf96037e5c611eecca6659e38f9b8a457
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ecaaa66dc7c21f930ad817824d685b2c00da8e39cb1d1c1c6675f6111afd65a5cd1228ee86d8d404a6397b8198c149c765d7486d8ef2a27782ddc62d1b4bcbfe
|
7
|
+
data.tar.gz: a47b927e9b31e9edbd5e81b2d6ed649b836f4c0a8ee05406d42c3b356c5b3a474f7c59c6aa0080321bb03c136d92d2ae1041b5e162fc1ab1165f94072d35b67d
|
data/lib/canary/client.rb
CHANGED
@@ -6,22 +6,30 @@ require 'json'
|
|
6
6
|
module Canary
|
7
7
|
class Client
|
8
8
|
|
9
|
-
def initialize(canary_url, client_name: nil)
|
9
|
+
def initialize(canary_url = nil, client_name: nil)
|
10
10
|
@canary_url = canary_url
|
11
11
|
@client_name = client_name
|
12
12
|
end
|
13
13
|
|
14
|
-
def send_alert(description,
|
15
|
-
uri = URI(
|
14
|
+
def send_alert(description, details: {})
|
15
|
+
uri = URI(canary_url)
|
16
16
|
req = Net::HTTP::Post.new(uri, {'Content-Type' => 'application/json'})
|
17
|
-
req.body = error_payload(description,
|
17
|
+
req.body = error_payload(description, details).to_json
|
18
18
|
Net::HTTP.start(uri.hostname, uri.port) {|http| http.request(req)}
|
19
19
|
end
|
20
20
|
|
21
21
|
private
|
22
22
|
|
23
|
-
def
|
24
|
-
|
23
|
+
def canary_url
|
24
|
+
@canary_url || ENV['CANARY_URL']
|
25
|
+
end
|
26
|
+
|
27
|
+
def client_name
|
28
|
+
@client_name || ENV['CANARY_CLIENT']
|
29
|
+
end
|
30
|
+
|
31
|
+
def error_payload(description, details)
|
32
|
+
details.merge!({client_name: client_name}) if client_name
|
25
33
|
{
|
26
34
|
description: description,
|
27
35
|
details: details
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: canary-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Erez Rabih
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|