exceptioner 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -1,6 +1,6 @@
1
1
  = Exceptioner
2
2
 
3
- Be notified about exceptions by various transports Email, Jabber, IRC, etc. Choose the option you want.
3
+ Stay notified about exceptions by various transports Email, Jabber, IRC, etc. Choose the option you want.
4
4
 
5
5
  The most common use is to use Exceptioner as rack middleware and send notifications when an exception occur in you web application. It may be used with Rails, Sinatra or any other rack citizen.
6
6
  Exceptioner may be also used with any ruby code you want. Just configure delivery methods and don't miss any exception.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
data/exceptioner.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{exceptioner}
8
- s.version = "0.0.1"
8
+ s.version = "0.0.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Micha\305\202 \305\201omnicki"]
@@ -28,8 +28,10 @@ Gem::Specification.new do |s|
28
28
  "init.rb",
29
29
  "lib/exceptioner.rb",
30
30
  "lib/exceptioner/action_controller.rb",
31
- "lib/exceptioner/core_ext/class/attribute_accessors.rb",
31
+ "lib/exceptioner/core_ext/class/attribute.rb",
32
+ "lib/exceptioner/core_ext/kernel/singleton_class.rb",
32
33
  "lib/exceptioner/core_ext/module/attribute_accessors.rb",
34
+ "lib/exceptioner/core_ext/module/remove_method.rb",
33
35
  "lib/exceptioner/middleware.rb",
34
36
  "lib/exceptioner/notifier.rb",
35
37
  "lib/exceptioner/railtie.rb",
