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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7740e0ee907b9b81a69152969c7510f5e6599b15
4
- data.tar.gz: 6712adcd6660f6033fb4110203c579a2b73f0678
3
+ metadata.gz: daf1d45fd36354a13e21fd8716eb61aa645833b0
4
+ data.tar.gz: 23ded6c557713baf4509123ff8bf00bfe74509f0
5
5
  SHA512:
6
- metadata.gz: 5f6f0eaab23573783e631dd2ce77db62ef1858e870bd63c2e63b66c3c327830212469fe10a49a956913a9ba5100e6c964fd6fdf46c4c3155e2e064260868fd5b
7
- data.tar.gz: f166444d705157cb91e18ff34f9d59bbd77496faaca10d5447d47d5461a38c1692fe7e97b5bb864719c8ef30fc9368514f3f7849c4e3170848f6c4d2355f5a1f
6
+ metadata.gz: 49f582f1594851976aaf821209a2af98721c08a022cb5b7c53937cf2f0ed549a8564d1d9d16c9eb58993e411abc671890f7c236217418a87514105dd6fcaac6d
7
+ data.tar.gz: 70b1d8015e16923575ec4edefc73fcb7cfa34a2bfcb3e838ef21ed007e47d9458d21c8c17e4f5e061662a0ad1afb9256ad3adc3cafd56ae8b862c2bb18914b57
@@ -0,0 +1,10 @@
1
+ language: ruby
2
+ rvm:
3
+ - "1.8.7"
4
+ - "1.9.2"
5
+ - "1.9.3"
6
+ - "2.0.0"
7
+ - "2.1.0"
8
+ - rbx
9
+ # uncomment this line if your project needs to run something other than `rake`:
10
+ script: bundle exec rspec spec
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
- TODO: Write a gem description
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
- TODO: Write usage instructions here
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/<my-github-username>/stashboardmanager/fork )
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`)
@@ -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
- self.generate_stashboard_event(service, status, message)
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 == false #If false then don't continue (the service does not exist on remote)
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
@@ -1,3 +1,3 @@
1
1
  module Stashboardmanager
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -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.2
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