go_watchdog 1.2.4 → 1.2.5

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: f6d78ca3a8f75cfef7821195dea157ed151cba3d
4
- data.tar.gz: 4c188eab5abb8b00afd2838b9b5ab9c308640f4c
3
+ metadata.gz: a6ea1372462d7f0fe11364be101f297e2dae7cf8
4
+ data.tar.gz: a82225b16b14c4fc6bdaf9f82a40425c9b81495b
5
5
  SHA512:
6
- metadata.gz: e851390864dcb066b8b61bbd0fe7a9965cd3d1d52c329aada4e5ee9cef947f3524fc91a035784ca0b84b271ac1b679ce9c39ea085f7d59b70bf0a3deb7d35b70
7
- data.tar.gz: 91413ee399b8ed9bf87274f0a2a17faa3fb82d0c73afd76da5609d5c525c47483c5c639a544e5f14e6c891cd50b610bf46899fcd0e5f71f93bf1a0b8732ed803
6
+ metadata.gz: d9c38fd46ee85ae51cd6f707006c62a1f936d882ec069438cbe7903bb64299c71db938713b5fa611eef0dc8cedf09b002d03bc82308aaf9d9ffbbadb77af96ef
7
+ data.tar.gz: 7ee6a17394465bfc9a343e95a7ff5f8cb5a96cfd60b30f9d9f9cc1de74b0769c829d8536154143cb511fe164973df84acc099cd31ca6e65e2819247a20907e3d
data/README.md CHANGED
@@ -11,22 +11,17 @@ I use it to monitor [Mingle's](http://getmingle.io) last deploy to staging pipel
11
11
  Setup
12
12
  =====
13
13
 
14
- This assumes you're using [rbenv](https://github.com/sstephenson/rbenv)
14
+ > gem install go_watchdog
15
15
 
16
- > gem install bundler
16
+ > go_watchdog
17
17
 
18
- > bundle
19
18
 
20
- > cp config.yml{.example,}
19
+ The first time it runs, it will generate an example config file that you must change to point to the pipeline you want the watchdog to watch.
21
20
 
22
- To configure the pipeline, change config.yml to point to the pipeline you want the watchdog to watch.
21
+ Once you have the config the way you want, run it again.
23
22
 
24
- You can also adjust the timing of the moods. Right now, he starts off happy, then at 2 hours becomes neutral. At 24 hours he becomes angry and then at 36 hours he becomes enraged.
23
+ > go_watchdog
25
24
 
26
- Then to fire it up:
25
+ Put [http://localhost:4567/](http://localhost:4567/) up on an information radiator.
27
26
 
28
- > rackup
29
-
30
- Put [http://localhost:9292/](http://localhost:9292/) up on an information radiator.
31
-
32
- If things aren't what they seem, try deleting the ~/.last-green-go-pipeline-cache folder.s
27
+ If things aren't what they seem, try deleting the ~/.last-green-go-pipeline-cache folder.
@@ -1,9 +1,11 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'fileutils'
4
+ require_relative '../lib/go_watchdog.rb'
5
+ require 'highline/import'
4
6
 
5
7
  base_dir = File.expand_path(File.join(__dir__, '..'))
6
- template = , File.join(base_dir, 'config.yml.example')
8
+ template = File.join(base_dir, 'config.yml.example')
7
9
  config_file = File.join(ENV['HOME'], '.go_watchdog.yml')
8
10
 
9
11
  if File.exists?(config_file)
@@ -14,5 +16,11 @@ else
14
16
  exit -1
15
17
  end
16
18
 
17
- )
18
- `rackup #{File.join(base_dir, 'config.ru')}`
19
+ config = YAML.load(File.read(config_file))
20
+ username = config['credentials']['username']
21
+ host = config['pipeline']['host']
22
+ config['credentials']['password'] ||= ask("enter password for #{username}@#{host}: ") { |prompt| prompt.echo = false }
23
+
24
+ WATCHDOG_CONFIG = config
25
+
26
+ GoWatchdogApp.run!
Binary file
Binary file
Binary file
@@ -0,0 +1,214 @@
1
+ /**
2
+ * Timeago is a jQuery plugin that makes it easy to support automatically
3
+ * updating fuzzy timestamps (e.g. "4 minutes ago" or "about 1 day ago").
4
+ *
5
+ * @name timeago
6
+ * @version 1.4.1
7
+ * @requires jQuery v1.2.3+
8
+ * @author Ryan McGeary
9
+ * @license MIT License - http://www.opensource.org/licenses/mit-license.php
10
+ *
11
+ * For usage and examples, visit:
12
+ * http://timeago.yarp.com/
13
+ *
14
+ * Copyright (c) 2008-2013, Ryan McGeary (ryan -[at]- mcgeary [*dot*] org)
15
+ */
16
+
17
+ (function (factory) {
18
+ if (typeof define === 'function' && define.amd) {
19
+ // AMD. Register as an anonymous module.
20
+ define(['jquery'], factory);
21
+ } else {
22
+ // Browser globals
23
+ factory(jQuery);
24
+ }
25
+ }(function ($) {
26
+ $.timeago = function(timestamp) {
27
+ if (timestamp instanceof Date) {
28
+ return inWords(timestamp);
29
+ } else if (typeof timestamp === "string") {
30
+ return inWords($.timeago.parse(timestamp));
31
+ } else if (typeof timestamp === "number") {
32
+ return inWords(new Date(timestamp));
33
+ } else {
34
+ return inWords($.timeago.datetime(timestamp));
35
+ }
36
+ };
37
+ var $t = $.timeago;
38
+
39
+ $.extend($.timeago, {
40
+ settings: {
41
+ refreshMillis: 60000,
42
+ allowPast: true,
43
+ allowFuture: false,
44
+ localeTitle: false,
45
+ cutoff: 0,
46
+ strings: {
47
+ prefixAgo: null,
48
+ prefixFromNow: null,
49
+ suffixAgo: "ago",
50
+ suffixFromNow: "from now",
51
+ inPast: 'any moment now',
52
+ seconds: "less than a minute",
53
+ minute: "about a minute",
54
+ minutes: "%d minutes",
55
+ hour: "about an hour",
56
+ hours: "about %d hours",
57
+ day: "a day",
58
+ days: "%d days",
59
+ month: "about a month",
60
+ months: "%d months",
61
+ year: "about a year",
62
+ years: "%d years",
63
+ wordSeparator: " ",
64
+ numbers: []
65
+ }
66
+ },
67
+
68
+ inWords: function(distanceMillis) {
69
+ if(!this.settings.allowPast && ! this.settings.allowFuture) {
70
+ throw 'timeago allowPast and allowFuture settings can not both be set to false.';
71
+ }
72
+
73
+ var $l = this.settings.strings;
74
+ var prefix = $l.prefixAgo;
75
+ var suffix = $l.suffixAgo;
76
+ if (this.settings.allowFuture) {
77
+ if (distanceMillis < 0) {
78
+ prefix = $l.prefixFromNow;
79
+ suffix = $l.suffixFromNow;
80
+ }
81
+ }
82
+
83
+ if(!this.settings.allowPast && distanceMillis >= 0) {
84
+ return this.settings.strings.inPast;
85
+ }
86
+
87
+ var seconds = Math.abs(distanceMillis) / 1000;
88
+ var minutes = seconds / 60;
89
+ var hours = minutes / 60;
90
+ var days = hours / 24;
91
+ var years = days / 365;
92
+
93
+ function substitute(stringOrFunction, number) {
94
+ var string = $.isFunction(stringOrFunction) ? stringOrFunction(number, distanceMillis) : stringOrFunction;
95
+ var value = ($l.numbers && $l.numbers[number]) || number;
96
+ return string.replace(/%d/i, value);
97
+ }
98
+
99
+ var words = seconds < 45 && substitute($l.seconds, Math.round(seconds)) ||
100
+ seconds < 90 && substitute($l.minute, 1) ||
101
+ minutes < 45 && substitute($l.minutes, Math.round(minutes)) ||
102
+ minutes < 90 && substitute($l.hour, 1) ||
103
+ hours < 24 && substitute($l.hours, Math.round(hours)) ||
104
+ hours < 42 && substitute($l.day, 1) ||
105
+ days < 30 && substitute($l.days, Math.round(days)) ||
106
+ days < 45 && substitute($l.month, 1) ||
107
+ days < 365 && substitute($l.months, Math.round(days / 30)) ||
108
+ years < 1.5 && substitute($l.year, 1) ||
109
+ substitute($l.years, Math.round(years));
110
+
111
+ var separator = $l.wordSeparator || "";
112
+ if ($l.wordSeparator === undefined) { separator = " "; }
113
+ return $.trim([prefix, words, suffix].join(separator));
114
+ },
115
+
116
+ parse: function(iso8601) {
117
+ var s = $.trim(iso8601);
118
+ s = s.replace(/\.\d+/,""); // remove milliseconds
119
+ s = s.replace(/-/,"/").replace(/-/,"/");
120
+ s = s.replace(/T/," ").replace(/Z/," UTC");
121
+ s = s.replace(/([\+\-]\d\d)\:?(\d\d)/," $1$2"); // -04:00 -> -0400
122
+ s = s.replace(/([\+\-]\d\d)$/," $100"); // +09 -> +0900
123
+ return new Date(s);
124
+ },
125
+ datetime: function(elem) {
126
+ var iso8601 = $t.isTime(elem) ? $(elem).attr("datetime") : $(elem).attr("title");
127
+ return $t.parse(iso8601);
128
+ },
129
+ isTime: function(elem) {
130
+ // jQuery's `is()` doesn't play well with HTML5 in IE
131
+ return $(elem).get(0).tagName.toLowerCase() === "time"; // $(elem).is("time");
132
+ }
133
+ });
134
+
135
+ // functions that can be called via $(el).timeago('action')
136
+ // init is default when no action is given
137
+ // functions are called with context of a single element
138
+ var functions = {
139
+ init: function(){
140
+ var refresh_el = $.proxy(refresh, this);
141
+ refresh_el();
142
+ var $s = $t.settings;
143
+ if ($s.refreshMillis > 0) {
144
+ this._timeagoInterval = setInterval(refresh_el, $s.refreshMillis);
145
+ }
146
+ },
147
+ update: function(time){
148
+ var parsedTime = $t.parse(time);
149
+ $(this).data('timeago', { datetime: parsedTime });
150
+ if($t.settings.localeTitle) $(this).attr("title", parsedTime.toLocaleString());
151
+ refresh.apply(this);
152
+ },
153
+ updateFromDOM: function(){
154
+ $(this).data('timeago', { datetime: $t.parse( $t.isTime(this) ? $(this).attr("datetime") : $(this).attr("title") ) });
155
+ refresh.apply(this);
156
+ },
157
+ dispose: function () {
158
+ if (this._timeagoInterval) {
159
+ window.clearInterval(this._timeagoInterval);
160
+ this._timeagoInterval = null;
161
+ }
162
+ }
163
+ };
164
+
165
+ $.fn.timeago = function(action, options) {
166
+ var fn = action ? functions[action] : functions.init;
167
+ if(!fn){
168
+ throw new Error("Unknown function name '"+ action +"' for timeago");
169
+ }
170
+ // each over objects here and call the requested function
171
+ this.each(function(){
172
+ fn.call(this, options);
173
+ });
174
+ return this;
175
+ };
176
+
177
+ function refresh() {
178
+ var data = prepareData(this);
179
+ var $s = $t.settings;
180
+
181
+ if (!isNaN(data.datetime)) {
182
+ if ( $s.cutoff == 0 || Math.abs(distance(data.datetime)) < $s.cutoff) {
183
+ $(this).text(inWords(data.datetime));
184
+ }
185
+ }
186
+ return this;
187
+ }
188
+
189
+ function prepareData(element) {
190
+ element = $(element);
191
+ if (!element.data("timeago")) {
192
+ element.data("timeago", { datetime: $t.datetime(element) });
193
+ var text = $.trim(element.text());
194
+ if ($t.settings.localeTitle) {
195
+ element.attr("title", element.data('timeago').datetime.toLocaleString());
196
+ } else if (text.length > 0 && !($t.isTime(element) && element.attr("title"))) {
197
+ element.attr("title", text);
198
+ }
199
+ }
200
+ return element.data("timeago");
201
+ }
202
+
203
+ function inWords(date) {
204
+ return $t.inWords(distance(date));
205
+ }
206
+
207
+ function distance(date) {
208
+ return (new Date().getTime() - date.getTime());
209
+ }
210
+
211
+ // fix for IE6 suckage
212
+ document.createElement("abbr");
213
+ document.createElement("time");
214
+ }));
Binary file
@@ -0,0 +1,67 @@
1
+ body {
2
+ background-color: black;
3
+ color: white;
4
+ margin: 0;
5
+ font-family: 'Gorditas', cursive;
6
+ background-repeat: no-repeat;
7
+ background-size: cover;
8
+ }
9
+
10
+ .enraged {
11
+ background-image: url('enraged.jpg');
12
+ }
13
+
14
+ .angry {
15
+ background-image: url('angry.jpg');
16
+ }
17
+
18
+ .happy {
19
+ background-image: url('happy.jpg');
20
+ }
21
+
22
+ .neutral {
23
+ background-image: url('neutral.jpg');
24
+ }
25
+
26
+ .dashboard {
27
+ margin: 50px 25px 0px 25px;
28
+ padding: 0px 10px 0px 50px;
29
+ }
30
+
31
+ h1 {
32
+ text-shadow: 3px 3px black;
33
+ font-size: 256px;
34
+ padding-bottom: -65px;
35
+ margin: 20px 0px -25px 0px;
36
+ }
37
+
38
+ h2 {
39
+ text-shadow: 3px 3px black;
40
+ font-size: 100px;
41
+ }
42
+
43
+ .footer {
44
+ background-color: black;
45
+ border-top: 1px solid #555;
46
+ color: #BBB;
47
+ margin: 0;
48
+ z-index: 10000;
49
+ position: fixed;
50
+ bottom: 0;
51
+ left: 0;
52
+ right: 0;
53
+ font-weight: bold;
54
+ font-size: 24px;
55
+ text-align: right;
56
+ padding: 2px 20px 2px 0px;
57
+ }
58
+
59
+
60
+ a {
61
+ color: white;
62
+ text-decoration: none;
63
+ }
64
+
65
+ a:hover {
66
+ color: yellow;
67
+ }
@@ -0,0 +1,46 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Go Watchdog - ¡Guau guau!</title>
5
+ <link rel="stylesheet" type="text/css" href="watchdog.css" />
6
+ <link href='http://fonts.googleapis.com/css?family=Gorditas' rel='stylesheet' type='text/css'>
7
+ </head>
8
+ <body class="neutral">
9
+
10
+ <div class="dashboard">
11
+ <h1 id="time_since_last_green_build">
12
+ <time datetime="">(sniffing it out)</time>
13
+ </h1>
14
+ <h2><%= watchdog_config['message'] %></h2>
15
+ </div>
16
+
17
+ <div class="footer">
18
+ <p><a href="https://github.com/rearadmiral/go_watchdog">Go Watchdog</a></p>
19
+ </div>
20
+
21
+ <script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
22
+ <script src="jquery.timeago.js"></script>
23
+ <script type="text/javascript">
24
+
25
+ var pollServer = function() {
26
+ $.ajax({
27
+ url: "/time",
28
+ success: function(data) {
29
+ $("#time_since_last_green_build time").attr('datetime', data.time)
30
+ .text($.timeago(data.time));
31
+
32
+ $('body').removeClass('<%= ImpatientWatchdog::MOODS.join(" ") %>');
33
+ $('body').addClass(data.mood);
34
+ }
35
+ });
36
+ };
37
+
38
+ $(function() {
39
+ jQuery.timeago.settings.strings.suffixAgo = "";
40
+ pollServer();
41
+ setInterval(pollServer, 60000);
42
+ });
43
+ </script>
44
+
45
+ </body>
46
+ </html>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: go_watchdog
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.4
4
+ version: 1.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bill DePhillips
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-30 00:00:00.000000000 Z
11
+ date: 2014-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: last_green_go_pipeline
@@ -61,9 +61,16 @@ executables:
61
61
  extensions: []
62
62
  extra_rdoc_files: []
63
63
  files:
64
+ - static/watchdog.css
65
+ - static/enraged.jpg
66
+ - static/neutral.jpg
67
+ - static/angry.jpg
68
+ - static/jquery.timeago.js
69
+ - static/happy.jpg
70
+ - views/index.erb
64
71
  - lib/impatient_watchdog.rb
65
- - lib/go_watchdog.rb
66
72
  - lib/go_watchdog_helper.rb
73
+ - lib/go_watchdog.rb
67
74
  - LICENSE
68
75
  - README.md
69
76
  - config.yml.example