uniform_notifier 1.2.0 → 1.3.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: 32594087462271ce56e830a65a5f055e309813ac
4
- data.tar.gz: c1b075373e494c52a30cb474835aaf1349b63442
3
+ metadata.gz: 1daee42774f88bbcb5dee6d8453df3dab0f100c1
4
+ data.tar.gz: d90364c166d4cbd0b667b7bec2be21322e2704be
5
5
  SHA512:
6
- metadata.gz: dca6046ca44a3b88a4ad1eaf53bdef0098701bf6c45c03dc160c92b088065b057ab947e0122d5f2959e6108a2a6b3657278723deabc6abdb024e0df5381f307a
7
- data.tar.gz: 4d9ed4d568e9df86739e9a245239bb50caab5ed1ec4ca1a78a907f907b8fe4611a225814ae65e469f049df659fef6700246ca29d5c429441d771259ea81b3ca1
6
+ metadata.gz: 372fdcb741154d490751286d692834700fa46c2d87f13e4e6ada6d570bd04b7248cf1c4c85ffc633ebb2ba3394c1229b854745680b2ecf7b4e77b2ea00a16326
7
+ data.tar.gz: f0e344f55daf89098fb5d3fea32129700816adf93e6344368781df3c13ac883cf4960d2c88da74cedcee772dbe760fbecfff30d1b9d4c60ac3ba5169e962ee4d
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
data/CONTRIBUTORS ADDED
@@ -0,0 +1,9 @@
1
+ Alexey Bobyrev <alexey.bobyrev@gmail.com>
2
+ Brian Kelly <polymonic@gmail.com>
3
+ Dan Finnie <dan@danfinnie.com>
4
+ Flip Sasser <flip@x451.com>
5
+ Ian Duggan <ian@ianduggan.net>
6
+ Konstantin Kosmatov <key@kosmatov.su>
7
+ Richard Huang <flyerhzm@gmail.com>
8
+ Steven Soroka <ssoroka78@gmail.com>
9
+ tinogomes <tinorj@gmail.com>
data/Gemfile CHANGED
@@ -2,3 +2,5 @@ source "http://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in uniform_notifier.gemspec
4
4
  gemspec
5
+
6
+ gem 'rake'
data/README.md CHANGED
@@ -69,6 +69,14 @@ By default, all notifiers are disabled, you should enable them first.
69
69
  :receiver => 'recipient_account@jabber.org',
70
70
  :show_online_status => true }
71
71
 
72
+ # raise an error
73
+ UniformNotifier.raise = true # raise a generic exception
74
+
75
+ class MyExceptionClass < Exception; end
76
+ UniformNotifier.raise = MyExceptionClass # raise a custom exception type
77
+
78
+ UniformNotifier.raise = false # don't raise errors
79
+
72
80
  After that, you can enjoy the notifiers, that's cool!
73
81
 
74
82
  # the notify message will be notified to rails logger, customized logger, growl or xmpp.
@@ -0,0 +1,19 @@
1
+ module UniformNotifier
2
+ class Raise < Base
3
+ class UniformNotifierException < Exception; end
4
+
5
+ def self.active?
6
+ @exception_class
7
+ end
8
+
9
+ def self.inline_notify( message )
10
+ return unless self.active?
11
+
12
+ raise @exception_class, message
13
+ end
14
+
15
+ def self.setup_connection(exception_class)
16
+ @exception_class = exception_class == true ? UniformNotifierException : exception_class
17
+ end
18
+ end
19
+ end
@@ -1,3 +1,3 @@
1
1
  module UniformNotifier
2
- VERSION = "1.2.0"
2
+ VERSION = "1.3.0"
3
3
  end
@@ -6,14 +6,15 @@ require 'uniform_notifier/xmpp'
6
6
  require 'uniform_notifier/rails_logger'
7
7
  require 'uniform_notifier/customized_logger'
8
8
  require 'uniform_notifier/airbrake'
9
+ require 'uniform_notifier/raise'
9
10
 
10
11
  module UniformNotifier
11
12
  class NotificationError < StandardError; end
12
13
 
13
14
  class <<self
14
- attr_accessor :alert, :console, :growl, :rails_logger, :xmpp, :airbrake
15
+ attr_accessor :alert, :console, :growl, :rails_logger, :xmpp, :airbrake, :raise
15
16
 
16
- NOTIFIERS = [JavascriptAlert, JavascriptConsole, Growl, Xmpp, RailsLogger, CustomizedLogger, AirbrakeNotifier]
17
+ NOTIFIERS = [JavascriptAlert, JavascriptConsole, Growl, Xmpp, RailsLogger, CustomizedLogger, AirbrakeNotifier, Raise]
17
18
 
18
19
  def active_notifiers
19
20
  NOTIFIERS.select { |notifier| notifier.active? }
@@ -30,5 +31,9 @@ module UniformNotifier
30
31
  def customized_logger=(logdev)
31
32
  UniformNotifier::CustomizedLogger.setup(logdev)
32
33
  end
34
+
35
+ def raise=(exception_class)
36
+ UniformNotifier::Raise.setup_connection(exception_class)
37
+ end
33
38
  end
34
39
  end
@@ -10,7 +10,7 @@ describe UniformNotifier::CustomizedLogger do
10
10
  logger.sync = true
11
11
 
12
12
  now = Time.now
13
- Time.stub!(:now).and_return(now)
13
+ Time.stub(:now).and_return(now)
14
14
  UniformNotifier.customized_logger = logger
15
15
  UniformNotifier::CustomizedLogger.out_of_channel_notify("notify rails logger")
16
16
 
@@ -19,4 +19,4 @@ describe UniformNotifier::CustomizedLogger do
19
19
 
