stashboardmanager 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +10 -0
- data/README.md +136 -7
- data/lib/stashboardmanager.rb +2 -18
- data/lib/stashboardmanager/version.rb +1 -1
- data/spec/manager_spec.rb +0 -7
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: daf1d45fd36354a13e21fd8716eb61aa645833b0
|
4
|
+
data.tar.gz: 23ded6c557713baf4509123ff8bf00bfe74509f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49f582f1594851976aaf821209a2af98721c08a022cb5b7c53937cf2f0ed549a8564d1d9d16c9eb58993e411abc671890f7c236217418a87514105dd6fcaac6d
|
7
|
+
data.tar.gz: 70b1d8015e16923575ec4edefc73fcb7cfa34a2bfcb3e838ef21ed007e47d9458d21c8c17e4f5e061662a0ad1afb9256ad3adc3cafd56ae8b862c2bb18914b57
|
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,28 +1,157 @@
|
|
1
|
-
# Stashboardmanager
|
1
|
+
# Stashboardmanager [![Gem Version](https://badge.fury.io/rb/stashboardmanager.svg)](http://badge.fury.io/rb/stashboardmanager) [![Build Status](https://travis-ci.org/mattrayner/stashboardmanager.svg?branch=master)](https://travis-ci.org/mattrayner/stashboardmanager)
|
2
2
|
|
3
|
-
|
3
|
+
A super-simple manager for stashboard, allowing you to easily update a stashboard instance with events throughout your application.
|
4
|
+
|
5
|
+
This gem adds a number of checks to prevent the repeat posting of updated so if you try to update the status to 'up' and the remote status is already 'up' then nothing happens, saving you bandwidth and time.
|
4
6
|
|
5
7
|
## Installation
|
6
8
|
|
7
9
|
Add this line to your application's Gemfile:
|
8
|
-
|
10
|
+
```ruby
|
9
11
|
gem 'stashboardmanager'
|
12
|
+
```
|
10
13
|
|
11
14
|
And then execute:
|
12
|
-
|
15
|
+
```bash
|
13
16
|
$ bundle
|
17
|
+
```
|
14
18
|
|
15
19
|
Or install it yourself as:
|
16
|
-
|
20
|
+
```bash
|
17
21
|
$ gem install stashboardmanager
|
22
|
+
```
|
18
23
|
|
19
24
|
## Usage
|
20
25
|
|
21
|
-
|
26
|
+
Create a new manager, using your app details and the oauth token and secret:
|
27
|
+
```ruby
|
28
|
+
manager = Stashboardmanager::Manager.new("https://YOURAPP.appspot.com", <oauth_token>, <oauth_secret>)
|
29
|
+
```
|
30
|
+
To get a list of all your services:
|
31
|
+
```ruby
|
32
|
+
manager.services
|
33
|
+
=begin
|
34
|
+
[
|
35
|
+
{
|
36
|
+
"description"=>"Mail Service",
|
37
|
+
"url"=>"https://YOURAPP.appspot.com/api/v1/services/mail-service",
|
38
|
+
"list"=>{
|
39
|
+
"url"=>"https://YOURAPP.appspot.com/api/v1/service-lists/application-services",
|
40
|
+
"description"=>"The main services that run the application",
|
41
|
+
"name"=>"Application Services",
|
42
|
+
"id"=>"application-services"
|
43
|
+
},
|
44
|
+
"current-event"=>nil,
|
45
|
+
"id"=>"mail-service",
|
46
|
+
"name"=>"Mail Service"
|
47
|
+
},
|
48
|
+
{
|
49
|
+
"description"=>"PDF Cleaner",
|
50
|
+
"url"=>"https://YOURAPP.appspot.com/api/v1/services/pdf-cleaner",
|
51
|
+
"list"=>{
|
52
|
+
"url"=>"https://YOURAPP.appspot.com/api/v1/service-lists/helper-services",
|
53
|
+
"description"=>"The little bits that help without being part of the app itself",
|
54
|
+
"name"=>"Helper Services", "id"=>"helper-services"
|
55
|
+
},
|
56
|
+
"current-event"=>nil,
|
57
|
+
"id"=>"pdf-cleaner",
|
58
|
+
"name"=>"PDF Cleaner"
|
59
|
+
},
|
60
|
+
{
|
61
|
+
"description"=>"Website service",
|
62
|
+
"url"=>"https://YOURAPP.appspot.com/api/v1/services/website",
|
63
|
+
"current-event"=>{
|
64
|
+
"status"=>{
|
65
|
+
"description"=>"The service is up",
|
66
|
+
"level"=>"NORMAL",
|
67
|
+
"default"=>true,
|
68
|
+
"image"=>"https://YOURAPP.appspot.com/images/icons/iconic/check_alt.png",
|
69
|
+
"url"=>"https://YOURAPP.appspot.com/api/v1/statuses/up",
|
70
|
+
"id"=>"up",
|
71
|
+
"name"=>"Up"
|
72
|
+
},
|
73
|
+
"url"=>"https://YOURAPP.appspot.com/api/v1/services/website/events/ag5zfnBsYW5ocS1zdGF0c3ISCxIFRXZlbnQYgICAgN6QwQsM",
|
74
|
+
"timestamp"=>"Mon, 28 Apr 2014 14:48:16 GMT",
|
75
|
+
"sid"=>"ag5zfnBsYW5ocS1zdGF0c3ISCxIFRXZlbnQYgICAgN6QwQsM",
|
76
|
+
"message"=>"Web server running A-OK",
|
77
|
+
"informational"=>false
|
78
|
+
},
|
79
|
+
"id"=>"website",
|
80
|
+
"name"=>"Website"
|
81
|
+
}
|
82
|
+
]
|
83
|
+
=end
|
84
|
+
```
|
85
|
+
|
86
|
+
To receive an array of service ids:
|
87
|
+
```ruby
|
88
|
+
manager.service_ids
|
89
|
+
# => ["mail-service", "pdf-cleaner", "website"]
|
90
|
+
```
|
91
|
+
|
92
|
+
To receive the status of a particular service:
|
93
|
+
```ruby
|
94
|
+
manager.service("website")
|
95
|
+
=begin
|
96
|
+
{
|
97
|
+
"description"=>"Website service",
|
98
|
+
"url"=>"https://YOURAPP.appspot.com/api/v1/services/website",
|
99
|
+
"current-event"=>{
|
100
|
+
"status"=>{
|
101
|
+
"description"=>"The service is up",
|
102
|
+
"level"=>"NORMAL",
|
103
|
+
"default"=>true,
|
104
|
+
"image"=>"https://YOURAPP.appspot.com/images/icons/iconic/check_alt.png",
|
105
|
+
"url"=>"https://YOURAPP.appspot.com/api/v1/statuses/up",
|
106
|
+
"id"=>"up",
|
107
|
+
"name"=>"Up"
|
108
|
+
},
|
109
|
+
"url"=>"https://YOURAPP.appspot.com/api/v1/services/website/events/ag5zfnBsYW5ocS1zdGF0c3ISCxIFRXZlbnQYgICAgN6QwQsM",
|
110
|
+
"timestamp"=>"Mon, 28 Apr 2014 14:48:16 GMT",
|
111
|
+
"sid"=>"ag5zfnBsYW5ocS1zdGF0c3ISCxIFRXZlbnQYgICAgN6QwQsM",
|
112
|
+
"message"=>"Web server running A-OK",
|
113
|
+
"informational"=>false
|
114
|
+
},
|
115
|
+
"id"=>"website",
|
116
|
+
"name"=>"Website"
|
117
|
+
}
|
118
|
+
=end
|
119
|
+
```
|
120
|
+
|
121
|
+
To find out how wether a service should be updated:
|
122
|
+
```ruby
|
123
|
+
manager.service_updatable("website", "up")
|
124
|
+
# => false
|
125
|
+
```
|
126
|
+
The above command first gets the details for this service, and checks it's current status. If the current status is not the same as the status you passed then it will return true.
|
127
|
+
|
128
|
+
To update a service:
|
129
|
+
```ruby
|
130
|
+
manager.service_update("website", "up", "The website it working!")
|
131
|
+
```
|
132
|
+
This command will first check if the service is updatable to the status you've chosen, if it is (it is not already the same status) then a new event is fired.
|
133
|
+
|
134
|
+
### Example usage
|
135
|
+
```ruby
|
136
|
+
#Create a manager for our stashboar instance
|
137
|
+
manager = Stashboardmanager::Manager.new("https://YOURAPP.appspot.com", <oauth_token>, <oauth_secret>)
|
138
|
+
|
139
|
+
#Get a list of all of their IDs
|
140
|
+
ids = manager.service_ids
|
141
|
+
|
142
|
+
#Iterate over each of them, seting the status to "up" in every case
|
143
|
+
ids.each do |id|
|
144
|
+
manager.service_update(id, "up", "Resetting #{id} to up for testing purposes")
|
145
|
+
end
|
146
|
+
```
|
147
|
+
|
148
|
+
## Additional help
|
149
|
+
|
150
|
+
For additional help, take a look at the [stashboard-ruby](https://github.com/mattrayner/stashboard-ruby) gem, stashboardmanager is build on top of it.
|
22
151
|
|
23
152
|
## Contributing
|
24
153
|
|
25
|
-
1. Fork it ( http://github.com
|
154
|
+
1. Fork it ( http://github.com/mattrayner/stashboardmanager/fork )
|
26
155
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
156
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
157
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/lib/stashboardmanager.rb
CHANGED
@@ -2,11 +2,8 @@ require "stashboard"
|
|
2
2
|
require "stashboardmanager/version"
|
3
3
|
|
4
4
|
module Stashboardmanager
|
5
|
-
|
6
|
-
|
7
5
|
# Main class for interacting with StashboardManager.
|
8
6
|
class Manager
|
9
|
-
|
10
7
|
@stashboard = nil
|
11
8
|
|
12
9
|
# Create a new StashboardManager instance.
|
@@ -21,7 +18,7 @@ module Stashboardmanager
|
|
21
18
|
# @param [String] message The message you wish to attach to this update
|
22
19
|
def service_update(service, status, message)
|
23
20
|
if service_updatable(service, status)
|
24
|
-
|
21
|
+
@stashboard.create_event(service, status, message)
|
25
22
|
end
|
26
23
|
end
|
27
24
|
|
@@ -76,25 +73,12 @@ module Stashboardmanager
|
|
76
73
|
#What is the current service status?
|
77
74
|
serv_stat = self.service_status(service)
|
78
75
|
|
79
|
-
if serv_stat ==
|
80
|
-
return nil
|
81
|
-
elsif serv_stat == status #If match don't update
|
76
|
+
if serv_stat == status #If match don't update
|
82
77
|
return false
|
83
78
|
else #No match - update
|
84
79
|
return true
|
85
80
|
end
|
86
81
|
end
|
87
|
-
|
88
|
-
# Create an event of a service. Events are the main way we
|
89
|
-
# indicate problems or resolutions of issues.
|
90
|
-
#
|
91
|
-
# @param [String] service The service you want to update
|
92
|
-
# @param [String] id The id of an already existing status (i.e. "up", "down", "warning" or "error")
|
93
|
-
# @param [String] message The message we want our event to have attached
|
94
|
-
# @return [Hash] event The event details
|
95
|
-
def generate_stashboard_event(service, status, message)
|
96
|
-
@stashboard.create_event(service, status, message)
|
97
|
-
end
|
98
82
|
end
|
99
83
|
|
100
84
|
end
|
data/spec/manager_spec.rb
CHANGED
@@ -2,23 +2,16 @@ require 'stashboardmanager'
|
|
2
2
|
|
3
3
|
describe Stashboardmanager::Manager do
|
4
4
|
#Setup the remote instance ready for the tests
|
5
|
-
puts "Preparing for tests"
|
6
5
|
manager = Stashboardmanager::Manager.new("https://stashmanagertest.appspot.com", "1/3x3oY6MRqACaMmuzr0pr76_3J9zkB3sJX_rIMCFU-cU", "p2K71wl3ekDBNF88UcAnFfUi")
|
7
6
|
|
8
7
|
ids = manager.service_ids
|
9
8
|
|
10
|
-
puts ids
|
11
|
-
|
12
9
|
ids.each do |id|
|
13
10
|
manager.service_update(id, "up", "Resetting #{id} for testing purposes")
|
14
11
|
end
|
15
12
|
|
16
13
|
id = ids[0]
|
17
14
|
|
18
|
-
puts id
|
19
|
-
|
20
|
-
puts manager.service_status(id)
|
21
|
-
|
22
15
|
it "Has reset all" do
|
23
16
|
manager.service_status(id).should eql("up")
|
24
17
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stashboardmanager
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Rayner
|
@@ -77,6 +77,7 @@ extensions: []
|
|
77
77
|
extra_rdoc_files: []
|
78
78
|
files:
|
79
79
|
- .gitignore
|
80
|
+
- .travis.yml
|
80
81
|
- Gemfile
|
81
82
|
- LICENSE.txt
|
82
83
|
- README.md
|