Class: ExceptionNotifier::AsanaNotifier
- Inherits:
-
BaseNotifier
- Object
- BaseNotifier
- ExceptionNotifier::AsanaNotifier
- Defined in:
- lib/asana_exception_notifier/classes/asana.rb
Overview
module that is used for formatting numbers using metrics
Instance Attribute Summary collapse
-
#default_options ⇒ Hash
readonly
The resulting options after merging with permitted_options and with initial_options.
-
#initial_options ⇒ Hash
readonly
The initial options that the middleware was configured with.
Instance Method Summary collapse
-
#active? ⇒ Boolean
Method that is used by the ExceptionNotifier gem to check if this notifier can be activated.
-
#asana_api_key ⇒ String?
Method that is used to fetch the Asana api key from the default_options.
-
#asana_client ⇒ Asana::Client
Returns the asana client that will be used to connect to Asana API and sets the configuration for the client.
-
#call(exception, options = {}) ⇒ void
When a exception is caught , this method will be called to publish to Asana the exception details In order not to block the main thread, while we are parsing the exception, and constructing the template date, and connecting to asana, this will spawn a new thread to ensure that the processing of the exception is deferred from the main thread.
-
#faraday_configuration(config) ⇒ void
Returns the asana client that will be used to connect to Asana API.
-
#initialize(options) ⇒ void
constructor
Initializes the instance with the options from the configuration and parses the options.
-
#notes ⇒ String?
Method that is used to fetch the notes from the default_options.
-
#task_name ⇒ String?
Method that is used to fetch the task name from the default_options.
-
#template_path ⇒ String?
Method that retrieves the template_path for rendering the exception details.
-
#workspace ⇒ String?
Method that is used to fetch the workspace ID from the default_options.
Methods included from AsanaExceptionNotifier::ApplicationHelper
add_files_to_zip, archive_files, ensure_thread_running, escape, execute_with_rescue, expanded_path, extract_body, force_utf8_encoding, get_extension_and_name_from_file, get_hash_rows, get_table_headers, get_table_rows, hash_to_html_attributes, inspect_value, log_bactrace, log_exception, logger, mount_table_for_hash, path_is_a_template?, permitted_options, prepare_archive_creation, rails_logger, remove_blank, rescue_interrupt, root, run_new_thread, set_fieldset_key, split_archive, tempfile_details, template_dir, template_path_exist
Methods included from AsanaExceptionNotifier::HeredocHelper
Constructor Details
#initialize(options) ⇒ void
Initializes the instance with the options from the configuration and parses the options
56 57 58 59 60 |
# File 'lib/asana_exception_notifier/classes/asana.rb', line 56 def initialize() super @initial_options = .symbolize_keys.reject { |_key, value| value.blank? } (@initial_options) end |
Instance Attribute Details
#default_options ⇒ Hash (readonly)
The resulting options after merging with permitted_options and with initial_options
20 21 22 |
# File 'lib/asana_exception_notifier/classes/asana.rb', line 20 def @default_options end |
#initial_options ⇒ Hash (readonly)
The initial options that the middleware was configured with
16 17 18 |
# File 'lib/asana_exception_notifier/classes/asana.rb', line 16 def @initial_options end |
Instance Method Details
#active? ⇒ Boolean
Method that is used by the ExceptionNotifier gem to check if this notifier can be activated. The method checks if the asana api key and workspace ID were provided
146 147 148 |
# File 'lib/asana_exception_notifier/classes/asana.rb', line 146 def active? asana_api_key.present? && workspace.present? end |
#asana_api_key ⇒ String?
Method that is used to fetch the Asana api key from the default_options
117 118 119 |
# File 'lib/asana_exception_notifier/classes/asana.rb', line 117 def asana_api_key @default_options.fetch(:asana_api_key, nil) end |
#asana_client ⇒ Asana::Client
Returns the asana client that will be used to connect to Asana API and sets the configuration for the client
66 67 68 69 70 71 72 73 |
# File 'lib/asana_exception_notifier/classes/asana.rb', line 66 def asana_client @asana_client = Asana::Client.new do |config| config.authentication :access_token, asana_api_key config.debug_mode config.faraday_adapter :typhoeus faraday_configuration(config) end end |
#call(exception, options = {}) ⇒ void
This method returns an undefined value.
When a exception is caught , this method will be called to publish to Asana the exception details In order not to block the main thread, while we are parsing the exception, and constructing the template date, and connecting to asana, this will spawn a new thread to ensure that the processing of the exception is deferred from the main thread. This method will also create the asana task after the processing of the exception and all the other data is gathered by the AsanaExceptionNotifier::ErrorPage class
105 106 107 108 109 110 111 112 |
# File 'lib/asana_exception_notifier/classes/asana.rb', line 105 def call(exception, = {}) ensure_thread_running do execute_with_rescue do error_page = AsanaExceptionNotifier::ErrorPage.new(template_path, exception, ) create_asana_task(error_page) if active? end end end |
#faraday_configuration(config) ⇒ void
This method returns an undefined value.
Returns the asana client that will be used to connect to Asana API
79 80 81 82 83 84 85 86 |
# File 'lib/asana_exception_notifier/classes/asana.rb', line 79 def faraday_configuration(config) config.configure_faraday do |conn| conn.request :url_encoded conn.use :instrumentation conn.response :logger conn.response :follow_redirects end end |
#notes ⇒ String?
Method that is used to fetch the notes from the default_options
131 132 133 |
# File 'lib/asana_exception_notifier/classes/asana.rb', line 131 def notes @default_options.fetch(:notes, nil) end |
#task_name ⇒ String?
Method that is used to fetch the task name from the default_options
138 139 140 |
# File 'lib/asana_exception_notifier/classes/asana.rb', line 138 def task_name @default_options.fetch(:name, nil) end |
#template_path ⇒ String?
Method that retrieves the template_path for rendering the exception details
153 154 155 |
# File 'lib/asana_exception_notifier/classes/asana.rb', line 153 def template_path @default_options.fetch(:template_path, nil) end |
#workspace ⇒ String?
Method that is used to fetch the workspace ID from the default_options
124 125 126 |
# File 'lib/asana_exception_notifier/classes/asana.rb', line 124 def workspace @default_options.fetch(:workspace, nil) end |