Class: ExceptionNotifier::YoutrackNotifier
- Inherits:
-
Object
- Object
- ExceptionNotifier::YoutrackNotifier
- Defined in:
- lib/exception_notifier/youtrack_notifier.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
-
#project ⇒ Object
Returns the value of attribute project.
Instance Method Summary collapse
- #call(exception, options = {}) ⇒ Object
- #clean_backtrace(exception) ⇒ Object
- #enrich_message_with_backtrace(exception) ⇒ Object
-
#initialize(options) ⇒ YoutrackNotifier
constructor
A new instance of YoutrackNotifier.
Constructor Details
#initialize(options) ⇒ YoutrackNotifier
Returns a new instance of YoutrackNotifier.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/exception_notifier/youtrack_notifier.rb', line 7 def initialize() @project = [:project] @client = Youtrack::Client.new do |c| c.url = [:url] c.login = [:user] c.password = [:password] end @client.connect! end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
5 6 7 |
# File 'lib/exception_notifier/youtrack_notifier.rb', line 5 def client @client end |
#project ⇒ Object
Returns the value of attribute project.
5 6 7 |
# File 'lib/exception_notifier/youtrack_notifier.rb', line 5 def project @project end |
Instance Method Details
#call(exception, options = {}) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/exception_notifier/youtrack_notifier.rb', line 19 def call(exception, ={}) issue_resource = @client.issues backtrace = (exception) issue = { project: @project, summary: exception., description: backtrace, type: 'bug', priority: 'critical', state: 'open' } issue_resource.create(issue) end |
#clean_backtrace(exception) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/exception_notifier/youtrack_notifier.rb', line 41 def clean_backtrace(exception) if defined?(Rails) && Rails.respond_to?(:backtrace_cleaner) Rails.backtrace_cleaner.send(:filter, exception.backtrace) else exception.backtrace end end |
#enrich_message_with_backtrace(exception) ⇒ Object
36 37 38 39 |
# File 'lib/exception_notifier/youtrack_notifier.rb', line 36 def (exception) backtrace = clean_backtrace(exception).first(10).join("\n") ['*Backtrace:*', backtrace].join("\n") end |