ragios-client 0.0.2 → 0.0.3

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/README.rdoc CHANGED
@@ -34,7 +34,7 @@
34
34
 
35
35
  ragios.delete(monitor_id)
36
36
 
37
- ragios.find_by(options)
37
+ ragios.where(options)
38
38
 
39
39
  ragios.update(monitor_id, options)
40
40
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
data/lib/ragios-client.rb CHANGED
@@ -29,14 +29,14 @@ module Ragios
29
29
  response = RestClient.post "#{address_port}/monitors/", json(monitors), http_request_options
30
30
  parse_json(response.body)
31
31
  rescue => e
32
- raise ClientException, e.response
32
+ raise_error(e)
33
33
  end
34
34
 
35
35
  def find(monitor_id)
36
36
  response = RestClient.get "#{address_port}/monitors/#{monitor_id}/", auth_cookie
37
37
  parse_json(response.body)
38
38
  rescue => e
39
- raise ClientException, e.response
39
+ raise_error(e)
40
40
  end
41
41
 
42
42
  def all
@@ -48,24 +48,24 @@ module Ragios
48
48
  response = RestClient.put "#{address_port}/monitors/#{monitor_id}",{:status => "stopped"}, http_request_options
49
49
  parse_json(response)
50
50
  rescue => e
51
- raise ClientException, e.response
51
+ raise_error(e)
52
52
  end
53
53
 
54
54
  def restart(monitor_id)
55
55
  response = RestClient.put "#{address_port}/monitors/#{monitor_id}",{:status => "active"},http_request_options
56
56
  parse_json(response)
57
57
  rescue => e
58
- raise ClientException, e.response
58
+ raise_error(e)
59
59
  end
60
60
 
61
61
  def delete(monitor_id)
62
62
  response = RestClient.delete "#{address_port}/monitors/#{monitor_id}", auth_cookie
63
63
  parse_json(response)
64
64
  rescue => e
65
- raise ClientException, e.response
65
+ raise_error(e)
66
66
  end
67
67
 
68
- def find_by(options)
68
+ def where(options)
69
69
  response = RestClient.get "#{address_port}/monitors?#{URI.encode_www_form(options)}", auth_cookie
70
70
  parse_json(response)
71
71
  end
@@ -74,18 +74,22 @@ module Ragios
74
74
  response = RestClient.put "#{address_port}/monitors/#{monitor_id}",json(options), http_request_options
75
75
  parse_json(response)
76
76
  rescue => e
77
- raise ClientException, e.response
77
+ raise_error(e)
78
78
  end
79
79
 
80
80
  def test(monitor_id)
81
81
  response = RestClient.post "#{address_port}/tests", {:id => monitor_id}, http_request_options
82
82
  parse_json(response)
83
83
  rescue => e
84
- raise ClientException, e.response
84
+ raise_error(e)
85
85
  end
86
86
 
87
87
  private
88
88
 
89
+ def raise_error(e)
90
+ e.respond_to?('response') ? raise(ClientException, e.response) : raise(e)
91
+ end
92
+
89
93
  def auth_cookie
90
94
  {:cookies => {:AuthSession => auth_session}}
91
95
  end
@@ -114,7 +118,7 @@ private
114
118
  hash = Yajl::Parser.parse(auth.to_str)
115
119
  hash['AuthSession']
116
120
  rescue => e
117
- raise ClientException, e.response
121
+ raise_error(e)
118
122
  end
119
123
  end
120
124
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "ragios-client"
8
- s.version = "0.0.2"
8
+ s.version = "0.0.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["obi-a"]
12
- s.date = "2014-04-05"
12
+ s.date = "2014-04-18"
13
13
  s.description = "ruby client for ragios"
14
14
  s.email = "obioraakubue@yahoo.com"
15
15
  s.extra_rdoc_files = [
@@ -31,7 +31,7 @@ Gem::Specification.new do |s|
31
31
  s.homepage = "http://github.com/obi-a/ragios-client"
32
32
  s.licenses = ["MIT"]
33
33
  s.require_paths = ["lib"]
34
- s.rubygems_version = "1.8.24"
34
+ s.rubygems_version = "1.8.28"
35
35
  s.summary = "Ruby client for ragios"
36
36
 
37
37
  if s.respond_to? :specification_version then
@@ -108,7 +108,7 @@ describe "Ragios Client" do
108
108
  #setup ends
109
109
 
110
110
  options = {tag: 'test', every: '5m', monitor: unique_name}
111
- found_monitors = @ragios.find_by(options)
111
+ found_monitors = @ragios.where(options)
112
112
  found_monitors.first.should include(monitors.first)
113
113
 
114
114
  #teardown
@@ -118,7 +118,7 @@ describe "Ragios Client" do
118
118
 
119
119
  it "returns an empty array when no monitor matches multiple key/value pairs" do
120
120
  options = {something: "dont_exist", every: "5m", monitor: "dont_exist"}
121
- @ragios.find_by(options).should == []
121
+ @ragios.where(options).should == []
122
122
  end
123
123
 
124
124
  it "should update a monitor" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ragios-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-04-05 00:00:00.000000000 Z
12
+ date: 2014-04-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client
@@ -172,7 +172,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
172
172
  version: '0'
173
173
  segments:
174
174
  - 0
175
- hash: 1863115322660695517
175
+ hash: -3019979110214078763
176
176
  required_rubygems_version: !ruby/object:Gem::Requirement
177
177
  none: false
178
178
  requirements:
@@ -181,7 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
181
181
  version: '0'
182
182
  requirements: []
183
183
  rubyforge_project:
184
- rubygems_version: 1.8.24
184
+ rubygems_version: 1.8.28
185
185
  signing_key:
186
186
  specification_version: 3
187
187
  summary: Ruby client for ragios