cronitor 0.3.0 → 0.4.0

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: 0efbe8c896f144e98aba3dab86d303598860754a
4
- data.tar.gz: a8e38a24411ca2819c8c24e16807b598efc4e5ed
3
+ metadata.gz: 62931e4f5e773ffba0710b4d89bcf0bf62c7f614
4
+ data.tar.gz: 715ce68d247ee1a24dd6d81df71c17366a7b9878
5
5
  SHA512:
6
- metadata.gz: 3250356169dc02257781ca28d3cd0dcfb700b19da21a30c1a6548a21ae81f0fbc9a65b11f3773d824afb26da995eb9890760f412d70a473be701533abae76ebd
7
- data.tar.gz: 4271de4e6e6e2d6eef7c90767e6396cb0c23069e45d4ff612c4a69b20d01f96aef650871b5b5bca0e89173568a02f55c185027a2f9ec446eedd8b5b21f08130f
6
+ metadata.gz: fa1cbf980d25a4a9daab92a453f1d119070e4d444e6d68bf58b28971c60aecb86a43a74af48d5d065ce5f9ac08d7c3f77ce685ad4ad3529066de2daf742ebbe5
7
+ data.tar.gz: 7134bc4c2e53f70ff0870f3159ecb816ad2ee09f171d10e4f3543561b76b28fba9d428af90f161b6fef4510d092051fc9b512f19176cb354d8f3dfe071fc1ae9
data/Rakefile CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'bundler/gem_tasks'
2
2
  require 'rspec/core/rake_task'
3
+ require 'bump/tasks'
3
4
 
4
5
  RSpec::Core::RakeTask.new(:spec)
5
6
 
data/cronitor.gemspec CHANGED
@@ -24,4 +24,5 @@ Gem::Specification.new do |spec|
24
24
  spec.add_development_dependency 'pry', '~> 0.10'
25
25
  spec.add_development_dependency 'webmock', '~> 1.21'
26
26
  spec.add_development_dependency 'sinatra', '~> 1.4'
27
+ spec.add_development_dependency 'bump', '~> 0.1'
27
28
  end
data/lib/cronitor.rb CHANGED
@@ -16,14 +16,16 @@ class Cronitor
16
16
  @opts = opts
17
17
  @code = code
18
18
 
19
- if token.nil? && code.nil?
19
+ exists? opts[:name] if opts && opts.key?(:name)
20
+
21
+ if token.nil? && @code.nil?
20
22
  fail(
21
23
  Cronitor::Error,
22
24
  'Either a Cronitor API token or an existing monitor code must be ' \
23
25
  'provided')
24
26
  end
25
27
 
26
- create if code.nil?
28
+ create if @code.nil?
27
29
  end
28
30
 
29
31
  def create
@@ -36,6 +38,18 @@ class Cronitor
36
38
  @code = response.body['code'] if valid? response
37
39
  end
38
40
 
41
+ def exists?(name)
42
+ response = Unirest.get(
43
+ "#{API_URL}/monitors/#{URI.escape name}",
44
+ auth: { user: token }
45
+ )
46
+ return false unless response.code == 200
47
+
48
+ @code = response.body['code']
49
+
50
+ true
51
+ end
52
+
39
53
  def ping(type, msg = nil)
40
54
  url = "#{PING_URL}/#{code}/#{type}"
41
55
  url += "?msg=#{URI.escape msg}" if type == 'fail' && !msg.nil?
@@ -1,3 +1,3 @@
1
1
  class Cronitor
2
- VERSION = '0.3.0'
2
+ VERSION = '0.4.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cronitor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Byrnes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-13 00:00:00.000000000 Z
11
+ date: 2015-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unirest
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '1.4'
111
+ - !ruby/object:Gem::Dependency
112
+ name: bump
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '0.1'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '0.1'
111
125
  description:
112
126
  email:
113
127
  - thejeffbyrnes@gmail.com