uniform_notifier 1.7.0 → 1.8.0

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: ef9b9fde70b51c9e9f5ddb5478cdbcd425d0329c
4
- data.tar.gz: 3ea627b20c17915ae9c14553c5d01514ea0399e4
3
+ metadata.gz: 5b6f244cf3daade27b95d8dadce002ee46035650
4
+ data.tar.gz: fd8dd9175640c1c510f2139f264feff0fa997f15
5
5
  SHA512:
6
- metadata.gz: c7dd7f936ecda2ef1c3cf4f4b52eda389256b55bb296d5d201050ba0f43743371d4defc17029a7ddfdf620a292209a99e555018004c8eabee3ed4fa4fea4c01a
7
- data.tar.gz: d9516d3ed87ac936ffec1cfbadb669071ab2c7f9f8bc23883f82632d9bb6820bb04d96336081363eeb403d364886ebae942354666749e7e8d5d0f2a21fa6bb7b
6
+ metadata.gz: f135f3bce6f9af0199762df2ed7d47f4dc0295c0b4b9c158556cab6abe50a6563ee2cd2ea8a70b0f94468c26cbc0cce34f4294a05d1fd8846670e985adcdb060
7
+ data.tar.gz: 73a98aa616a6944609b0347f615d447ba4a64076326faa02e3c3ee84fce531aabded7b1050ad0b3eff5214dbd94c25156eba989625a2ae0ea870b01739c5866e
data/README.md CHANGED
@@ -24,15 +24,23 @@ if you want to notify by airbrake, you should install airbrake first
24
24
 
25
25
  gem install airbrake
26
26
 
27
+ if you want to notify by rollbar, you should install rollbar first
28
+
29
+ gem install rollbar
30
+
27
31
  if you want to notify by bugsnag, you should install bugsnag first
28
32
 
29
33
  gem install bugsnag
30
34
 
35
+ if you want to notify by slack, you should install slack-notifier first
36
+
37
+ gem install slack-notifier
38
+
31
39
  ### add it into Gemfile (Bundler)
32
40
 
33
41
  gem "uniform_notifier"
34
42
 
35
- you should add ruby-growl, ruby_gntp, xmpp4r, airbrake gem if you want.
43
+ you should add ruby-growl, ruby_gntp, xmpp4r, airbrake, bugsnag, slack-notifier gem if you want.
36
44
 
37
45
  ## Usage
38
46
 
@@ -56,11 +64,19 @@ By default, all notifiers are disabled, you should enable them first.
56
64
  # airbrake with options
57
65
  UniformNotifier.airbrake = { :error_class => Exception }
58
66
 
67
+ # rollbar
68
+ UniformNotifier.rollbar = true
69
+
59
70
  # bugsnag
60
71
  UniformNotifier.bugsnag = true
61
72
  # bugsnag with options
62
73
  UniformNotifier.bugsnag = { :api_key => 'something' }
63
74
 
75
+ # slack
76
+ UniformNotifier.slack = true
77
+ # slack with options
78
+ UniformNotifier.slack = { :webhook_url => 'http://some.slack.url', :foo => 'bar' }
79
+
64
80
  # customized logger
65
81
  logger = File.open('notify.log', 'a+')
66
82
  logger.sync = true
@@ -7,6 +7,7 @@ require 'uniform_notifier/xmpp'
7
7
  require 'uniform_notifier/rails_logger'
8
8
  require 'uniform_notifier/customized_logger'
9
9
  require 'uniform_notifier/airbrake'
10
+ require 'uniform_notifier/rollbar'
10
11
  require 'uniform_notifier/bugsnag'
11
12
  require 'uniform_notifier/slack'
12
13
  require 'uniform_notifier/raise'
@@ -15,9 +16,9 @@ module UniformNotifier
15
16
  class NotificationError < StandardError; end
16
17
 
17
18
  class <<self
18
- attr_accessor :alert, :console, :growl, :rails_logger, :xmpp, :airbrake, :bugsnag, :slack, :raise
19
+ attr_accessor :alert, :console, :growl, :rails_logger, :xmpp, :airbrake, :rollbar, :bugsnag, :slack, :raise
19
20
 
20
- NOTIFIERS = [JavascriptAlert, JavascriptConsole, Growl, Xmpp, RailsLogger, CustomizedLogger, AirbrakeNotifier, BugsnagNotifier, Raise]
21
+ NOTIFIERS = [JavascriptAlert, JavascriptConsole, Growl, Xmpp, RailsLogger, CustomizedLogger, AirbrakeNotifier, BugsnagNotifier, Raise, Slack]
21
22
 
22
23
  def active_notifiers
23
24
  NOTIFIERS.select { |notifier| notifier.active? }
@@ -20,8 +20,13 @@ module UniformNotifier
20
20
  def self.setup_connection_growl( growl )
21
21
  return unless growl
22
22
  require 'ruby-growl'
23
- @password = growl.instance_of?(Hash) ? growl[:password] : nil
24
- @growl = ::Growl.new 'localhost', 'uniform_notifier'
23
+ if growl.instance_of?(Hash)
24
+ @password = growl.include?(:password) ? growl[:password] : nil
25
+ @host = growl.include?(:host) ? growl[:host] : 'localhost'
26
+ end
27
+ @password ||= nil
28
+ @host ||= 'localhost'
29
+ @growl = ::Growl.new @host, 'uniform_notifier'
25
30
  @growl.add_notification 'uniform_notifier'
