uniform_notifier 1.9.0 → 1.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +14 -2
- data/lib/uniform_notifier.rb +11 -5
- data/lib/uniform_notifier/growl.rb +1 -1
- data/lib/uniform_notifier/honeybadger.rb +21 -0
- data/lib/uniform_notifier/version.rb +1 -1
- data/spec/uniform_notifier/airbrake_spec.rb +4 -4
- data/spec/uniform_notifier/base_spec.rb +5 -5
- data/spec/uniform_notifier/bugsnag_spec.rb +9 -9
- data/spec/uniform_notifier/customized_logger_spec.rb +4 -4
- data/spec/uniform_notifier/growl_spec.rb +22 -22
- data/spec/uniform_notifier/honeybadger_spec.rb +25 -0
- data/spec/uniform_notifier/javascript_alert_spec.rb +3 -3
- data/spec/uniform_notifier/javascript_console_spec.rb +3 -3
- data/spec/uniform_notifier/rails_logger_spec.rb +4 -4
- data/spec/uniform_notifier/raise_spec.rb +2 -2
- data/spec/uniform_notifier/rollbar_spec.rb +3 -3
- data/spec/uniform_notifier/slack_spec.rb +2 -2
- data/spec/uniform_notifier/xmpp_spec.rb +22 -22
- data/uniform_notifier.gemspec +1 -0
- metadata +8 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ce5c6778339ac98c3683322370c55b36e2e0f6d8
|
4
|
+
data.tar.gz: 2c10528a49539b46b7cdfbde658d5032e04ccffb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bdff272e464293c384f81eb736b0e1d639293ae84b97c3212cff43f8ea5e150f43095f5f4efd055c57c50eb9be4e9d664d75efcf4b3d07d16083b058cf65e335
|
7
|
+
data.tar.gz: 0918ca02b1d871578e5cd5c45bb0037553ef7739adcbdd73d4655dad8d796290a0890e38de0fe1168c57af2dce392d458ab998507141a3ed46ed1c1cdea466a4
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# UniformNotifier
|
2
2
|
|
3
|
-
uniform_notifier is extracted from [bullet][0], it gives you the ability to send notification through rails logger, customized logger, javascript alert, javascript console, growl, xmpp and
|
3
|
+
uniform_notifier is extracted from [bullet][0], it gives you the ability to send notification through rails logger, customized logger, javascript alert, javascript console, growl, xmpp, airbrake and honeybadger.
|
4
4
|
|
5
5
|
## Install
|
6
6
|
|
@@ -24,6 +24,10 @@ 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 Honeybadger, you should install honeybadger first
|
28
|
+
|
29
|
+
gem install honeybadger
|
30
|
+
|
27
31
|
if you want to notify by rollbar, you should install rollbar first
|
28
32
|
|
29
33
|
gem install rollbar
|
@@ -40,7 +44,7 @@ if you want to notify by slack, you should install slack-notifier first
|
|
40
44
|
|
41
45
|
gem "uniform_notifier"
|
42
46
|
|
43
|
-
you should add ruby-growl, ruby_gntp, xmpp4r, airbrake, bugsnag, slack-notifier gem if you want.
|
47
|
+
you should add ruby-growl, ruby_gntp, xmpp4r, airbrake, bugsnag, honeybadger, slack-notifier gem if you want.
|
44
48
|
|
45
49
|
## Usage
|
46
50
|
|
@@ -64,6 +68,14 @@ By default, all notifiers are disabled, you should enable them first.
|
|
64
68
|
# airbrake with options
|
65
69
|
UniformNotifier.airbrake = { :error_class => Exception }
|
66
70
|
|
71
|
+
# Honeybadger
|
72
|
+
#
|
73
|
+
# Reporting live data from development is disabled by default. Ensure
|
74
|
+
# that the `report_data` option is enabled via configuration.
|
75
|
+
UniformNotifier.honeybadger = true
|
76
|
+
# Honeybadger with options
|
77
|
+
UniformNotifier.honeybadger = { :error_class => 'Exception' }
|
78
|
+
|
67
79
|
# rollbar
|
68
80
|
UniformNotifier.rollbar = true
|
69
81
|
|
data/lib/uniform_notifier.rb
CHANGED
@@ -3,6 +3,7 @@ require 'uniform_notifier/errors'
|
|
3
3
|
require 'uniform_notifier/javascript_alert'
|
4
4
|
require 'uniform_notifier/javascript_console'
|
5
5
|
require 'uniform_notifier/growl'
|
6
|
+
require 'uniform_notifier/honeybadger'
|
6
7
|
require 'uniform_notifier/xmpp'
|
7
8
|
require 'uniform_notifier/rails_logger'
|
8
9
|
require 'uniform_notifier/customized_logger'
|
@@ -13,37 +14,42 @@ require 'uniform_notifier/slack'
|
|
13
14
|
require 'uniform_notifier/raise'
|
14
15
|
|
15
16
|
class UniformNotifier
|
16
|
-
AVAILABLE_NOTIFIERS = [:alert, :console, :growl, :
|
17
|
-
:airbrake, :rollbar, :bugsnag, :slack, :raise]
|
17
|
+
AVAILABLE_NOTIFIERS = [:alert, :console, :growl, :honeybadger, :xmpp, :rails_logger,
|
18
|
+
:customized_logger, :airbrake, :rollbar, :bugsnag, :slack, :raise]
|
18
19
|
|
19
|
-
NOTIFIERS = [JavascriptAlert, JavascriptConsole, Growl, Xmpp, RailsLogger,
|
20
|
-
AirbrakeNotifier, RollbarNotifier, BugsnagNotifier, Raise, Slack]
|
20
|
+
NOTIFIERS = [JavascriptAlert, JavascriptConsole, Growl, HoneybadgerNotifier, Xmpp, RailsLogger,
|
21
|
+
CustomizedLogger, AirbrakeNotifier, RollbarNotifier, BugsnagNotifier, Raise, Slack]
|
21
22
|
|
22
23
|
class NotificationError < StandardError; end
|
23
24
|
|
24
25
|
class <<self
|
25
|
-
attr_accessor
|
26
|
+
attr_accessor(*AVAILABLE_NOTIFIERS)
|
26
27
|
|
27
28
|
def active_notifiers
|
28
29
|
NOTIFIERS.select { |notifier| notifier.active? }
|
29
30
|
end
|
30
31
|
|
32
|
+
undef :growl=
|
31
33
|
def growl=(growl)
|
32
34
|
UniformNotifier::Growl.setup_connection(growl)
|
33
35
|
end
|
34
36
|
|
37
|
+
undef :xmpp=
|
35
38
|
def xmpp=(xmpp)
|
36
39
|
UniformNotifier::Xmpp.setup_connection(xmpp)
|
37
40
|
end
|
38
41
|
|
42
|
+
undef :customized_logger=
|
39
43
|
def customized_logger=(logdev)
|
40
44
|
UniformNotifier::CustomizedLogger.setup(logdev)
|
41
45
|
end
|
42
46
|
|
47
|
+
undef :slack=
|
43
48
|
def slack=(slack)
|
44
49
|
UniformNotifier::Slack.setup_connection(slack)
|
45
50
|
end
|
46
51
|
|
52
|
+
undef :raise=
|
47
53
|
def raise=(exception_class)
|
48
54
|
UniformNotifier::Raise.setup_connection(exception_class)
|
49
55
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class UniformNotifier
|
2
|
+
class HoneybadgerNotifier < Base
|
3
|
+
def self.active?
|
4
|
+
!!UniformNotifier.honeybadger
|
5
|
+
end
|
6
|
+
|
7
|
+
protected
|
8
|
+
|
9
|
+
def self._out_of_channel_notify(data)
|
10
|
+
message = data.values.compact.join("\n")
|
11
|
+
|
12
|
+
opt = {}
|
13
|
+
if UniformNotifier.honeybadger.is_a?(Hash)
|
14
|
+
opt = UniformNotifier.honeybadger
|
15
|
+
end
|
16
|
+
|
17
|
+
exception = Exception.new(message)
|
18
|
+
Honeybadger.notify(exception, opt)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -4,20 +4,20 @@ class Airbrake
|
|
4
4
|
# mock Airbrake
|
5
5
|
end
|
6
6
|
|
7
|
-
describe UniformNotifier::AirbrakeNotifier do
|
7
|
+
RSpec.describe UniformNotifier::AirbrakeNotifier do
|
8
8
|
it "should not notify airbrake" do
|
9
|
-
UniformNotifier::AirbrakeNotifier.out_of_channel_notify(:title => "notify airbrake").
|
9
|
+
expect(UniformNotifier::AirbrakeNotifier.out_of_channel_notify(:title => "notify airbrake")).to be_nil
|
10
10
|
end
|
11
11
|
|
12
12
|
it "should notify airbrake" do
|
13
|
-
Airbrake.
|
13
|
+
expect(Airbrake).to receive(:notify).with(UniformNotifier::Exception.new("notify airbrake"), {})
|
14
14
|
|
15
15
|
UniformNotifier.airbrake = true
|
16
16
|
UniformNotifier::AirbrakeNotifier.out_of_channel_notify(:title => "notify airbrake")
|
17
17
|
end
|
18
18
|
|
19
19
|
it "should notify airbrake" do
|
20
|
-
Airbrake.
|
20
|
+
expect(Airbrake).to receive(:notify).with(UniformNotifier::Exception.new("notify airbrake"), :foo => :bar)
|
21
21
|
|
22
22
|
UniformNotifier.airbrake = { :foo => :bar }
|
23
23
|
UniformNotifier::AirbrakeNotifier.out_of_channel_notify("notify airbrake")
|
@@ -1,21 +1,21 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe UniformNotifier::Base do
|
3
|
+
RSpec.describe UniformNotifier::Base do
|
4
4
|
context "#inline_channel_notify" do
|
5
5
|
before do
|
6
|
-
UniformNotifier::Base.
|
6
|
+
allow(UniformNotifier::Base).to receive(:active?).and_return(true)
|
7
7
|
end
|
8
8
|
it "should keep the compatibility" do
|
9
|
-
UniformNotifier::Base.
|
9
|
+
expect(UniformNotifier::Base).to receive(:_inline_notify).once.with(:title => "something")
|
10
10
|
UniformNotifier::Base.inline_notify("something")
|
11
11
|
end
|
12
12
|
end
|
13
13
|
context "#out_of_channel_notify" do
|
14
14
|
before do
|
15
|
-
UniformNotifier::Base.
|
15
|
+
allow(UniformNotifier::Base).to receive(:active?).and_return(true)
|
16
16
|
end
|
17
17
|
it "should keep the compatibility" do
|
18
|
-
UniformNotifier::Base.
|
18
|
+
expect(UniformNotifier::Base).to receive(:_out_of_channel_notify).once.with(:title => "something")
|
19
19
|
UniformNotifier::Base.out_of_channel_notify("something")
|
20
20
|
end
|
21
21
|
end
|
@@ -4,24 +4,24 @@ class Bugsnag
|
|
4
4
|
# mock Bugsnag
|
5
5
|
end
|
6
6
|
|
7
|
-
describe UniformNotifier::BugsnagNotifier do
|
7
|
+
RSpec.describe UniformNotifier::BugsnagNotifier do
|
8
8
|
let(:notification_data) { {} }
|
9
9
|
it "should not notify bugsnag" do
|
10
|
-
Bugsnag.
|
10
|
+
expect(Bugsnag).not_to receive(:notify)
|
11
11
|
UniformNotifier::BugsnagNotifier.out_of_channel_notify(notification_data)
|
12
12
|
end
|
13
13
|
context "with string notification" do
|
14
14
|
let(:notification_data) { {:user => 'user', :title => 'notify bugsnag', :url => 'URL', body: 'something'} }
|
15
15
|
|
16
16
|
it "should notify bugsnag" do
|
17
|
-
Bugsnag.
|
17
|
+
expect(Bugsnag).to receive(:notify).with(UniformNotifier::Exception.new(notification_data[:title]), :grouping_hash => notification_data[:body], :notification => notification_data)
|
18
18
|
|
19
19
|
UniformNotifier.bugsnag = true
|
20
20
|
UniformNotifier::BugsnagNotifier.out_of_channel_notify(notification_data)
|
21
21
|
end
|
22
22
|
|
23
23
|
it "should notify bugsnag with option" do
|
24
|
-
Bugsnag.
|
24
|
+
expect(Bugsnag).to receive(:notify).with(UniformNotifier::Exception.new(notification_data[:title]), :foo => :bar, :grouping_hash => notification_data[:body], :notification => notification_data)
|
25
25
|
|
26
26
|
UniformNotifier.bugsnag = { :foo => :bar }
|
27
27
|
UniformNotifier::BugsnagNotifier.out_of_channel_notify(notification_data)
|
@@ -31,14 +31,14 @@ describe UniformNotifier::BugsnagNotifier do
|
|
31
31
|
let(:notification_data) { "notify bugsnag" }
|
32
32
|
|
33
33
|
it "should notify bugsnag" do
|
34
|
-
Bugsnag.
|
34
|
+
expect(Bugsnag).to receive(:notify).with(UniformNotifier::Exception.new("notify bugsnag"), :grouping_hash => "notify bugsnag", :notification => {:title => "notify bugsnag"})
|
35
35
|
|
36
36
|
UniformNotifier.bugsnag = true
|
37
37
|
UniformNotifier::BugsnagNotifier.out_of_channel_notify(notification_data)
|
38
38
|
end
|
39
39
|
|
40
40
|
it "should notify bugsnag with option" do
|
41
|
-
Bugsnag.
|
41
|
+
expect(Bugsnag).to receive(:notify).with(UniformNotifier::Exception.new("notify bugsnag"), :foo => :bar, :grouping_hash => "notify bugsnag", :notification => {:title => "notify bugsnag"})
|
42
42
|
|
43
43
|
UniformNotifier.bugsnag = { :foo => :bar }
|
44
44
|
UniformNotifier::BugsnagNotifier.out_of_channel_notify(notification_data)
|
@@ -46,9 +46,9 @@ describe UniformNotifier::BugsnagNotifier do
|
|
46
46
|
end
|
47
47
|
|
48
48
|
it "should notify bugsnag with correct backtrace" do
|
49
|
-
Bugsnag.
|
50
|
-
error.
|
51
|
-
error.backtrace.
|
49
|
+
expect(Bugsnag).to receive(:notify) do |error|
|
50
|
+
expect(error).to be_a UniformNotifier::Exception
|
51
|
+
expect(error.backtrace).to eq ["bugsnag spec test"]
|
52
52
|
end
|
53
53
|
UniformNotifier.bugsnag = true
|
54
54
|
UniformNotifier::BugsnagNotifier.out_of_channel_notify(backtrace: ["bugsnag spec test"])
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
describe UniformNotifier::CustomizedLogger do
|
3
|
+
RSpec.describe UniformNotifier::CustomizedLogger do
|
4
4
|
it "should not notify to customized logger" do
|
5
|
-
UniformNotifier::CustomizedLogger.out_of_channel_notify(:title => "notify rails logger").
|
5
|
+
expect(UniformNotifier::CustomizedLogger.out_of_channel_notify(:title => "notify rails logger")).to be_nil
|
6
6
|
end
|
7
7
|
|
8
8
|
it "should notify to customized logger" do
|
@@ -10,12 +10,12 @@ describe UniformNotifier::CustomizedLogger do
|
|
10
10
|
logger.sync = true
|
11
11
|
|
12
12
|
now = Time.now
|
13
|
-
Time.
|
13
|
+
allow(Time).to receive(:now).and_return(now)
|
14
14
|
UniformNotifier.customized_logger = logger
|
15
15
|
UniformNotifier::CustomizedLogger.out_of_channel_notify(:title => "notify rails logger")
|
16
16
|
|
17
17
|
logger.seek(0)
|
18
|
-
logger.read.
|
18
|
+
expect(logger.read).to eq "#{now.strftime("%Y-%m-%d %H:%M:%S")}[WARN] notify rails logger"
|
19
19
|
|
20
20
|
File.delete('test.log')
|
21
21
|
end
|
@@ -1,18 +1,18 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe UniformNotifier::Growl do
|
3
|
+
RSpec.describe UniformNotifier::Growl do
|
4
4
|
|
5
5
|
it "should not notify growl" do
|
6
|
-
UniformNotifier::Growl.out_of_channel_notify(:title => 'notify growl').
|
6
|
+
expect(UniformNotifier::Growl.out_of_channel_notify(:title => 'notify growl')).to be_nil
|
7
7
|
end
|
8
8
|
|
9
9
|
it "should notify growl without password" do
|
10
10
|
growl = double('growl', :is_a? => true)
|
11
|
-
Growl.
|
12
|
-
growl.
|
13
|
-
growl.
|
14
|
-
growl.
|
15
|
-
growl.
|
11
|
+
expect(Growl).to receive(:new).with('localhost', 'uniform_notifier').and_return(growl)
|
12
|
+
expect(growl).to receive(:add_notification).with('uniform_notifier')
|
13
|
+
expect(growl).to receive(:password=).with(nil)
|
14
|
+
expect(growl).to receive(:notify).with('uniform_notifier', 'Uniform Notifier', 'Uniform Notifier Growl has been turned on').ordered
|
15
|
+
expect(growl).to receive(:notify).with('uniform_notifier', 'Uniform Notifier', 'notify growl without password').ordered
|
16
16
|
|
17
17
|
UniformNotifier.growl = true
|
18
18
|
UniformNotifier::Growl.out_of_channel_notify(:title => 'notify growl without password')
|
@@ -20,11 +20,11 @@ describe UniformNotifier::Growl do
|
|
20
20
|
|
21
21
|
it "should notify growl with password" do
|
22
22
|
growl = double('growl', :is_a? => true)
|
23
|
-
Growl.
|
24
|
-
growl.
|
25
|
-
growl.
|
26
|
-
growl.
|
27
|
-
growl.
|
23
|
+
expect(Growl).to receive(:new).with('localhost', 'uniform_notifier').and_return(growl)
|
24
|
+
expect(growl).to receive(:add_notification).with('uniform_notifier')
|
25
|
+
expect(growl).to receive(:password=).with('123456')
|
26
|
+
expect(growl).to receive(:notify).with('uniform_notifier', 'Uniform Notifier', 'Uniform Notifier Growl has been turned on').ordered
|
27
|
+
expect(growl).to receive(:notify).with('uniform_notifier', 'Uniform Notifier', 'notify growl with password').ordered
|
28
28
|
|
29
29
|
UniformNotifier.growl = { :password => '123456' }
|
30
30
|
UniformNotifier::Growl.out_of_channel_notify(:title => 'notify growl with password')
|
@@ -32,11 +32,11 @@ describe UniformNotifier::Growl do
|
|
32
32
|
|
33
33
|
it "should notify growl with host" do
|
34
34
|
growl = double('growl', :is_a? => true)
|
35
|
-
Growl.
|
36
|
-
growl.
|
37
|
-
growl.
|
38
|
-
growl.
|
39
|
-
growl.
|
35
|
+
expect(Growl).to receive(:new).with('10.10.156.17', 'uniform_notifier').and_return(growl)
|
36
|
+
expect(growl).to receive(:add_notification).with('uniform_notifier')
|
37
|
+
expect(growl).to receive(:password=).with('123456')
|
38
|
+
expect(growl).to receive(:notify).with('uniform_notifier', 'Uniform Notifier', 'Uniform Notifier Growl has been turned on').ordered
|
39
|
+
expect(growl).to receive(:notify).with('uniform_notifier', 'Uniform Notifier', 'notify growl with password').ordered
|
40
40
|
|
41
41
|
UniformNotifier.growl = { :password => '123456', :host => '10.10.156.17' }
|
42
42
|
UniformNotifier::Growl.out_of_channel_notify(:title => 'notify growl with password')
|
@@ -44,11 +44,11 @@ describe UniformNotifier::Growl do
|
|
44
44
|
|
45
45
|
it "should notify growl with quiet" do
|
46
46
|
growl = double('growl', :is_a? => true)
|
47
|
-
Growl.
|
48
|
-
growl.
|
49
|
-
growl.
|
50
|
-
growl.
|
51
|
-
growl.
|
47
|
+
expect(Growl).to receive(:new).with('localhost', 'uniform_notifier').and_return(growl)
|
48
|
+
expect(growl).to receive(:add_notification).with('uniform_notifier')
|
49
|
+
expect(growl).to receive(:password=).with('123456')
|
50
|
+
expect(growl).not_to receive(:notify).with('uniform_notifier', 'Uniform Notifier', 'Uniform Notifier Growl has been turned on')
|
51
|
+
expect(growl).to receive(:notify).with('uniform_notifier', 'Uniform Notifier', 'notify growl with password')
|
52
52
|
|
53
53
|
UniformNotifier.growl = { :password => '123456', :quiet => true }
|
54
54
|
UniformNotifier::Growl.out_of_channel_notify(:title => 'notify growl with password')
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
class Honeybadger
|
4
|
+
# mock Honeybadger
|
5
|
+
end
|
6
|
+
|
7
|
+
RSpec.describe UniformNotifier::HoneybadgerNotifier do
|
8
|
+
it "should not notify honeybadger" do
|
9
|
+
expect(UniformNotifier::HoneybadgerNotifier.out_of_channel_notify(:title => "notify honeybadger")).to be_nil
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should notify honeybadger" do
|
13
|
+
expect(Honeybadger).to receive(:notify).with(UniformNotifier::Exception.new("notify honeybadger"), {})
|
14
|
+
|
15
|
+
UniformNotifier.honeybadger = true
|
16
|
+
UniformNotifier::HoneybadgerNotifier.out_of_channel_notify(:title => "notify honeybadger")
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should notify honeybadger" do
|
20
|
+
expect(Honeybadger).to receive(:notify).with(UniformNotifier::Exception.new("notify honeybadger"), :foo => :bar)
|
21
|
+
|
22
|
+
UniformNotifier.honeybadger = { :foo => :bar }
|
23
|
+
UniformNotifier::HoneybadgerNotifier.out_of_channel_notify("notify honeybadger")
|
24
|
+
end
|
25
|
+
end
|
@@ -1,13 +1,13 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
describe UniformNotifier::JavascriptAlert do
|
3
|
+
RSpec.describe UniformNotifier::JavascriptAlert do
|
4
4
|
it "should not notify message" do
|
5
|
-
UniformNotifier::JavascriptAlert.inline_notify(:title => "javascript alert!").
|
5
|
+
expect(UniformNotifier::JavascriptAlert.inline_notify(:title => "javascript alert!")).to be_nil
|
6
6
|
end
|
7
7
|
|
8
8
|
it "should notify message" do
|
9
9
|
UniformNotifier.alert = true
|
10
|
-
UniformNotifier::JavascriptAlert.inline_notify(:title => "javascript alert!").
|
10
|
+
expect(UniformNotifier::JavascriptAlert.inline_notify(:title => "javascript alert!")).to eq <<-CODE
|
11
11
|
<script type="text/javascript">/*<![CDATA[*/
|
12
12
|
alert( "javascript alert!" );
|
13
13
|
/*]]>*/</script>
|
@@ -1,13 +1,13 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
describe UniformNotifier::JavascriptConsole do
|
3
|
+
RSpec.describe UniformNotifier::JavascriptConsole do
|
4
4
|
it "should not notify message" do
|
5
|
-
UniformNotifier::JavascriptConsole.inline_notify(:title => "javascript console!").
|
5
|
+
expect(UniformNotifier::JavascriptConsole.inline_notify(:title => "javascript console!")).to be_nil
|
6
6
|
end
|
7
7
|
|
8
8
|
it "should notify message" do
|
9
9
|
UniformNotifier.console = true
|
10
|
-
UniformNotifier::JavascriptConsole.inline_notify(:title => "javascript console!").
|
10
|
+
expect(UniformNotifier::JavascriptConsole.inline_notify(:title => "javascript console!")).to eq <<-CODE
|
11
11
|
<script type="text/javascript">/*<![CDATA[*/
|
12
12
|
if (typeof(console) !== 'undefined' && console.log) {
|
13
13
|
if (console.groupCollapsed && console.groupEnd) {
|
@@ -4,15 +4,15 @@ class Rails
|
|
4
4
|
# mock Rails
|
5
5
|
end
|
6
6
|
|
7
|
-
describe UniformNotifier::RailsLogger do
|
7
|
+
RSpec.describe UniformNotifier::RailsLogger do
|
8
8
|
it "should not notify rails logger" do
|
9
|
-
UniformNotifier::RailsLogger.out_of_channel_notify(:title => "notify rails logger").
|
9
|
+
expect(UniformNotifier::RailsLogger.out_of_channel_notify(:title => "notify rails logger")).to be_nil
|
10
10
|
end
|
11
11
|
|
12
12
|
it "should notify rails logger" do
|
13
13
|
logger = double("logger")
|
14
|
-
Rails.
|
15
|
-
logger.
|
14
|
+
expect(Rails).to receive(:logger).and_return(logger)
|
15
|
+
expect(logger).to receive(:warn).with("notify rails logger")
|
16
16
|
|
17
17
|
UniformNotifier.rails_logger = true
|
18
18
|
UniformNotifier::RailsLogger.out_of_channel_notify(:title => "notify rails logger")
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
describe UniformNotifier::Raise do
|
3
|
+
RSpec.describe UniformNotifier::Raise do
|
4
4
|
it "should not notify message" do
|
5
|
-
UniformNotifier::Raise.out_of_channel_notify(:title => "notification").
|
5
|
+
expect(UniformNotifier::Raise.out_of_channel_notify(:title => "notification")).to be_nil
|
6
6
|
end
|
7
7
|
|
8
8
|
it "should raise error of the default class" do
|
@@ -4,13 +4,13 @@ class Rollbar
|
|
4
4
|
# mock Rollbar
|
5
5
|
end
|
6
6
|
|
7
|
-
describe UniformNotifier::RollbarNotifier do
|
7
|
+
RSpec.describe UniformNotifier::RollbarNotifier do
|
8
8
|
it "should not notify rollbar" do
|
9
|
-
UniformNotifier::RollbarNotifier.out_of_channel_notify(:title => "notify rollbar").
|
9
|
+
expect(UniformNotifier::RollbarNotifier.out_of_channel_notify(:title => "notify rollbar")).to be_nil
|
10
10
|
end
|
11
11
|
|
12
12
|
it "should notify rollbar" do
|
13
|
-
Rollbar.
|
13
|
+
expect(Rollbar).to receive(:info).with(UniformNotifier::Exception.new("notify rollbar"))
|
14
14
|
|
15
15
|
UniformNotifier.rollbar = true
|
16
16
|
UniformNotifier::RollbarNotifier.out_of_channel_notify(:title => "notify rollbar")
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe UniformNotifier::Slack do
|
3
|
+
RSpec.describe UniformNotifier::Slack do
|
4
4
|
context 'not enabled' do
|
5
5
|
it 'should not notify slack' do
|
6
6
|
expect_any_instance_of(Slack::Notifier).to_not receive(:ping)
|
@@ -39,7 +39,7 @@ describe UniformNotifier::Slack do
|
|
39
39
|
end
|
40
40
|
|
41
41
|
context 'properly configured' do
|
42
|
-
before(:
|
42
|
+
before(:example) do
|
43
43
|
@message = 'notify slack'
|
44
44
|
allow_any_instance_of(Slack::Notifier).to receive(:ping).and_return(@message)
|
45
45
|
end
|
@@ -1,23 +1,23 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe UniformNotifier::Xmpp do
|
3
|
+
RSpec.describe UniformNotifier::Xmpp do
|
4
4
|
it "should not notify xmpp" do
|
5
|
-
UniformNotifier::Xmpp.out_of_channel_notify(:title => "notify xmpp").
|
5
|
+
expect(UniformNotifier::Xmpp.out_of_channel_notify(:title => "notify xmpp")).to be_nil
|
6
6
|
end
|
7
7
|
|
8
8
|
it "should notify xmpp without online status" do
|
9
9
|
jid = double("jid")
|
10
10
|
xmpp = double("xmpp")
|
11
|
-
Jabber::JID.
|
12
|
-
Jabber::Client.
|
13
|
-
xmpp.
|
14
|
-
xmpp.
|
11
|
+
expect(Jabber::JID).to receive(:new).with('from@gmail.com').and_return(jid)
|
12
|
+
expect(Jabber::Client).to receive(:new).with(jid).and_return(xmpp)
|
13
|
+
expect(xmpp).to receive(:connect)
|
14
|
+
expect(xmpp).to receive(:auth).with('123456')
|
15
15
|
|
16
16
|
message = double("message")
|
17
|
-
Jabber::Message.
|
18
|
-
message.
|
19
|
-
message.
|
20
|
-
xmpp.
|
17
|
+
expect(Jabber::Message).to receive(:new).with('to@gmail.com', 'notify xmpp').and_return(message)
|
18
|
+
expect(message).to receive(:set_type).with(:normal).and_return(message)
|
19
|
+
expect(message).to receive(:set_subject).with('Uniform Notifier').and_return(message)
|
20
|
+
expect(xmpp).to receive(:send).with(message)
|
21
21
|
|
22
22
|
UniformNotifier.xmpp = {:account => 'from@gmail.com', :password => '123456', :receiver => 'to@gmail.com', :show_online_status => false}
|
23
23
|
UniformNotifier::Xmpp.out_of_channel_notify(:title => 'notify xmpp')
|
@@ -26,23 +26,23 @@ describe UniformNotifier::Xmpp do
|
|
26
26
|
it "should notify xmpp with online status" do
|
27
27
|
jid = double("jid")
|
28
28
|
xmpp = double("xmpp")
|
29
|
-
Jabber::JID.
|
30
|
-
Jabber::Client.
|
31
|
-
xmpp.
|
32
|
-
xmpp.
|
29
|
+
expect(Jabber::JID).to receive(:new).with('from@gmail.com').and_return(jid)
|
30
|
+
expect(Jabber::Client).to receive(:new).with(jid).and_return(xmpp)
|
31
|
+
expect(xmpp).to receive(:connect)
|
32
|
+
expect(xmpp).to receive(:auth).with('123456')
|
33
33
|
|
34
34
|
presence = double("presence")
|
35
35
|
now = Time.now
|
36
|
-
Time.
|
37
|
-
Jabber::Presence.
|
38
|
-
presence.
|
39
|
-
xmpp.
|
36
|
+
allow(Time).to receive(:now).and_return(now)
|
37
|
+
expect(Jabber::Presence).to receive(:new).and_return(presence)
|
38
|
+
expect(presence).to receive(:set_status).with("Uniform Notifier started on #{now}").and_return(presence)
|
39
|
+
expect(xmpp).to receive(:send).with(presence)
|
40
40
|
|
41
41
|
message = double("message")
|
42
|
-
Jabber::Message.
|
43
|
-
message.
|
44
|
-
message.
|
45
|
-
xmpp.
|
42
|
+
expect(Jabber::Message).to receive(:new).with('to@gmail.com', 'notify xmpp').and_return(message)
|
43
|
+
expect(message).to receive(:set_type).with(:normal).and_return(message)
|
44
|
+
expect(message).to receive(:set_subject).with('Uniform Notifier').and_return(message)
|
45
|
+
expect(xmpp).to receive(:send).with(message)
|
46
46
|
|
47
47
|
UniformNotifier.xmpp = {:account => 'from@gmail.com', :password => '123456', :receiver => 'to@gmail.com', :show_online_status => true}
|
48
48
|
UniformNotifier::Xmpp.out_of_channel_notify(:title => 'notify xmpp')
|
data/uniform_notifier.gemspec
CHANGED
@@ -11,6 +11,7 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.homepage = "http://rubygems.org/gems/uniform_notifier"
|
12
12
|
s.summary = %q{uniform notifier for rails logger, customized logger, javascript alert, javascript console, growl and xmpp}
|
13
13
|
s.description = %q{uniform notifier for rails logger, customized logger, javascript alert, javascript console, growl and xmpp}
|
14
|
+
s.license = 'MIT'
|
14
15
|
|
15
16
|
s.rubyforge_project = "uniform_notifier"
|
16
17
|
|
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.
|
4
|
+
version: 1.10.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:
|
11
|
+
date: 2016-01-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-growl
|
@@ -102,6 +102,7 @@ files:
|
|
102
102
|
- lib/uniform_notifier/customized_logger.rb
|
103
103
|
- lib/uniform_notifier/errors.rb
|
104
104
|
- lib/uniform_notifier/growl.rb
|
105
|
+
- lib/uniform_notifier/honeybadger.rb
|
105
106
|
- lib/uniform_notifier/javascript_alert.rb
|
106
107
|
- lib/uniform_notifier/javascript_console.rb
|
107
108
|
- lib/uniform_notifier/rails_logger.rb
|
@@ -116,6 +117,7 @@ files:
|
|
116
117
|
- spec/uniform_notifier/bugsnag_spec.rb
|
117
118
|
- spec/uniform_notifier/customized_logger_spec.rb
|
118
119
|
- spec/uniform_notifier/growl_spec.rb
|
120
|
+
- spec/uniform_notifier/honeybadger_spec.rb
|
119
121
|
- spec/uniform_notifier/javascript_alert_spec.rb
|
120
122
|
- spec/uniform_notifier/javascript_console_spec.rb
|
121
123
|
- spec/uniform_notifier/rails_logger_spec.rb
|
@@ -125,7 +127,8 @@ files:
|
|
125
127
|
- spec/uniform_notifier/xmpp_spec.rb
|
126
128
|
- uniform_notifier.gemspec
|
127
129
|
homepage: http://rubygems.org/gems/uniform_notifier
|
128
|
-
licenses:
|
130
|
+
licenses:
|
131
|
+
- MIT
|
129
132
|
metadata: {}
|
130
133
|
post_install_message:
|
131
134
|
rdoc_options: []
|
@@ -143,7 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
143
146
|
version: '0'
|
144
147
|
requirements: []
|
145
148
|
rubyforge_project: uniform_notifier
|
146
|
-
rubygems_version: 2.
|
149
|
+
rubygems_version: 2.5.1
|
147
150
|
signing_key:
|
148
151
|
specification_version: 4
|
149
152
|
summary: uniform notifier for rails logger, customized logger, javascript alert, javascript
|
@@ -155,6 +158,7 @@ test_files:
|
|
155
158
|
- spec/uniform_notifier/bugsnag_spec.rb
|
156
159
|
- spec/uniform_notifier/customized_logger_spec.rb
|
157
160
|
- spec/uniform_notifier/growl_spec.rb
|
161
|
+
- spec/uniform_notifier/honeybadger_spec.rb
|
158
162
|
- spec/uniform_notifier/javascript_alert_spec.rb
|
159
163
|
- spec/uniform_notifier/javascript_console_spec.rb
|
160
164
|
- spec/uniform_notifier/rails_logger_spec.rb
|