opsgenie-heartbeat 0.1.1 → 0.1.2

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: 791da80f0096d7f95239f6e2bb604786f225ebb3
4
- data.tar.gz: '0019d407624761117fe21d1d6d653412fce1116d'
3
+ metadata.gz: 90ab82ef80b3460608df4482d3cfec7854abe08d
4
+ data.tar.gz: 860eef58b7f9ee13b7e4ed72734ac938987e878d
5
5
  SHA512:
6
- metadata.gz: 0c2ee4d60cd06bf0caa1afd82ccc48d595111825aac263338200c4d2b8b66cf1ba6b5285e61c41d0578ab3acb070cf89f70488de061c2a47334c72f8742f73e4
7
- data.tar.gz: 94862bea1ca6cc7a16cf53d2fd1aff535258471c9688957e7761f88773c59a6d00f6f827f922acaa9cc8d1bd64d488fd076b7ea7287e3efb68d63be8e893430d
6
+ metadata.gz: dd2e2930a0a5b714580839cdf235f27794e2d52175a643dc08a564ef9cb960f5213d790fe982517158eb7d98d199318d90e2797cfc4734eae6385fdb38d056d8
7
+ data.tar.gz: 5d6dae499406c7c1f2e713c74ab8099e60059f6f55090ae48c251d5501c52b08ba417864a5e79315a1fa60c6246e0d8a81bc5ad314a873dc70712e1ffc0479c3
@@ -2,3 +2,6 @@ Updates in version 0.1.1:
2
2
 
3
3
  No need to supply name_transformer in initializer file unless wanted.
4
4
  Now there is default value -> name itself.
5
+
6
+ Updates in version 0.1.2:
7
+ Instead of require 'opsgenie/heartbeat/heartbeat' now is require 'opsgenie/heartbeat'
data/README.md CHANGED
@@ -29,7 +29,7 @@ Ping, create or delete heartbeat requests with personalized name of heartbeat.
29
29
 
30
30
  In yours initializers folder, define new file with:
