exception-notifier-pushover 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.rspec +2 -0
- data/.ruby-verion +1 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/Guardfile +9 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +8 -0
- data/exception_notifier-pushover.gemspec +37 -0
- data/lib/exception_notifier/pushover_notifier.rb +40 -0
- data/spec/exception_notifier/pushover_notifier_spec.rb +22 -0
- data/spec/spec_helper.rb +25 -0
- data/spec/support/fake_pushover.rb +14 -0
- metadata +187 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 456d768777387d73869190d5abe0532e75bb8ca7
|
4
|
+
data.tar.gz: e5ab1e976bea2bcd7e81989313857e39af5e5b8f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d60c5bc3bc9df59373b9d799c74a38569bb23a39d864a682e85a1de250833c0fb9c9344ed318e41fa5e8e06d9af8f9150cb0b1600d7636ed545551750c1159dc
|
7
|
+
data.tar.gz: 30a305ceb3882c8e13562a89ccd80b5dee564f22f74893964a7dedfd6a34deb0baf03131bb83daa52c42203e7f87c40a0b6ac4a8082b91e6d3b63d1a95abd662
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.ruby-verion
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.0.0
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Sascha Wessel
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# ExceptionNotifier::Pushover
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'exception_notification-pushover'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install exception_notification-pushover
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "exception-notifier-pushover"
|
7
|
+
spec.version = "0.0.1"
|
8
|
+
spec.authors = ["Sascha Wessel"]
|
9
|
+
spec.email = ["swessel@gr4yweb.de"]
|
10
|
+
spec.description = %q{a pushover notifier for exception_notification}
|
11
|
+
spec.summary = %q{a pushover notifier for exception_notification}
|
12
|
+
spec.homepage = "https://github.com/gr4y/exception-notifier-pushover"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files`.split($/)
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
21
|
+
spec.add_development_dependency "rake"
|
22
|
+
|
23
|
+
# for specs
|
24
|
+
spec.add_development_dependency "rspec"
|
25
|
+
spec.add_development_dependency "guard"
|
26
|
+
spec.add_development_dependency "guard-rspec"
|
27
|
+
|
28
|
+
# for coverage report
|
29
|
+
spec.add_development_dependency "simplecov"
|
30
|
+
|
31
|
+
# for mocking webservices
|
32
|
+
spec.add_development_dependency "webmock"
|
33
|
+
spec.add_development_dependency "sinatra"
|
34
|
+
|
35
|
+
# for http
|
36
|
+
spec.add_dependency "httparty"
|
37
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
|
3
|
+
module ExceptionNotifier
|
4
|
+
class PushoverNotifier
|
5
|
+
|
6
|
+
attr_accessor :api_token, :url, :logger
|
7
|
+
attr_accessor :default_options
|
8
|
+
|
9
|
+
def initialize(options)
|
10
|
+
@api_token = options.delete(:api_token)
|
11
|
+
@url = options.delete(:url)
|
12
|
+
@logger = options.delete(:logger)
|
13
|
+
@default_options = options
|
14
|
+
end
|
15
|
+
|
16
|
+
def call(exception, options={})
|
17
|
+
return if !is_active?
|
18
|
+
server = ::Socket.gethostname
|
19
|
+
options = options.merge(@default_options)
|
20
|
+
message = "#{server}: A new exception occured: #{exception.message} on #{exception.backtrace.first}"
|
21
|
+
options[:users].each do |user_token|
|
22
|
+
response = send(user_token, message)
|
23
|
+
if response.code == 200 && response.parsed_response[:status]
|
24
|
+
@logger.error("Can't send notification to user with token #{user_token}") if defined?(@logger)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
def send(user_token, message)
|
31
|
+
options = { :body => { :token => @api_token, :user => user_token, :message => message } }
|
32
|
+
::HTTParty.post(@url, options)
|
33
|
+
end
|
34
|
+
|
35
|
+
def is_active?
|
36
|
+
!@api_token.empty? && !@url.empty?
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'logger'
|
3
|
+
|
4
|
+
describe ExceptionNotifier::PushoverNotifier do
|
5
|
+
|
6
|
+
let(:options) do
|
7
|
+
{ :url => 'https://api.pushover.net/1/messags.json', :logger => ::Logger.new(STDOUT),
|
8
|
+
:api_token => '123456789', :users => ['abcdefgh', 'ijklmnp'] }
|
9
|
+
end
|
10
|
+
|
11
|
+
subject(:notifier) { ExceptionNotifier::PushoverNotifier.new(options) }
|
12
|
+
it 'has to respond to call method' do
|
13
|
+
expect(notifier).to respond_to(:call)
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'has sent a message cause an exception was thrown' do
|
17
|
+
throw_exception do |e|
|
18
|
+
notifier.call(e)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
SimpleCov.start do
|
3
|
+
add_group 'Lib', 'lib'
|
4
|
+
add_filter '/spec/'
|
5
|
+
end
|
6
|
+
|
7
|
+
def throw_exception(&block)
|
8
|
+
begin
|
9
|
+
raise "This is an intended exception"
|
10
|
+
rescue Exception => e
|
11
|
+
block.call(e)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
require 'support/fake_pushover'
|
16
|
+
require 'rspec'
|
17
|
+
require 'webmock/rspec'
|
18
|
+
RSpec.configure do |config|
|
19
|
+
config.before(:each) do
|
20
|
+
WebMock.disable_net_connect!
|
21
|
+
stub_request(:any, /api.pushover.net/).to_rack(FakePushover)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
require 'exception_notifier/pushover_notifier'
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'sinatra/base'
|
2
|
+
|
3
|
+
class FakePushover < Sinatra::Base
|
4
|
+
|
5
|
+
post '/1/messages.json' do
|
6
|
+
puts params.inspect
|
7
|
+
|
8
|
+
result = Hash.new
|
9
|
+
result[:status] = 1
|
10
|
+
result[:request] = "e460545a8b333d0da2f3602aff3133d6"
|
11
|
+
JSON.encode(result)
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
metadata
ADDED
@@ -0,0 +1,187 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: exception-notifier-pushover
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sascha Wessel
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-12-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: guard
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: guard-rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: simplecov
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: webmock
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: sinatra
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: httparty
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - '>='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - '>='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
description: a pushover notifier for exception_notification
|
140
|
+
email:
|
141
|
+
- swessel@gr4yweb.de
|
142
|
+
executables: []
|
143
|
+
extensions: []
|
144
|
+
extra_rdoc_files: []
|
145
|
+
files:
|
146
|
+
- .gitignore
|
147
|
+
- .rspec
|
148
|
+
- .ruby-verion
|
149
|
+
- .travis.yml
|
150
|
+
- Gemfile
|
151
|
+
- Guardfile
|
152
|
+
- LICENSE.txt
|
153
|
+
- README.md
|
154
|
+
- Rakefile
|
155
|
+
- exception_notifier-pushover.gemspec
|
156
|
+
- lib/exception_notifier/pushover_notifier.rb
|
157
|
+
- spec/exception_notifier/pushover_notifier_spec.rb
|
158
|
+
- spec/spec_helper.rb
|
159
|
+
- spec/support/fake_pushover.rb
|
160
|
+
homepage: https://github.com/gr4y/exception-notifier-pushover
|
161
|
+
licenses:
|
162
|
+
- MIT
|
163
|
+
metadata: {}
|
164
|
+
post_install_message:
|
165
|
+
rdoc_options: []
|
166
|
+
require_paths:
|
167
|
+
- lib
|
168
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
169
|
+
requirements:
|
170
|
+
- - '>='
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: '0'
|
173
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
174
|
+
requirements:
|
175
|
+
- - '>='
|
176
|
+
- !ruby/object:Gem::Version
|
177
|
+
version: '0'
|
178
|
+
requirements: []
|
179
|
+
rubyforge_project:
|
180
|
+
rubygems_version: 2.1.6
|
181
|
+
signing_key:
|
182
|
+
specification_version: 4
|
183
|
+
summary: a pushover notifier for exception_notification
|
184
|
+
test_files:
|
185
|
+
- spec/exception_notifier/pushover_notifier_spec.rb
|
186
|
+
- spec/spec_helper.rb
|
187
|
+
- spec/support/fake_pushover.rb
|