http-pulse 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -6,7 +6,7 @@ require 'spec/rake/spectask'
6
6
 
7
7
  spec = Gem::Specification.new do |s|
8
8
  s.name = "http-pulse"
9
- s.version = "0.0.1"
9
+ s.version = "0.0.2"
10
10
  s.author = "Corey Donohoe"
11
11
  s.email = "atmos@atmos.org"
12
12
  s.homepage = "http://www.atmos.org/http-pulse"
data/bin/http-pulse CHANGED
@@ -33,7 +33,11 @@ begin
33
33
  response = api.create(options[:url])
34
34
  puts "Successfully added #{options[:url]}"
35
35
  when :delete
36
- raise ArgumentError, "Unimplemented on the server"
36
+ if api.delete(options[:url])
37
+ puts "Successfully removed #{options[:url]}"
38
+ else
39
+ puts "Unable to locate #{options[:url]} for your user"
40
+ end
37
41
  else
38
42
  response = api.get
39
43
  if response.any?
@@ -46,7 +50,7 @@ begin
46
50
  puts "You have no monitors in place, create some!"
47
51
  end
48
52
  end
49
- rescue Errno::ECONNREFUSED => e
53
+ rescue Errno::ECONNREFUSED, RestClient::RequestTimeout => e
50
54
  puts "http-pulse seems to be down ATM :("
51
55
  exit(1)
52
56
  rescue RestClient::ResourceNotFound => e
@@ -17,11 +17,24 @@ module HttpPulse
17
17
  end
18
18
 
19
19
  def delete(url)
20
- response = RestClient.delete(endpoint, {:url => url}, {:content_type => :json, :accept => :json})
21
- handle_response(response)
20
+ if object_id = id_for_url(url)
21
+ response = RestClient.delete("#{endpoint}/#{object_id}")
22
+ JSON.parse(response) == { }
23
+ else
24
+ false
25
+ end
22
26
  end
23
27
 
24
28
  private
29
+
30
+ def id_for_url(url)
31
+ monitors = get
32
+ monitors.each do |monitor|
33
+ return monitor['_id'] if monitor['url'] == url
34
+ end
35
+ nil
36
+ end
37
+
25
38
  def handle_response(response)
26
39
  raise RequestError, response.inspect unless (200...299).include?(response.code)
27
40
  JSON.parse(response.to_s)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: http-pulse
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Corey Donohoe
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-08-14 00:00:00 -07:00
18
+ date: 2010-08-15 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency