Class: ExceptionNotifier::IkachanNotifier
- Inherits:
-
Object
- Object
- ExceptionNotifier::IkachanNotifier
- Defined in:
- lib/exception_notifier/ikachan_notifier.rb
Defined Under Namespace
Classes: Client
Constant Summary collapse
- DEFAULT_FORMAT =
"\x02\x0315,4[ERROR]\x03 \x0313%{class}\x03 - %{message}\x03\x0f, %{occurred}"- IRC_SEQUENCE_RE =
Regexp.new("[\x02\x03\x0f](\\d+)?(,\\d+)?")
Instance Attribute Summary collapse
-
#channels ⇒ Object
readonly
Returns the value of attribute channels.
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#message_format ⇒ Object
readonly
Returns the value of attribute message_format.
Instance Method Summary collapse
- #build_message(exception, options = {}) ⇒ Object
- #call(exception, options = {}) ⇒ Object
-
#initialize(options) ⇒ IkachanNotifier
constructor
A new instance of IkachanNotifier.
Constructor Details
#initialize(options) ⇒ IkachanNotifier
Returns a new instance of IkachanNotifier.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/exception_notifier/ikachan_notifier.rb', line 37 def initialize() channel = [:channels] || [:channel] if !channel or ![:base_url] raise "Some of option is missing: %s" % end @channels = channel.is_a?(Array) ? channel : [channel] @client = Client.new([:base_url]) @message_format = () @message = nil @request_param_names = .scan(/%{(request_[a-zA-Z_?!]+)}/).flatten.uniq @request_param_names.map{|n| [n, n.sub(/^request_/, '')] }.each do |param_name, attribute| raise "Parameter name #{param_name} is unavailable" unless request_klass.method_defined?(attribute) end end |
Instance Attribute Details
#channels ⇒ Object (readonly)
Returns the value of attribute channels.
53 54 55 |
# File 'lib/exception_notifier/ikachan_notifier.rb', line 53 def channels @channels end |
#client ⇒ Object (readonly)
Returns the value of attribute client.
53 54 55 |
# File 'lib/exception_notifier/ikachan_notifier.rb', line 53 def client @client end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
53 54 55 |
# File 'lib/exception_notifier/ikachan_notifier.rb', line 53 def @message end |
#message_format ⇒ Object (readonly)
Returns the value of attribute message_format.
53 54 55 |
# File 'lib/exception_notifier/ikachan_notifier.rb', line 53 def @message_format end |
Instance Method Details
#build_message(exception, options = {}) ⇒ Object
62 63 64 65 66 67 68 69 70 71 |
# File 'lib/exception_notifier/ikachan_notifier.rb', line 62 def (exception, = {}) params = { class: exception.class, message: exception., occurred: (exception.backtrace.first rescue nil), hostname: (Socket.gethostname rescue nil), } params.merge!(build_params_from_request([:env])) @message = % params end |
#call(exception, options = {}) ⇒ Object
57 58 59 60 |
# File 'lib/exception_notifier/ikachan_notifier.rb', line 57 def call(exception, = {}) (exception, ) client.notice_all(channels, ) end |