comsat 0.0.2 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/comsat.gemspec +1 -2
- data/lib/comsat/services/campfire.rb +15 -6
- data/lib/comsat/services/pagerduty.rb +5 -6
- data/lib/comsat/version.rb +1 -1
- data/lib/comsat.rb +0 -4
- metadata +11 -22
data/comsat.gemspec
CHANGED
@@ -6,7 +6,7 @@ Gem::Specification.new do |gem|
|
|
6
6
|
gem.email = ["ops@heroku.com"]
|
7
7
|
gem.description = "Notifications as a Gem"
|
8
8
|
gem.summary = "Notifications as a Gem"
|
9
|
-
gem.homepage = ""
|
9
|
+
gem.homepage = "https://github.com/heroku/comsat"
|
10
10
|
|
11
11
|
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
12
12
|
gem.files = `git ls-files`.split("\n")
|
@@ -17,7 +17,6 @@ Gem::Specification.new do |gem|
|
|
17
17
|
|
18
18
|
gem.add_runtime_dependency('rest-client')
|
19
19
|
gem.add_runtime_dependency('scrolls')
|
20
|
-
gem.add_runtime_dependency('tinder')
|
21
20
|
|
22
21
|
gem.add_development_dependency('rake')
|
23
22
|
gem.add_development_dependency('rspec')
|
@@ -15,19 +15,28 @@ module Comsat
|
|
15
15
|
unless room = find_room
|
16
16
|
raise "Unable to find room"
|
17
17
|
end
|
18
|
-
Array(msgs).each {|line| room
|
18
|
+
Array(msgs).each {|line| speak(room["id"], line) }
|
19
19
|
end
|
20
20
|
|
21
21
|
def campfire
|
22
|
-
@campfire = ::
|
23
|
-
@credentials.host
|
24
|
-
:
|
25
|
-
:token => @credentials.api_key
|
22
|
+
@campfire = RestClient::Resource.new(
|
23
|
+
"https://#{@credentials.api_key}:X@#{@credentials.host}",
|
24
|
+
:headers => {:content_type => :json}
|
26
25
|
)
|
27
26
|
end
|
28
27
|
|
29
28
|
def find_room
|
30
|
-
|
29
|
+
if @credentials.scope.to_i > 0
|
30
|
+
@room = {"id" => @credentials.scope.to_i}
|
31
|
+
else
|
32
|
+
rooms = JSON.parse(campfire['/rooms.json'].get)
|
33
|
+
@room = rooms["rooms"].select {|r| r["name"] == @credentials.scope }
|
34
|
+
@room.first
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def speak(room, message)
|
39
|
+
campfire["/room/#{room}/speak.json"].post(JSON.dump({:message => message}))
|
31
40
|
end
|
32
41
|
end
|
33
42
|
end
|
@@ -1,7 +1,5 @@
|
|
1
1
|
module Comsat
|
2
|
-
class
|
3
|
-
PAGERDUTY_ENDPOINT = 'https://events.pagerduty.com/generic/2010-04-15/create_event.json'
|
4
|
-
|
2
|
+
class Pagerduty < Service::Base
|
5
3
|
def send_notice(data)
|
6
4
|
contact_pagerduty(:trigger, data)
|
7
5
|
end
|
@@ -14,18 +12,19 @@ module Comsat
|
|
14
12
|
private
|
15
13
|
|
16
14
|
def contact_pagerduty(event_type, data)
|
17
|
-
id = data[:message_id] ||
|
15
|
+
id = data[:message_id] || rand(10_000)
|
18
16
|
message = data[:message]
|
19
17
|
source = data[:source]
|
20
|
-
message = "#{source}
|
18
|
+
message = "[#{source}] #{message}"
|
21
19
|
|
20
|
+
pagerduty_url = "https://#{@credentials.host}/#{@credentials.scope}"
|
22
21
|
data = {
|
23
22
|
:service_key => @credentials.api_key,
|
24
23
|
:incident_key => id,
|
25
24
|
:event_type => event_type,
|
26
25
|
:description => message
|
27
26
|
}
|
28
|
-
RestClient.post
|
27
|
+
RestClient.post pagerduty_url, data.to_json, :content_type => :json
|
29
28
|
end
|
30
29
|
end
|
31
30
|
end
|
data/lib/comsat/version.rb
CHANGED
data/lib/comsat.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: comsat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,11 +10,11 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-04-
|
13
|
+
date: 2012-04-12 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rest-client
|
17
|
-
requirement: &
|
17
|
+
requirement: &70177295796840 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: '0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *70177295796840
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: scrolls
|
28
|
-
requirement: &
|
28
|
+
requirement: &70177295796100 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ! '>='
|
@@ -33,21 +33,10 @@ dependencies:
|
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: tinder
|
39
|
-
requirement: &70287816064080 !ruby/object:Gem::Requirement
|
40
|
-
none: false
|
41
|
-
requirements:
|
42
|
-
- - ! '>='
|
43
|
-
- !ruby/object:Gem::Version
|
44
|
-
version: '0'
|
45
|
-
type: :runtime
|
46
|
-
prerelease: false
|
47
|
-
version_requirements: *70287816064080
|
36
|
+
version_requirements: *70177295796100
|
48
37
|
- !ruby/object:Gem::Dependency
|
49
38
|
name: rake
|
50
|
-
requirement: &
|
39
|
+
requirement: &70177295795660 !ruby/object:Gem::Requirement
|
51
40
|
none: false
|
52
41
|
requirements:
|
53
42
|
- - ! '>='
|
@@ -55,10 +44,10 @@ dependencies:
|
|
55
44
|
version: '0'
|
56
45
|
type: :development
|
57
46
|
prerelease: false
|
58
|
-
version_requirements: *
|
47
|
+
version_requirements: *70177295795660
|
59
48
|
- !ruby/object:Gem::Dependency
|
60
49
|
name: rspec
|
61
|
-
requirement: &
|
50
|
+
requirement: &70177295795180 !ruby/object:Gem::Requirement
|
62
51
|
none: false
|
63
52
|
requirements:
|
64
53
|
- - ! '>='
|
@@ -66,7 +55,7 @@ dependencies:
|
|
66
55
|
version: '0'
|
67
56
|
type: :development
|
68
57
|
prerelease: false
|
69
|
-
version_requirements: *
|
58
|
+
version_requirements: *70177295795180
|
70
59
|
description: Notifications as a Gem
|
71
60
|
email:
|
72
61
|
- ops@heroku.com
|
@@ -91,7 +80,7 @@ files:
|
|
91
80
|
- spec/client_spec.rb
|
92
81
|
- spec/service_spec.rb
|
93
82
|
- spec/spec_helper.rb
|
94
|
-
homepage:
|
83
|
+
homepage: https://github.com/heroku/comsat
|
95
84
|
licenses: []
|
96
85
|
post_install_message:
|
97
86
|
rdoc_options: []
|