Class: ProcessBot::Options
- Inherits:
-
Object
- Object
- ProcessBot::Options
- Defined in:
- lib/process_bot/options.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #application_basename ⇒ Object
- #events ⇒ Object
- #fetch ⇒ Object
-
#initialize(options = {}) ⇒ Options
constructor
A new instance of Options.
- #possible_process_titles ⇒ Object
- #possible_process_titles_joined_regex ⇒ Object
- #present?(key) ⇒ Boolean
- #release_path ⇒ Object
- #set(key, value) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Options
Returns a new instance of Options.
4 5 6 |
# File 'lib/process_bot/options.rb', line 4 def initialize( = {}) = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
2 3 4 |
# File 'lib/process_bot/options.rb', line 2 def end |
Instance Method Details
#[](key) ⇒ Object
8 9 10 |
# File 'lib/process_bot/options.rb', line 8 def [](key) [key] end |
#application_basename ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/process_bot/options.rb', line 27 def application_basename @application_basename ||= begin app_path_parts = release_path.split("/") if release_path.include?("/releases/") app_path_parts.pop(2) elsif release_path.end_with?("/current") app_path_parts.pop end app_path_parts.last end end |
#events ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/process_bot/options.rb', line 12 def events @events ||= begin require "knjrbfw" event_handler = ::Knj::Event_handler.new event_handler.add_event(name: :on_process_started) event_handler.add_event(name: :on_socket_opened) event_handler end end |
#fetch ⇒ Object
23 24 25 |
# File 'lib/process_bot/options.rb', line 23 def fetch(...) .fetch(...) end |
#possible_process_titles ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/process_bot/options.rb', line 41 def possible_process_titles possible_names = [] # Sidekiq name can by current Rails root base name possible_names << application_basename # Sidekiq name can be set tag name (but we wrongly read application for some reason?) possible_names << .fetch(:application) possible_names end |
#possible_process_titles_joined_regex ⇒ Object
53 54 55 56 57 58 59 60 61 |
# File 'lib/process_bot/options.rb', line 53 def possible_process_titles_joined_regex possible_process_titles_joined_regex = "" possible_process_titles.each_with_index do |possible_name, index| possible_process_titles_joined_regex << "|" if index >= 1 possible_process_titles_joined_regex << Regexp.escape(possible_name) end possible_process_titles_joined_regex end |
#present?(key) ⇒ Boolean
63 64 65 66 67 |
# File 'lib/process_bot/options.rb', line 63 def present?(key) return true if .key?(key) && [key] false end |
#release_path ⇒ Object
69 70 71 |
# File 'lib/process_bot/options.rb', line 69 def release_path @release_path ||= fetch(:release_path) end |
#set(key, value) ⇒ Object
73 74 75 |
# File 'lib/process_bot/options.rb', line 73 def set(key, value) [key] = value end |