26
31
  @growl.password = @password
27
32
 
@@ -31,8 +36,13 @@ module UniformNotifier
31
36
  def self.setup_connection_gntp( growl )
32
37
  return unless growl
33
38
  require 'ruby_gntp'
34
- @password = growl.instance_of?(Hash) ? growl[:password] : nil
35
- @growl = GNTP.new('uniform_notifier', 'localhost', @password, 23053)
39
+ if growl.instance_of?(Hash)
40
+ @password = growl.include?(:password) ? growl[:password] : nil
41
+ @host = growl.include?(:host) ? growl[:host] : 'localhost'
42
+ end
43
+ @password ||= nil
44
+ @host ||= 'localhost'
45
+ @growl = GNTP.new('uniform_notifier', @host, @password, 23053)
36
46
  @growl.register({:notifications => [{
37
47
  :name => 'uniform_notifier',
38
48
  :enabled => true,
@@ -0,0 +1,16 @@
1
+ module UniformNotifier
2
+ class RollbarNotifier < Base
3
+ def self.active?
4
+ !!UniformNotifier.rollbar
5
+ end
6
+
7
+ protected
8
+
9
+ def self._out_of_channel_notify(data)
10
+ message = data.values.compact.join("\n")
11
+
12
+ exception = Exception.new(message)
13
+ Rollbar.info(exception)
14
+ end
15
+ end
16
+ end
@@ -1,3 +1,3 @@
1
1
  module UniformNotifier
2
- VERSION = "1.7.0"
2
+ VERSION = "1.8.0"
3
3
  end
@@ -30,6 +30,18 @@ describe UniformNotifier::Growl do
30
30
  UniformNotifier::Growl.out_of_channel_notify(:title => 'notify growl with password')
31
31
  end
32
32
 
33
+ it "should notify growl with host" do
34
+ growl = double('growl', :is_a? => true)
35
+ Growl.should_receive(:new).with('10.10.156.17', 'uniform_notifier').and_return(growl)
36
+ growl.should_receive(:add_notification).with('uniform_notifier')
37
+ growl.should_receive(:password=).with('123456')
38
+ growl.should_receive(:notify).with('uniform_notifier', 'Uniform Notifier', 'Uniform Notifier Growl has been turned on').ordered
39
+ growl.should_receive(:notify).with('uniform_notifier', 'Uniform Notifier', 'notify growl with password').ordered
40
+
41
+ UniformNotifier.growl = { :password => '123456', :host => '10.10.156.17' }
42
+ UniformNotifier::Growl.out_of_channel_notify(:title => 'notify growl with password')
43
+ end
44
+
33
45
  it "should notify growl with quiet" do
34
46
  growl = double('growl', :is_a? => true)
35
47
  Growl.should_receive(:new).with('localhost', 'uniform_notifier').and_return(growl)
@@ -0,0 +1,18 @@
1
+ require "spec_helper"
2
+
3
+ class Rollbar
4
+ # mock Rollbar
5
+ end
6
+
7
+ describe UniformNotifier::RollbarNotifier do
8
+ it "should not notify rollbar" do
9
+ UniformNotifier::RollbarNotifier.out_of_channel_notify(:title => "notify rollbar").should be_nil
10
+ end
11
+
12
+ it "should notify rollbar" do
13
+ Rollbar.should_receive(:info).with(UniformNotifier::Exception.new("notify rollbar"))
14
+
15
+ UniformNotifier.rollbar = true
16
+ UniformNotifier::RollbarNotifier.out_of_channel_notify(:title => "notify rollbar")
17
+ end
18
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uniform_notifier
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.0
4
+ version: 1.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Huang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-08 00:00:00.000000000 Z
11
+ date: 2015-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-growl
@@ -105,6 +105,7 @@ files:
105
105
  - lib/uniform_notifier/javascript_console.rb
106
106
  - lib/uniform_notifier/rails_logger.rb
107
107
  - lib/uniform_notifier/raise.rb
108
+ - lib/uniform_notifier/rollbar.rb
108
109
  - lib/uniform_notifier/slack.rb
109
110
  - lib/uniform_notifier/version.rb
110
111
  - lib/uniform_notifier/xmpp.rb
@@ -118,6 +119,7 @@ files:
118
119
  - spec/uniform_notifier/javascript_console_spec.rb
119
120
  - spec/uniform_notifier/rails_logger_spec.rb
120
121
  - spec/uniform_notifier/raise_spec.rb
122
+ - spec/uniform_notifier/rollbar_spec.rb
121
123
  - spec/uniform_notifier/slack_spec.rb
122
124
  - spec/uniform_notifier/xmpp_spec.rb
123
125
  - uniform_notifier.gemspec
@@ -156,5 +158,6 @@ test_files:
156
158
  - spec/uniform_notifier/javascript_console_spec.rb
157
159
  - spec/uniform_notifier/rails_logger_spec.rb
158
160
  - spec/uniform_notifier/raise_spec.rb
161
+ - spec/uniform_notifier/rollbar_spec.rb
159
162
  - spec/uniform_notifier/slack_spec.rb
160
163
  - spec/uniform_notifier/xmpp_spec.rb