stashboard 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -18,10 +18,17 @@ module Stashboard
18
18
 
19
19
  # Gets a list of all services currently managed by the Stashboard instance
20
20
  #
21
- # @return [Array] an array of service detail hashes
21
+ # @return [Hash] containing an array of service detail hashes, or an error message
22
22
  def services
23
- response = @client.get("/api/v1/services")
24
- return JSON.parse(response.body)
23
+ response = JSON.parse(@client.get("/api/v1/services").body)
24
+ return response["services"] || response
25
+ end
26
+
27
+ # Gets an array of service ids. This is just for convenience
28
+ #
29
+ # @return [Array] containing just the service ids
30
+ def service_ids
31
+ services.collect { |s| s["id"] }
25
32
  end
26
33
 
27
34
  # Get the details of an individual service managed by the Stashboard instance.
@@ -68,18 +75,18 @@ module Stashboard
68
75
  #
69
76
  # @return [Array] an array of the level strings
70
77
  def levels
71
- response = @client.get("/api/v1/levels")
72
- return JSON.parse(response.body)["levels"]
78
+ response = JSON.parse(@client.get("/api/v1/levels").body)
79
+ return response["levels"] || response
73
80
  end
74
81
 
75
82
  # Get events for the specified service.
76
83
  #
77
84
  # @param [String] the service id we wer interested in
78
85
  # @param [Hash] optional hash that restricts the returned events. Only keys that do anything are "start" and "end" which can be used to constrain the time period from which events will be returned.
79
- # @return [Array] an array of event hashes describing events for the service
86
+ # @return [Hash] an array of event hashes describing events for the service, or an error hash
80
87
  def events(service_id, options = {})
81
- response = @client.get("/api/v1/services/#{service_id}/events", options)
82
- return JSON.parse(response.body)
88
+ response = JSON.parse(@client.get("/api/v1/services/#{service_id}/events", options).body)
89
+ return response["events"] || response
83
90
  end
84
91
 
85
92
  # Create an event of a service. Events are the main way we
@@ -125,8 +132,15 @@ module Stashboard
125
132
  #
126
133
  # @return [Array] an array of status hashes, each hash is an individual status
127
134
  def statuses
128
- response = @client.get("/api/v1/statuses")
129
- return JSON.parse(response.body)
135
+ response = JSON.parse(@client.get("/api/v1/statuses").body)
136
+ return response["statuses"] || response
137
+ end
138
+
139
+ # Convenience method to return just the status ids.
140
+ #
141
+ # @return [Array] an array of just the status ids
142
+ def status_ids
143
+ statuses.collect { |s| s["id"] }
130
144
  end
131
145
 
132
146
  # Get the details of the individual status.
@@ -155,8 +169,8 @@ module Stashboard
155
169
  #
156
170
  # @return [Array] array of image hashes
157
171
  def status_images
158
- response = @client.get("/api/v1/status-images")
159
- return JSON.parse(response.body)["images"]
172
+ response = JSON.parse(@client.get("/api/v1/status-images").body)
173
+ return response["images"] || response
160
174
  end
161
175
  end
162
176
  end
@@ -1,3 +1,3 @@
1
1
  module Stashboard
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stashboard
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
  - Sam Mulube