@@ -0,0 +1,29 @@
1
+ # This code is stolen from ActiveSupport gem.
2
+ # We don't need to instance accessors so they're removed
3
+ # for cattr_ methods so responsible part of code was removed.
4
+ #
5
+ # Note we don't overwrite class_attribute method if it exists already.
6
+ class Class
7
+ unless method_defined?(:class_attribute)
8
+ require 'exceptioner/core_ext/kernel/singleton_class'
9
+ require 'exceptioner/core_ext/module/remove_method'
10
+
11
+ def class_attribute(*attrs)
12
+ attrs.each do |name|
13
+ class_eval <<-RUBY, __FILE__, __LINE__ + 1
14
+ def self.#{name}() nil end
15
+ def self.#{name}?() !!#{name} end
16
+
17
+ def self.#{name}=(val)
18
+ singleton_class.class_eval do
19
+ remove_possible_method(:#{name})
20
+ define_method(:#{name}) { val }
21
+ end
22
+ val
23
+ end
24
+ RUBY
25
+
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,13 @@
1
+ module Kernel
2
+ # Returns the object's singleton class.
3
+ def singleton_class
4
+ class << self
5
+ self
6
+ end
7
+ end unless respond_to?(:singleton_class) # exists in 1.9.2
8
+
9
+ # class_eval on an object acts like singleton_class.class_eval.
10
+ def class_eval(*args, &block)
11
+ singleton_class.class_eval(*args, &block)
12
+ end
13
+ end
@@ -0,0 +1,11 @@
1
+ class Module
2
+ def remove_possible_method(method)
3
+ remove_method(method)
4
+ rescue NameError
5
+ end
6
+
7
+ def redefine_method(method, &block)
8
+ remove_possible_method(method)
9
+ define_method(method, &block)
10
+ end
11
+ end
@@ -2,13 +2,13 @@ module Exceptioner::Transport
2
2
 
3
3
  class Base
4
4
 
5
- cattr_accessor :sender
5
+ class_attribute :sender
6
6
 
7
- cattr_accessor :recipients
7
+ class_attribute :recipients
8
8
 
9
- cattr_accessor :prefix
9
+ class_attribute :prefix
10
10
 
11
- cattr_accessor :subject
11
+ class_attribute :subject
12
12
 
13
13
 
14
14
  def self.deliver(exception, options = {})
@@ -7,9 +7,9 @@ module Exceptioner::Transport
7
7
 
8
8
  class Jabber < Base
9
9
 
10
- cattr_accessor :jabber_id
10
+ class_attribute :jabber_id
11
11
 
12
- cattr_accessor :password
12
+ class_attribute :password
13
13
 
14
14
  def self.deliver(exception, options = {})
15
15
  connect
@@ -8,9 +8,9 @@ module Exceptioner::Transport
8
8
  class Mail < Base
9
9
  DEFAULT_SENDER_ADDRESS = 'exceptioner@exceptioner.net'
10
10
 
11
- cattr_accessor :delivery_method
11
+ class_attribute :delivery_method
12
12
 
13
- cattr_accessor :delivery_options
13
+ class_attribute :delivery_options
14
14
 
15
15
  def self.deliver(exception, options = {})
16
16
  mail = prepare_mail(exception, options)
@@ -28,11 +28,11 @@ module Exceptioner::Transport
28
28
 
29
29
  protected
30
30
  def self.default_options
31
- super.merge(
31
+ {
32
32
  :delivery_method => delivery_method,
33
33
  :delivery_options => delivery_options,
34
34
  :sender => DEFAULT_SENDER_ADDRESS
35
- )
35
+ }.merge!(super)
36
36
  end
37
37
 
38
38
  def self.prepare_mail(exception, mail_options)
@@ -47,7 +47,7 @@ module Exceptioner::Transport
47
47
  :subject => options[:subject],
48
48
  :body => options[:body]
49
49
  )
50
- mail.delivery_method(options[:delivery_method], options[:delivery_options]) if options[:delivery_method]
50
+ mail.delivery_method(options[:delivery_method], options[:delivery_options] || {}) if options[:delivery_method]
51
51
  mail
52
52
  end
53
53
 
data/lib/exceptioner.rb CHANGED
@@ -1,4 +1,4 @@
1
- require 'exceptioner/core_ext/class/attribute_accessors'
1
+ require 'exceptioner/core_ext/class/attribute'
2
2
  require 'exceptioner/core_ext/module/attribute_accessors'
3
3
  require 'exceptioner/railtie' if defined?(Rails::Railtie)
4
4
 
@@ -2,7 +2,7 @@
2
2
  Exceptioner.setup do |config|
3
3
 
4
4
  # Define how to deliver information about exception
5
- # Available options are: email
5
+ # Available options are: mail, :jabber
6
6
  # config.transports = [:mail]
7
7
 
8
8
  # ### The section below regards mail transport only ###
@@ -26,7 +26,6 @@ Exceptioner.setup do |config|
26
26
 
27
27
  # Prefix prepended to email subject
28
28
  # config.mail.prefix = '[ERROR] '
29
-
30
29
 
31
30
  # ### The section below regards jabber/xmpp transport only ###
32
31
 
@@ -40,6 +39,6 @@ Exceptioner.setup do |config|
40
39
  # config.jabber.jabber_id = 'server@jabber.org'
41
40
 
42
41
  # Sender's password
43
- # conifg.jabber.password = 'SECRETXXX'
42
+ # config.jabber.password = 'SECRETXXX'
44
43
 
45
44
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 1
9
- version: 0.0.1
8
+ - 2
9
+ version: 0.0.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - "Micha\xC5\x82 \xC5\x81omnicki"
@@ -79,8 +79,10 @@ files:
79
79
  - init.rb
80
80
  - lib/exceptioner.rb
81
81
  - lib/exceptioner/action_controller.rb
82
- - lib/exceptioner/core_ext/class/attribute_accessors.rb
82
+ - lib/exceptioner/core_ext/class/attribute.rb
83
+ - lib/exceptioner/core_ext/kernel/singleton_class.rb
83
84
  - lib/exceptioner/core_ext/module/attribute_accessors.rb
85
+ - lib/exceptioner/core_ext/module/remove_method.rb
84
86
  - lib/exceptioner/middleware.rb
85
87
  - lib/exceptioner/notifier.rb
86
88
  - lib/exceptioner/railtie.rb
@@ -1,42 +0,0 @@
1
- # This code is stolen from ActiveSupport gem.
2
- # We don't need to pass options like :instance_writer
3
- # for cattr_ methods so responsible part of code was removed.
4
- #
5
- # Note we don't overwrite cattr_ methods if they exist already.
6
-
7
- class Class
8
- def cattr_reader(*syms)
9
- syms.each do |sym|
10
- class_eval(<<-EOS, __FILE__, __LINE__ + 1)
11
- unless defined? @@#{sym}
12
- @@#{sym} = nil
13
- end
14
-
15
- def self.#{sym}
16
- @@#{sym}
17
- end
18
- EOS
19
- end
20
- end unless method_defined?(:cattr_reader)
21
-
22
- def cattr_writer(*syms)
23
- syms.each do |sym|
24
- class_eval(<<-EOS, __FILE__, __LINE__ + 1)
25
- unless defined? @@#{sym}
26
- @@#{sym} = nil
27
- end
28
-
29
- def self.#{sym}=(obj)
30
- @@#{sym} = obj
31
- end
32
- EOS
33
-
34
- self.send("#{sym}=", yield) if block_given?
35
- end
36
- end unless method_defined?(:cattr_writer)
37
-
38
- def cattr_accessor(*syms, &blk)
39
- cattr_reader(*syms)
40
- cattr_writer(*syms, &blk)
41
- end unless method_defined?(:cattr_accessor)
42
- end