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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4c66111e3800fed9e4af8e7c4ca049766422a852
4
- data.tar.gz: db9cd1d2f1ed12bfac05085a33328fcae89df090
3
+ metadata.gz: 354e4992a8200b8a3196da9adca37a3d61e409e8
4
+ data.tar.gz: 6a3e9accf96037e5c611eecca6659e38f9b8a457
5
5
  SHA512:
6
- metadata.gz: d7193db40dca215b7b31b9ba4a92d2644d9b1bc015f1d91c211826ff35f56b11185db82ddb3458829ad58a377e6f6d78c644a38faecab70943d6ee43600ce443
7
- data.tar.gz: 864a2bc4950edc72c10fb3d5ad56e54ada3ceb1977509901b7468b890470819fc7eeb2ba1ce35ad0d891f6977047adfb9d0cd786a6a966b66b6613c044b89eeb
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, client_name: nil, details: {})
15
- uri = URI(@canary_url)
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, client_name, details).to_json
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 error_payload(description, client_name, details)
24
- details.merge!({client_name: client_name || @client_name}) if client_name || @client_name
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
@@ -1,5 +1,5 @@
1
1
  module Canary
2
2
  class Client
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
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.0
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-27 00:00:00.000000000 Z
11
+ date: 2015-12-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler