Class: StatusCake
- Inherits:
-
Object
- Object
- StatusCake
- Includes:
- HTTParty
- Defined in:
- lib/status_cake/version.rb,
lib/status_cake/status_cake.rb
Defined Under Namespace
Modules: Version
Constant Summary collapse
- SUPPORTED_QUERIES =
We can only filter on these in the API. Hopefully they will support more.
['CUID','Status']
Instance Method Summary collapse
- #delete_test(test = {}) ⇒ Object
- #find(id) ⇒ Object
-
#initialize(opts) ⇒ StatusCake
constructor
A new instance of StatusCake.
- #pause_test(t) ⇒ Object
- #tests(options = {}) ⇒ Object
- #unpause_test(t) ⇒ Object
- #update_test(test = {}) ⇒ Object
Constructor Details
#initialize(opts) ⇒ StatusCake
Returns a new instance of StatusCake.
15 16 17 |
# File 'lib/status_cake/status_cake.rb', line 15 def initialize(opts) @auth = {'Username' => opts[:username], 'API' => opts[:api_key]} end |
Instance Method Details
#delete_test(test = {}) ⇒ Object
44 45 46 47 |
# File 'lib/status_cake/status_cake.rb', line 44 def delete_test(test={}) @opts = {headers:@auth, body:{ 'TestID' => test['TestID'] } } respond(self.class.delete("/Tests/Details",@opts)) end |
#find(id) ⇒ Object
19 20 21 22 |
# File 'lib/status_cake/status_cake.rb', line 19 def find(id) @opts = {headers:@auth, query:{ 'TestID' => id }} respond(self.class.get("/Tests/Details", @opts)) end |
#pause_test(t) ⇒ Object
49 50 51 52 53 54 |
# File 'lib/status_cake/status_cake.rb', line 49 def pause_test(t) if t t['Paused'] = '1' update_test(t) end end |
#tests(options = {}) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/status_cake/status_cake.rb', line 24 def tests(={}) # Hash#slice w/o activesupport query_opts = .select { |k,v| SUPPORTED_QUERIES.index(k) } filter_opts = .reject { |k,v| SUPPORTED_QUERIES.index(k) } @opts = {headers:@auth, query:query_opts} tests = respond(self.class.get("/Tests", @opts)) unless filter_opts.empty? tests.find_all { |t| (t & filter_opts) == filter_opts } else tests end end |
#unpause_test(t) ⇒ Object
56 57 58 59 60 61 |
# File 'lib/status_cake/status_cake.rb', line 56 def unpause_test(t) if t t['Paused'] = '0' update_test(t) end end |
#update_test(test = {}) ⇒ Object
39 40 41 42 |
# File 'lib/status_cake/status_cake.rb', line 39 def update_test(test={}) @opts = {headers:@auth, body:test } respond(self.class.put("/Tests/Update",@opts)) end |