20
20
  File.delete('test.log')
21
21
  end
22
- end
22
+ end
@@ -8,7 +8,9 @@ describe UniformNotifier::Growl do
8
8
 
9
9
  it "should notify growl without password" do
10
10
  growl = double('growl', :is_a? => true)
11
- Growl.should_receive(:new).with('localhost', 'uniform_notifier', ['uniform_notifier'], nil, nil).and_return(growl)
11
+ Growl.should_receive(:new).with('localhost', 'uniform_notifier').and_return(growl)
12
+ growl.should_receive(:add_notification).with('uniform_notifier')
13
+ growl.should_receive(:password=).with(nil)
12
14
  growl.should_receive(:notify).with('uniform_notifier', 'Uniform Notifier', 'Uniform Notifier Growl has been turned on').ordered
13
15
  growl.should_receive(:notify).with('uniform_notifier', 'Uniform Notifier', 'notify growl without password').ordered
14
16
 
@@ -18,7 +20,9 @@ describe UniformNotifier::Growl do
18
20
 
19
21
  it "should notify growl with password" do
20
22
  growl = double('growl', :is_a? => true)
21
- Growl.should_receive(:new).with('localhost', 'uniform_notifier', ['uniform_notifier'], nil, '123456').and_return(growl)
23
+ Growl.should_receive(:new).with('localhost', 'uniform_notifier').and_return(growl)
24
+ growl.should_receive(:add_notification).with('uniform_notifier')
25
+ growl.should_receive(:password=).with('123456')
22
26
  growl.should_receive(:notify).with('uniform_notifier', 'Uniform Notifier', 'Uniform Notifier Growl has been turned on').ordered
23
27
  growl.should_receive(:notify).with('uniform_notifier', 'Uniform Notifier', 'notify growl with password').ordered
24
28
 
@@ -0,0 +1,31 @@
1
+ require "spec_helper"
2
+
3
+ describe UniformNotifier::Raise do
4
+ it "should not notify message" do
5
+ UniformNotifier::Raise.inline_notify("notification").should be_nil
6
+ end
7
+
8
+ it "should raise error of the default class" do
9
+ UniformNotifier.raise = true
10
+ expect {
11
+ UniformNotifier::Raise.inline_notify("notification")
12
+ }.to raise_error(UniformNotifier::Raise::UniformNotifierException, "notification")
13
+ end
14
+
15
+ it "allows the user to override the default exception class" do
16
+ klass = Class.new(Exception)
17
+ UniformNotifier.raise = klass
18
+ expect {
19
+ UniformNotifier::Raise.inline_notify("notification")
20
+ }.to raise_error(klass, "notification")
21
+ end
22
+
23
+ it "can be turned from on to off again" do
24
+ UniformNotifier.raise = true
25
+ UniformNotifier.raise = false
26
+
27
+ expect {
28
+ UniformNotifier::Raise.inline_notify("notification")
29
+ }.not_to raise_error
30
+ end
31
+ end
@@ -33,7 +33,7 @@ describe UniformNotifier::Xmpp do
33
33
 
34
34
  presence = double("presence")
35
35
  now = Time.now
36
- Time.stub!(:now).and_return(now)
36
+ Time.stub(:now).and_return(now)
37
37
  Jabber::Presence.should_receive(:new).and_return(presence)
38
38
  presence.should_receive(:set_status).with("Uniform Notifier started on #{now}").and_return(presence)
39
39
  xmpp.should_receive(:send).with(presence)
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.2.0
4
+ version: 1.3.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: 2013-03-03 00:00:00.000000000 Z
11
+ date: 2013-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-growl
@@ -75,6 +75,8 @@ extensions: []
75
75
  extra_rdoc_files: []
76
76
  files:
77
77
  - .gitignore
78
+ - .travis.yml
79
+ - CONTRIBUTORS
78
80
  - Gemfile
79
81
  - LICENSE
80
82
  - README.md
@@ -87,6 +89,7 @@ files:
87
89
  - lib/uniform_notifier/javascript_alert.rb
88
90
  - lib/uniform_notifier/javascript_console.rb
89
91
  - lib/uniform_notifier/rails_logger.rb
92
+ - lib/uniform_notifier/raise.rb
90
93
  - lib/uniform_notifier/version.rb
91
94
  - lib/uniform_notifier/xmpp.rb
92
95
  - spec/spec_helper.rb
@@ -96,6 +99,7 @@ files:
96
99
  - spec/uniform_notifier/javascript_alert_spec.rb
97
100
  - spec/uniform_notifier/javascript_console_spec.rb
98
101
  - spec/uniform_notifier/rails_logger_spec.rb
102
+ - spec/uniform_notifier/raise_spec.rb
99
103
  - spec/uniform_notifier/xmpp_spec.rb
100
104
  - uniform_notifier.gemspec
101
105
  homepage: http://rubygems.org/gems/uniform_notifier
@@ -117,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
121
  version: '0'
118
122
  requirements: []
119
123
  rubyforge_project: uniform_notifier
120
- rubygems_version: 2.0.0
124
+ rubygems_version: 2.0.6
121
125
  signing_key:
122
126
  specification_version: 4
123
127
  summary: uniform notifier for rails logger, customized logger, javascript alert, javascript
@@ -130,4 +134,5 @@ test_files:
130
134
  - spec/uniform_notifier/javascript_alert_spec.rb
131
135
  - spec/uniform_notifier/javascript_console_spec.rb
132
136
  - spec/uniform_notifier/rails_logger_spec.rb
137
+ - spec/uniform_notifier/raise_spec.rb
133
138
  - spec/uniform_notifier/xmpp_spec.rb