service_disruption 0.1.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/service_disruption.rb +5 -3
- data/lib/service_disruption/command.rb +2 -2
- data/lib/service_disruption/notifiers/growl.rb +37 -0
- data/lib/service_disruption/notifiers/notification_center.rb +15 -0
- data/service_disruption.gemspec +12 -11
- data/spec/service_disruption_spec.rb +0 -4
- metadata +112 -72
- data/lib/service_disruption/notifier.rb +0 -35
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 803a987f6624f3849a3a6b13612dba25a9ab4792
|
4
|
+
data.tar.gz: 6542fa23a4acfebe8f615dad4bb74a4a150da2e7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9ac5e350dee77f387b028987ebc318127ef02289c7cefb7a21682a2ed2c051be17da10a36e67790161059fe7e52ab1c09dadbded6516cbdd23f1af357d06605c
|
7
|
+
data.tar.gz: 6b645b829c369f9e9530fae224f85bcc224e5108bf412bf352abcc3618ebb67d2b61517d0255da157356deb82417cbf7e6cec2a6577985fae9b35dc88a9bceb2
|
data/lib/service_disruption.rb
CHANGED
@@ -10,6 +10,7 @@ require 'eventmachine'
|
|
10
10
|
require 'daemons'
|
11
11
|
require 'rainbow'
|
12
12
|
require 'ruby_gntp'
|
13
|
+
require 'terminal-notifier'
|
13
14
|
require 'active_support/core_ext'
|
14
15
|
|
15
16
|
#Redefine runtime loadpath
|
@@ -20,19 +21,20 @@ require "service_disruption/data_source"
|
|
20
21
|
require "service_disruption/line"
|
21
22
|
require "service_disruption/status"
|
22
23
|
require "service_disruption/network"
|
23
|
-
require "service_disruption/
|
24
|
+
require "service_disruption/notifiers/growl"
|
25
|
+
require "service_disruption/notifiers/notification_center"
|
24
26
|
|
25
27
|
require "service_disruption/core_ext/hash"
|
26
28
|
|
27
29
|
module ServiceDisruption
|
28
|
-
VERSION = '
|
30
|
+
VERSION = '1.0.0'
|
29
31
|
TFL_ENDPOINT = 'http://cloud.tfl.gov.uk/TrackerNet/LineStatus'
|
30
32
|
ROOT_PATH = File.dirname(File.dirname(__FILE__))
|
31
33
|
|
32
34
|
extend self
|
33
35
|
|
34
36
|
def notifier
|
35
|
-
@notifier ||= ServiceDisruption::
|
37
|
+
@notifier ||= ServiceDisruption::Notifiers::NotificationCenter.new
|
36
38
|
end
|
37
39
|
|
38
40
|
def data_source
|
@@ -4,14 +4,14 @@ module ServiceDisruption
|
|
4
4
|
desc "start", "Start a demonized monitor"
|
5
5
|
method_option :interval, :aliases => "-i", :default => 30, :type => :numeric, :banner => "Interval to wait to poll in seconds"
|
6
6
|
def start
|
7
|
-
Daemons.run_proc('service_disruption', :
|
7
|
+
Daemons.run_proc('service_disruption', :ARGV => ['start'], :dir_mode => :normal, :dir => '/tmp') do
|
8
8
|
run_as_event_machine(options)
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
12
|
desc "stop", "Stop a demonized monitor"
|
13
13
|
def stop
|
14
|
-
Daemons.run_proc('service_disruption', :
|
14
|
+
Daemons.run_proc('service_disruption', :ARGV => ['stop'], :dir_mode => :normal, :dir => '/tmp') do
|
15
15
|
run_as_event_machine
|
16
16
|
end
|
17
17
|
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module ServiceDisruption
|
2
|
+
module Notifiers
|
3
|
+
class Growl
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
@client = GNTP.new("Service Disruption")
|
7
|
+
register_notifications
|
8
|
+
end
|
9
|
+
|
10
|
+
def status_change(line)
|
11
|
+
@client.notify({:name => "status_change",
|
12
|
+
:title => "#{line.name} | #{line.status.status_description}",
|
13
|
+
:text => line.status.status_details,
|
14
|
+
:icon => line.status.image,
|
15
|
+
:sticky => true
|
16
|
+
})
|
17
|
+
true
|
18
|
+
rescue
|
19
|
+
false
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def register_notifications
|
25
|
+
@client.register({:notifications => [{
|
26
|
+
:name => "status_change",
|
27
|
+
:enabled => true,
|
28
|
+
}]
|
29
|
+
})
|
30
|
+
true
|
31
|
+
rescue
|
32
|
+
false
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module ServiceDisruption
|
2
|
+
module Notifiers
|
3
|
+
class NotificationCenter
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
@client = TerminalNotifier
|
7
|
+
end
|
8
|
+
|
9
|
+
def status_change(line)
|
10
|
+
@client.notify(line.status.status_details, :title => line.name , :subtitle => line.status.status_description)
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/service_disruption.gemspec
CHANGED
@@ -24,16 +24,17 @@ Gem::Specification.new do |s|
|
|
24
24
|
s.require_paths = ["lib"]
|
25
25
|
|
26
26
|
# specify any dependencies here; for example:
|
27
|
-
s.add_development_dependency 'rake'
|
28
|
-
s.add_development_dependency 'rspec'
|
29
|
-
s.add_development_dependency 'fakeweb'
|
30
|
-
s.add_development_dependency 'fuubar'
|
27
|
+
s.add_development_dependency 'rake'
|
28
|
+
s.add_development_dependency 'rspec'
|
29
|
+
s.add_development_dependency 'fakeweb'
|
30
|
+
s.add_development_dependency 'fuubar'
|
31
31
|
|
32
|
-
s.add_runtime_dependency "thor"
|
33
|
-
s.add_runtime_dependency "httparty"
|
34
|
-
s.add_runtime_dependency "eventmachine"
|
35
|
-
s.add_runtime_dependency "rainbow"
|
36
|
-
s.add_runtime_dependency "activesupport"
|
37
|
-
s.add_runtime_dependency "ruby_gntp"
|
38
|
-
s.add_runtime_dependency "
|
32
|
+
s.add_runtime_dependency "thor"
|
33
|
+
s.add_runtime_dependency "httparty"
|
34
|
+
s.add_runtime_dependency "eventmachine"
|
35
|
+
s.add_runtime_dependency "rainbow"
|
36
|
+
s.add_runtime_dependency "activesupport"
|
37
|
+
s.add_runtime_dependency "ruby_gntp"
|
38
|
+
s.add_runtime_dependency "terminal-notifier"
|
39
|
+
s.add_runtime_dependency "daemons"
|
39
40
|
end
|
metadata
CHANGED
@@ -1,138 +1,184 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: service_disruption
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
5
|
-
prerelease:
|
4
|
+
version: 1.0.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Adam Carlile
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2013-06-14 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rake
|
16
|
-
requirement:
|
17
|
-
none: false
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version: 0
|
19
|
+
version: '0'
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
|
-
version_requirements:
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
25
27
|
- !ruby/object:Gem::Dependency
|
26
28
|
name: rspec
|
27
|
-
requirement:
|
28
|
-
none: false
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
29
30
|
requirements:
|
30
|
-
- -
|
31
|
+
- - '>='
|
31
32
|
- !ruby/object:Gem::Version
|
32
|
-
version:
|
33
|
+
version: '0'
|
33
34
|
type: :development
|
34
35
|
prerelease: false
|
35
|
-
version_requirements:
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
36
41
|
- !ruby/object:Gem::Dependency
|
37
42
|
name: fakeweb
|
38
|
-
requirement:
|
39
|
-
none: false
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
40
44
|
requirements:
|
41
|
-
- -
|
45
|
+
- - '>='
|
42
46
|
- !ruby/object:Gem::Version
|
43
|
-
version:
|
47
|
+
version: '0'
|
44
48
|
type: :development
|
45
49
|
prerelease: false
|
46
|
-
version_requirements:
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
47
55
|
- !ruby/object:Gem::Dependency
|
48
56
|
name: fuubar
|
49
|
-
requirement:
|
50
|
-
none: false
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
51
58
|
requirements:
|
52
|
-
- -
|
59
|
+
- - '>='
|
53
60
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
61
|
+
version: '0'
|
55
62
|
type: :development
|
56
63
|
prerelease: false
|
57
|
-
version_requirements:
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
58
69
|
- !ruby/object:Gem::Dependency
|
59
70
|
name: thor
|
60
|
-
requirement:
|
61
|
-
none: false
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
62
72
|
requirements:
|
63
|
-
- -
|
73
|
+
- - '>='
|
64
74
|
- !ruby/object:Gem::Version
|
65
|
-
version: 0
|
75
|
+
version: '0'
|
66
76
|
type: :runtime
|
67
77
|
prerelease: false
|
68
|
-
version_requirements:
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: httparty
|
71
|
-
requirement:
|
72
|
-
none: false
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
73
86
|
requirements:
|
74
|
-
- -
|
87
|
+
- - '>='
|
75
88
|
- !ruby/object:Gem::Version
|
76
|
-
version: 0
|
89
|
+
version: '0'
|
77
90
|
type: :runtime
|
78
91
|
prerelease: false
|
79
|
-
version_requirements:
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
80
97
|
- !ruby/object:Gem::Dependency
|
81
98
|
name: eventmachine
|
82
|
-
requirement:
|
83
|
-
none: false
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
84
100
|
requirements:
|
85
|
-
- -
|
101
|
+
- - '>='
|
86
102
|
- !ruby/object:Gem::Version
|
87
|
-
version: 0
|
103
|
+
version: '0'
|
88
104
|
type: :runtime
|
89
105
|
prerelease: false
|
90
|
-
version_requirements:
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
91
111
|
- !ruby/object:Gem::Dependency
|
92
112
|
name: rainbow
|
93
|
-
requirement:
|
94
|
-
none: false
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
95
114
|
requirements:
|
96
|
-
- -
|
115
|
+
- - '>='
|
97
116
|
- !ruby/object:Gem::Version
|
98
|
-
version:
|
117
|
+
version: '0'
|
99
118
|
type: :runtime
|
100
119
|
prerelease: false
|
101
|
-
version_requirements:
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
102
125
|
- !ruby/object:Gem::Dependency
|
103
126
|
name: activesupport
|
104
|
-
requirement:
|
105
|
-
none: false
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
106
128
|
requirements:
|
107
|
-
- -
|
129
|
+
- - '>='
|
108
130
|
- !ruby/object:Gem::Version
|
109
|
-
version:
|
131
|
+
version: '0'
|
110
132
|
type: :runtime
|
111
133
|
prerelease: false
|
112
|
-
version_requirements:
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - '>='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
113
139
|
- !ruby/object:Gem::Dependency
|
114
140
|
name: ruby_gntp
|
115
|
-
requirement:
|
116
|
-
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - '>='
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :runtime
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
117
149
|
requirements:
|
118
|
-
- -
|
150
|
+
- - '>='
|
119
151
|
- !ruby/object:Gem::Version
|
120
|
-
version: 0
|
152
|
+
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: terminal-notifier
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - '>='
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
121
160
|
type: :runtime
|
122
161
|
prerelease: false
|
123
|
-
version_requirements:
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - '>='
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
124
167
|
- !ruby/object:Gem::Dependency
|
125
168
|
name: daemons
|
126
|
-
requirement:
|
127
|
-
none: false
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
128
170
|
requirements:
|
129
|
-
- -
|
171
|
+
- - '>='
|
130
172
|
- !ruby/object:Gem::Version
|
131
|
-
version:
|
173
|
+
version: '0'
|
132
174
|
type: :runtime
|
133
175
|
prerelease: false
|
134
|
-
version_requirements:
|
135
|
-
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - '>='
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
181
|
+
description: "\n A simple gem to track the current status of London Underground
|
136
182
|
services, it polls the TFL endpoint and will alert\n you if there is an issue,
|
137
183
|
also provides a nice interface to TFL's tube data, still very beta, please give
|
138
184
|
me a poke on github with suggestions and enhancements.\n "
|
@@ -154,7 +200,8 @@ files:
|
|
154
200
|
- lib/service_disruption/data_source.rb
|
155
201
|
- lib/service_disruption/line.rb
|
156
202
|
- lib/service_disruption/network.rb
|
157
|
-
- lib/service_disruption/
|
203
|
+
- lib/service_disruption/notifiers/growl.rb
|
204
|
+
- lib/service_disruption/notifiers/notification_center.rb
|
158
205
|
- lib/service_disruption/status.rb
|
159
206
|
- service_disruption.gemspec
|
160
207
|
- spec/data_source_spec.rb
|
@@ -171,33 +218,26 @@ files:
|
|
171
218
|
- static/sd.png
|
172
219
|
homepage: http://adamcarlile.com
|
173
220
|
licenses: []
|
221
|
+
metadata: {}
|
174
222
|
post_install_message:
|
175
223
|
rdoc_options: []
|
176
224
|
require_paths:
|
177
225
|
- lib
|
178
226
|
required_ruby_version: !ruby/object:Gem::Requirement
|
179
|
-
none: false
|
180
227
|
requirements:
|
181
|
-
- -
|
228
|
+
- - '>='
|
182
229
|
- !ruby/object:Gem::Version
|
183
230
|
version: '0'
|
184
|
-
segments:
|
185
|
-
- 0
|
186
|
-
hash: 992296754875061883
|
187
231
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
188
|
-
none: false
|
189
232
|
requirements:
|
190
|
-
- -
|
233
|
+
- - '>='
|
191
234
|
- !ruby/object:Gem::Version
|
192
235
|
version: '0'
|
193
|
-
segments:
|
194
|
-
- 0
|
195
|
-
hash: 992296754875061883
|
196
236
|
requirements: []
|
197
237
|
rubyforge_project: service_disruption
|
198
|
-
rubygems_version:
|
238
|
+
rubygems_version: 2.0.3
|
199
239
|
signing_key:
|
200
|
-
specification_version:
|
240
|
+
specification_version: 4
|
201
241
|
summary: A simple gem to track the current status of London Underground services
|
202
242
|
test_files:
|
203
243
|
- spec/data_source_spec.rb
|
@@ -1,35 +0,0 @@
|
|
1
|
-
module ServiceDisruption
|
2
|
-
class Notifier
|
3
|
-
|
4
|
-
def initialize
|
5
|
-
@client = GNTP.new("Service Disruption")
|
6
|
-
register_notifications
|
7
|
-
end
|
8
|
-
|
9
|
-
def status_change(line)
|
10
|
-
@client.notify({:name => "status_change",
|
11
|
-
:title => "#{line.name} | #{line.status.status_description}",
|
12
|
-
:text => line.status.status_details,
|
13
|
-
:icon => line.status.image,
|
14
|
-
:sticky => true
|
15
|
-
})
|
16
|
-
true
|
17
|
-
rescue
|
18
|
-
false
|
19
|
-
end
|
20
|
-
|
21
|
-
private
|
22
|
-
|
23
|
-
def register_notifications
|
24
|
-
@client.register({:notifications => [{
|
25
|
-
:name => "status_change",
|
26
|
-
:enabled => true,
|
27
|
-
}]
|
28
|
-
})
|
29
|
-
true
|
30
|
-
rescue
|
31
|
-
false
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
35
|
-
end
|