http-pulse 0.0.1 → 0.0.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.
- data/Rakefile +1 -1
- data/bin/http-pulse +6 -2
- data/lib/http-pulse/request.rb +15 -2
- metadata +4 -4
data/Rakefile
CHANGED
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
|
-
|
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
|
data/lib/http-pulse/request.rb
CHANGED
@@ -17,11 +17,24 @@ module HttpPulse
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def delete(url)
|
20
|
-
|
21
|
-
|
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:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
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-
|
18
|
+
date: 2010-08-15 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|