31
31
  ```ruby
32
- require "opsgenie/heartbeat/heartbeat"
32
+ require "opsgenie/heartbeat"
33
33
 
34
34
  Opsgenie::Heartbeat.configure do |config|
35
35
  #define opsgenie_api key in secrets.yml
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require "bundler/setup"
4
- require "opsgenie/heartbeat/heartbeat"
4
+ require "opsgenie/heartbeat"
5
5
 
6
6
  # You can add fixtures and/or initialization code here to make experimenting
7
7
  # with your gem easier. You can also use a different console, if you like.
@@ -0,0 +1,80 @@
1
+ require "opsgenie/heartbeat/config"
2
+ require 'net/https'
3
+ require 'uri'
4
+ require 'json'
5
+ require 'rack'
6
+
7
+ module Opsgenie
8
+ module Heartbeat
9
+
10
+ def self.pulse(name)
11
+ return unless configuration.enabled
12
+ name = configuration.name_transformer.call(name)
13
+ begin
14
+ uri = URI.parse("https://api.opsgenie.com/v2/heartbeats/#{Rack::Utils.escape name}/ping")
15
+ http = Net::HTTP.new(uri.host, uri.port)
16
+ http.use_ssl = true
17
+ data = {name: name}
18
+ http.post(uri.path, data.to_json, {'Authorization': "GenieKey #{configuration.api_key}", "Content-Type": "application/json"})
19
+ rescue => e
20
+ resolve_exception e
21
+ end
22
+ end
23
+
24
+ def self.ensure(name:, interval:, unit: , description:, enabled: true)
25
+ return unless configuration.enabled
26
+ original_name = name
27
+ name = configuration.name_transformer.call(name)
28
+
29
+ uri = URI.parse("https://api.opsgenie.com/v2/heartbeats/#{Rack::Utils.escape name}")
30
+ http = Net::HTTP.new(uri.host, uri.port)
31
+ http.use_ssl = true
32
+ response = http.get(uri.path)
33
+ unless response.is_a?(Net::HTTPSuccess)
34
+ create(name: original_name, description: description, interval: interval, unit: unit, enabled: enabled)
35
+ end
36
+ end
37
+
38
+ def self.delete(name)
39
+ return unless configuration.enabled
40
+ name = configuration.name_transformer.call(name)
41
+
42
+ begin
43
+ uri = URI.parse("https://api.opsgenie.com/v2/heartbeats/#{Rack::Utils.escape name}")
44
+ http = Net::HTTP.new(uri.host, uri.port)
45
+ http.use_ssl = true
46
+
47
+ http.delete(uri.path, {'Authorization': "GenieKey #{configuration.api_key}", "Content-Type": "application/json"})
48
+ rescue => e
49
+ resolve_exception e
50
+ end
51
+ end
52
+
53
+ private
54
+
55
+ def self.create(name:,description:,interval:,unit:, enabled:)
56
+ name = configuration.name_transformer.call(name)
57
+
58
+ begin
59
+ uri = URI.parse('https://api.opsgenie.com/v2/heartbeats')
60
+ http = Net::HTTP.new(uri.host, uri.port)
61
+ http.use_ssl = true
62
+ doc = {
63
+ name: name,
64
+ description: description,
65
+ interval: interval,
66
+ intervalUnit: unit,
67
+ enabled: enabled
68
+ }
69
+ http.post(uri.path, doc.to_json, {'Authorization': "GenieKey #{configuration.api_key}", "Content-Type": "application/json"})
70
+ rescue => e
71
+ resolve_exception e
72
+ end
73
+ end
74
+
75
+ def self.resolve_exception e
76
+ configuration.logger.info("Exception raised during heartbeat: #{e.message} #{e.backtrace}") if configuration.logger
77
+ raise if configuration.raise_error
78
+ end
79
+ end
80
+ end
@@ -1,80 +1,4 @@
1
- require "opsgenie/heartbeat/config"
2
- require 'net/https'
3
- require 'uri'
4
- require 'json'
5
- require 'rack'
6
-
7
- module Opsgenie
8
- module Heartbeat
9
-
10
- def self.pulse(name)
11
- return unless configuration.enabled
12
- name = configuration.name_transformer.call(name)
13
- begin
14
- uri = URI.parse("https://api.opsgenie.com/v2/heartbeats/#{Rack::Utils.escape name}/ping")
15
- http = Net::HTTP.new(uri.host, uri.port)
16
- http.use_ssl = true
17
- data = {name: name}
18
- http.post(uri.path, data.to_json, {'Authorization': "GenieKey #{configuration.api_key}", "Content-Type": "application/json"})
19
- rescue => e
20
- resolve_exception e
21
- end
22
- end
23
-
24
- def self.ensure(name:, interval:, unit: , description:, enabled: true)
25
- return unless configuration.enabled
26
- original_name = name
27
- name = configuration.name_transformer.call(name)
28
-
29
- uri = URI.parse("https://api.opsgenie.com/v2/heartbeats/#{Rack::Utils.escape name}")
30
- http = Net::HTTP.new(uri.host, uri.port)
31
- http.use_ssl = true
32
- response = http.get(uri.path)
33
- unless response.is_a?(Net::HTTPSuccess)
34
- create(name: original_name, description: description, interval: interval, unit: unit, enabled: enabled)
35
- end
36
- end
37
-
38
- def self.delete(name)
39
- return unless configuration.enabled
40
- name = configuration.name_transformer.call(name)
41
-
42
- begin
43
- uri = URI.parse("https://api.opsgenie.com/v2/heartbeats/#{Rack::Utils.escape name}")
44
- http = Net::HTTP.new(uri.host, uri.port)
45
- http.use_ssl = true
46
-
47
- http.delete(uri.path, {'Authorization': "GenieKey #{configuration.api_key}", "Content-Type": "application/json"})
48
- rescue => e
49
- resolve_exception e
50
- end
51
- end
52
-
53
- private
54
-
55
- def self.create(name:,description:,interval:,unit:, enabled:)
56
- name = configuration.name_transformer.call(name)
57
-
58
- begin
59
- uri = URI.parse('https://api.opsgenie.com/v2/heartbeats')
60
- http = Net::HTTP.new(uri.host, uri.port)
61
- http.use_ssl = true
62
- doc = {
63
- name: name,
64
- description: description,
65
- interval: interval,
66
- intervalUnit: unit,
67
- enabled: enabled
68
- }
69
- http.post(uri.path, doc.to_json, {'Authorization': "GenieKey #{configuration.api_key}", "Content-Type": "application/json"})
70
- rescue => e
71
- resolve_exception e
72
- end
73
- end
74
-
75
- def self.resolve_exception e
76
- configuration.logger.info("Exception raised during heartbeat: #{e.message} #{e.backtrace}") if configuration.logger
77
- raise if configuration.raise_error
78
- end
79
- end
80
- end
1
+ #heartbeat.rb code was in lib/opsgenie/heartbeat folder at first, which was wrong.
2
+ #this file is added to maintain compatibility
3
+ require 'opsgenie/heartbeat'
4
+
@@ -1,5 +1,5 @@
1
1
  module Opsgenie
2
2
  module Heartbeat
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opsgenie-heartbeat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dressipi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-08-18 00:00:00.000000000 Z
11
+ date: 2017-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -71,6 +71,7 @@ files:
71
71
  - bin/console
72
72
  - bin/setup
73
73
  - exe/opsgenie-heartbeat
74
+ - lib/opsgenie/heartbeat.rb
74
75
  - lib/opsgenie/heartbeat/config.rb
75
76
  - lib/opsgenie/heartbeat/heartbeat.rb
76
77
  - lib/opsgenie/heartbeat/version.rb