chatty_crow_errbit 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/MIT-LICENSE +20 -0
- data/README.textile +34 -0
- data/Rakefile +37 -0
- data/app/assets/images/chattycrow_create.png +0 -0
- data/app/assets/images/chattycrow_goto.png +0 -0
- data/app/assets/images/chattycrow_inactive.png +0 -0
- data/app/assets/stylesheets/chatty_crow.css.erb +14 -0
- data/app/models/chatty_crow_errbit/chatty_crow_service.rb +76 -0
- data/lib/chatty_crow_errbit.rb +5 -0
- data/lib/chatty_crow_errbit/engine.rb +11 -0
- data/lib/chatty_crow_errbit/version.rb +3 -0
- data/lib/tasks/chatty_crow_errbit_tasks.rake +4 -0
- metadata +77 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: fb72a9a775dbb6c03e17e14ee1cb8ed802c68c14
|
4
|
+
data.tar.gz: 685cb335d0807e6019105e29092c2db199c534e9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f4da735eaeb9f9553381d02b3c94826a0f8ac58d256f7817a211456c33e2c7acbd07273a277c45d3776acab0b6a3a7c7126c63b7e5aeeead2ab18ecc5ef16968
|
7
|
+
data.tar.gz: f8d5d1c253bc8b6d417dc7b809b9976c75bb530a82cf01647520d66ba8ffa344360e766f58bd34eb8cc225e9541e8466fdbc5a71c58e32a2f5e035069c3286eb
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2014 YOURNAME
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.textile
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
!http://chattycrow.com/crow3logo.png!
|
2
|
+
|
3
|
+
h1. ChattyCrow - Errbit library
|
4
|
+
|
5
|
+
This library is usefull to send error messages from errbit to chatty crow channels!
|
6
|
+
|
7
|
+
h2. Installation
|
8
|
+
|
9
|
+
<pre>
|
10
|
+
# Gemfile in errbit!
|
11
|
+
gem 'chatty_crow_errbit', '~> 1.0.0'
|
12
|
+
bundle install
|
13
|
+
|
14
|
+
# Add styles to:
|
15
|
+
# app/assets/stylesheets/application.css.erb
|
16
|
+
*= require chatty_crow
|
17
|
+
|
18
|
+
# And restart your errbit web server.
|
19
|
+
</pre>
|
20
|
+
|
21
|
+
h2. Configuration in Errbit
|
22
|
+
|
23
|
+
Simple set token for channel, token for application and contacts (you can also manage contacts in administration of chattycrow).
|
24
|
+
|
25
|
+
h2. Screenshot
|
26
|
+
|
27
|
+
!https://raw.github.com/ChattyCrow/chattycrow_errbit/master/service.png!
|
28
|
+
|
29
|
+
h2. Contribution
|
30
|
+
|
31
|
+
* Fork
|
32
|
+
* Create new branch
|
33
|
+
* Add your hacks or feature
|
34
|
+
* Create pull request
|
data/Rakefile
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
begin
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'rdoc/task'
|
9
|
+
rescue LoadError
|
10
|
+
require 'rdoc/rdoc'
|
11
|
+
require 'rake/rdoctask'
|
12
|
+
RDoc::Task = Rake::RDocTask
|
13
|
+
end
|
14
|
+
|
15
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
16
|
+
rdoc.rdoc_dir = 'rdoc'
|
17
|
+
rdoc.title = 'ChattyCrowErrbit'
|
18
|
+
rdoc.options << '--line-numbers'
|
19
|
+
rdoc.rdoc_files.include('README.rdoc')
|
20
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
|
+
end
|
22
|
+
|
23
|
+
APP_RAKEFILE = File.expand_path('../test/dummy/Rakefile', __FILE__)
|
24
|
+
load 'rails/tasks/engine.rake'
|
25
|
+
|
26
|
+
Bundler::GemHelper.install_tasks
|
27
|
+
|
28
|
+
require 'rake/testtask'
|
29
|
+
|
30
|
+
Rake::TestTask.new(:test) do |t|
|
31
|
+
t.libs << 'lib'
|
32
|
+
t.libs << 'test'
|
33
|
+
t.pattern = 'test/**/*_test.rb'
|
34
|
+
t.verbose = false
|
35
|
+
end
|
36
|
+
|
37
|
+
task default: :test
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,14 @@
|
|
1
|
+
/** Chatty crow icons */
|
2
|
+
<% notification_service = 'chattycrow' %>
|
3
|
+
div.notification_service.nested label.<%= notification_service %> {
|
4
|
+
background: url(<%= asset_path "#{ notification_service }_inactive.png" %>) no-repeat;
|
5
|
+
}
|
6
|
+
div.notification_service.nested label.r_on.<%= notification_service %> {
|
7
|
+
background: url(<%= asset_path "#{ notification_service }_create.png" %>) no-repeat;
|
8
|
+
}
|
9
|
+
#action-bar a.<%= notification_service %>_create {
|
10
|
+
background: transparent url(<%= asset_path "#{ notification_service }_create.png" %>) 6px 5px no-repeat;
|
11
|
+
}
|
12
|
+
#action-bar a.<%= notification_service %>_goto {
|
13
|
+
background: transparent url(<%= asset_path "#{ notification_service }_goto.png" %>) 6px 5px no-repeat;
|
14
|
+
}
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'chatty_crow'
|
2
|
+
|
3
|
+
module ChattyCrowErrbit
|
4
|
+
# Chatty crow notification service for Errbit
|
5
|
+
class ChattyCrowService < ::NotificationService
|
6
|
+
Label = 'chattycrow'
|
7
|
+
|
8
|
+
SERVICES = %w(ios android skype jabber mail sms)
|
9
|
+
|
10
|
+
Fields += [
|
11
|
+
[:service_url, { placeholder: 'http://chattycrow.com/api/v1', label: 'API URL' }],
|
12
|
+
[:service, { placeholder: "#{SERVICES.join(', ')}", label: "Service (valid options: #{SERVICES.join(', ')})" }],
|
13
|
+
[:api_token, { placeholder: 'Application token', label: 'APP Token' }],
|
14
|
+
[:sender_name, { placeholder: 'Channel token', label: 'Channel Token' }],
|
15
|
+
[:user_id, { placeholder: 'test@jabbim.com, test2@jabbim.com', label: 'Contacts separated by comma' }]
|
16
|
+
]
|
17
|
+
|
18
|
+
def check_params
|
19
|
+
# Validation without room id, it's optional!
|
20
|
+
if Fields[0...-1].find { |f| self[f[0]].blank? && self[f[2]].blank? }
|
21
|
+
errors.add :base, 'You must specify your Service url, application token and channel token'
|
22
|
+
end
|
23
|
+
|
24
|
+
# Validate services
|
25
|
+
errors.add :base, 'Invalid service' unless SERVICES.include?(service.to_s)
|
26
|
+
end
|
27
|
+
|
28
|
+
def create_notification(problem)
|
29
|
+
# Get message for problem
|
30
|
+
payload = payload(problem)
|
31
|
+
|
32
|
+
# Contacts?
|
33
|
+
contacts = user_id.blank? ? nil : user_id.gsub(/;/i, ",").split(",").map(&:strip).reject(&:empty?)
|
34
|
+
|
35
|
+
# Set URL
|
36
|
+
::ChattyCrow.configure do |config|
|
37
|
+
config.host = service_url
|
38
|
+
end
|
39
|
+
|
40
|
+
# Send message!
|
41
|
+
if payload.is_a?(Hash)
|
42
|
+
::ChattyCrow.send("send_#{service.downcase}", payload.merge(channel: sender_name, contacts: contacts, token: api_token))
|
43
|
+
else
|
44
|
+
::ChattyCrow.send("send_#{service.downcase}", payload, channel: sender_name, contacts: contacts, token: api_token)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def payload(problem)
|
51
|
+
res = message(problem)
|
52
|
+
case service.downcase
|
53
|
+
when 'android'
|
54
|
+
res = { payload: { data: { alert: res } } }
|
55
|
+
when 'ios'
|
56
|
+
res = { payload: { aps: { alert: res } } }
|
57
|
+
when 'mail'
|
58
|
+
res = { html_body: res, subject: "Problem #{problem.app.name}" }
|
59
|
+
end
|
60
|
+
|
61
|
+
res
|
62
|
+
end
|
63
|
+
|
64
|
+
def message(problem)
|
65
|
+
<<-MESSAGE
|
66
|
+
#{problem.app.name}
|
67
|
+
#{config_protocol}://#{Errbit::Config.host}/apps/#{problem.app.id}
|
68
|
+
#{notification_description problem}
|
69
|
+
MESSAGE
|
70
|
+
end
|
71
|
+
|
72
|
+
def config_protocol
|
73
|
+
Errbit::Config.protocol || 'http'
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module ChattyCrowErrbit
|
2
|
+
# Rails engine
|
3
|
+
class Engine < ::Rails::Engine
|
4
|
+
isolate_namespace ChattyCrowErrbit
|
5
|
+
|
6
|
+
initializer 'chatty_crow_errbit.require_model' do
|
7
|
+
# Very ugly workaround to force ruby discover NotificationService sublcass!
|
8
|
+
ChattyCrowErrbit::ChattyCrowService
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
metadata
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: chatty_crow_errbit
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Netbrick s.r.o.
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-10-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: chatty_crow
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.2'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.2.1
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.2'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.2.1
|
33
|
+
description: Extension for errbit error handler to send messages via ChattyCrow
|
34
|
+
email:
|
35
|
+
- support@netbrick.eu
|
36
|
+
- info@chattycrow.com
|
37
|
+
executables: []
|
38
|
+
extensions: []
|
39
|
+
extra_rdoc_files: []
|
40
|
+
files:
|
41
|
+
- MIT-LICENSE
|
42
|
+
- README.textile
|
43
|
+
- Rakefile
|
44
|
+
- app/assets/images/chattycrow_create.png
|
45
|
+
- app/assets/images/chattycrow_goto.png
|
46
|
+
- app/assets/images/chattycrow_inactive.png
|
47
|
+
- app/assets/stylesheets/chatty_crow.css.erb
|
48
|
+
- app/models/chatty_crow_errbit/chatty_crow_service.rb
|
49
|
+
- lib/chatty_crow_errbit.rb
|
50
|
+
- lib/chatty_crow_errbit/engine.rb
|
51
|
+
- lib/chatty_crow_errbit/version.rb
|
52
|
+
- lib/tasks/chatty_crow_errbit_tasks.rake
|
53
|
+
homepage: http://www.chattycrow.com
|
54
|
+
licenses:
|
55
|
+
- MIT
|
56
|
+
metadata: {}
|
57
|
+
post_install_message:
|
58
|
+
rdoc_options: []
|
59
|
+
require_paths:
|
60
|
+
- lib
|
61
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
requirements: []
|
72
|
+
rubyforge_project:
|
73
|
+
rubygems_version: 2.4.2
|
74
|
+
signing_key:
|
75
|
+
specification_version: 4
|
76
|
+
summary: Errbit error notification handler
|
77
|
+
test_files: []
|