Class: RailsSpotlight::Configuration
- Inherits:
-
Object
- Object
- RailsSpotlight::Configuration
- Defined in:
- lib/rails_spotlight/configuration.rb
Overview
rubocop:disable Metrics/ClassLength
Constant Summary collapse
- DEFAULT_NOT_ENCODABLE_EVENT_VALUES =
{ 'ActiveRecord' => [ 'ActiveRecord::ConnectionAdapters::AbstractAdapter', 'ActiveRecord::ConnectionAdapters::PostgreSQLAdapter', 'ActiveRecord::ConnectionAdapters::RealTransaction' ], 'ActionDispatch' => ['ActionDispatch::Request', 'ActionDispatch::Response'] }.freeze
- DEFAULT_DIRECTORY_INDEX_IGNORE =
%w[ /.git **/*.lock **/.DS_Store /app/assets/images/** /app/assets/fonts/** /app/assets/builds/** **/.keep ].freeze
- SKIP_RENDERED_IVARS =
%i[ @_routes @_config @view_renderer @lookup_context @_assigns @_controller @_request @_default_form_builder @view_flow @output_buffer @virtual_path @tag_builder @assets_environment @asset_resolver_strategies @_main_app @_devise_route_context @devise_mapping ].freeze
Instance Attribute Summary collapse
-
#action_cable_mount_path ⇒ Object
readonly
Returns the value of attribute action_cable_mount_path.
-
#block_editing_files ⇒ Object
readonly
Returns the value of attribute block_editing_files.
-
#block_editing_files_outside_of_the_project ⇒ Object
readonly
Returns the value of attribute block_editing_files_outside_of_the_project.
-
#default_rs_src ⇒ Object
readonly
Returns the value of attribute default_rs_src.
-
#directory_index_ignore ⇒ Object
readonly
Returns the value of attribute directory_index_ignore.
-
#form_js_execution_token ⇒ Object
readonly
Returns the value of attribute form_js_execution_token.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#middleware_skipped_paths ⇒ Object
readonly
Returns the value of attribute middleware_skipped_paths.
-
#not_encodable_event_values ⇒ Object
readonly
Returns the value of attribute not_encodable_event_values.
-
#project_name ⇒ Object
readonly
Returns the value of attribute project_name.
-
#rubocop_config_path ⇒ Object
readonly
Returns the value of attribute rubocop_config_path.
-
#skip_rendered_ivars ⇒ Object
readonly
Returns the value of attribute skip_rendered_ivars.
-
#source_path ⇒ Object
readonly
Returns the value of attribute source_path.
-
#storage_path ⇒ Object
readonly
Returns the value of attribute storage_path.
-
#storage_pool_size ⇒ Object
readonly
Returns the value of attribute storage_pool_size.
-
#use_action_cable ⇒ Object
(also: #use_action_cable?)
readonly
Returns the value of attribute use_action_cable.
Class Method Summary collapse
Instance Method Summary collapse
- #action_cable_present? ⇒ Boolean
- #auto_mount_action_cable ⇒ Object (also: #auto_mount_action_cable?)
-
#initialize(opts = {}) ⇒ Configuration
constructor
rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/AbcSize.
- #live_console_enabled ⇒ Object (also: #live_console_enabled?)
- #live_logs_enabled ⇒ Object (also: #live_logs_enabled?)
- #rails_root ⇒ Object
- #request_completed_broadcast_enabled ⇒ Object (also: #request_completed_broadcast_enabled?)
Constructor Details
#initialize(opts = {}) ⇒ Configuration
rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/AbcSize
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/rails_spotlight/configuration.rb', line 47 def initialize(opts = {}) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/AbcSize @project_name = opts[:project_name] || detect_project_name @source_path = opts[:source_path] || self.class.rails_root @logger = opts[:logger] || Logger.new(File.join(self.class.rails_root, 'log', 'rails_spotlight.log')) @storage_path = opts[:storage_path] || File.join(self.class.rails_root, 'tmp', 'data', 'rails_spotlight') @storage_pool_size = opts[:storage_pool_size] || 20 @live_console_enabled = opts[:live_console_enabled].nil? ? false : true?(opts[:live_console_enabled]) @request_completed_broadcast_enabled = opts[:request_completed_broadcast_enabled].nil? ? false : true?(opts[:request_completed_broadcast_enabled]) @middleware_skipped_paths = opts[:middleware_skipped_paths] || [] @not_encodable_event_values = DEFAULT_NOT_ENCODABLE_EVENT_VALUES.merge(opts[:not_encodable_event_values] || {}) @use_action_cable = opts[:use_action_cable].nil? ? false : true?(opts[:use_action_cable]) @auto_mount_action_cable = opts[:auto_mount_action_cable].nil? ? false : true?(opts[:auto_mount_action_cable]) @action_cable_mount_path = opts[:action_cable_mount_path] || '/cable' @block_editing_files = opts[:block_editing_files].nil? ? false : true?(opts[:block_editing_files]) @block_editing_files_outside_of_the_project = opts[:block_editing_files_outside_of_the_project].nil? ? true : true?(opts[:block_editing_files_outside_of_the_project]) @skip_rendered_ivars = SKIP_RENDERED_IVARS + (opts[:skip_rendered_ivars] || []).map(&:to_sym) @directory_index_ignore = opts[:directory_index_ignore] || DEFAULT_DIRECTORY_INDEX_IGNORE @rubocop_config_path = opts[:rubocop_config_path] ? File.join(self.class.rails_root, opts[:rubocop_config_path]) : nil @live_logs_enabled = opts[:live_logs_enabled].nil? ? false : true?(opts[:live_logs_enabled]) @default_rs_src = opts[:default_rs_src] || 'default' @form_js_execution_token = opts[:form_js_execution_token] || Digest::MD5.hexdigest(detect_project_name) end |
Instance Attribute Details
#action_cable_mount_path ⇒ Object (readonly)
Returns the value of attribute action_cable_mount_path.
41 42 43 |
# File 'lib/rails_spotlight/configuration.rb', line 41 def action_cable_mount_path @action_cable_mount_path end |
#block_editing_files ⇒ Object (readonly)
Returns the value of attribute block_editing_files.
41 42 43 |
# File 'lib/rails_spotlight/configuration.rb', line 41 def block_editing_files @block_editing_files end |
#block_editing_files_outside_of_the_project ⇒ Object (readonly)
Returns the value of attribute block_editing_files_outside_of_the_project.
41 42 43 |
# File 'lib/rails_spotlight/configuration.rb', line 41 def block_editing_files_outside_of_the_project @block_editing_files_outside_of_the_project end |
#default_rs_src ⇒ Object (readonly)
Returns the value of attribute default_rs_src.
41 42 43 |
# File 'lib/rails_spotlight/configuration.rb', line 41 def default_rs_src @default_rs_src end |
#directory_index_ignore ⇒ Object (readonly)
Returns the value of attribute directory_index_ignore.
41 42 43 |
# File 'lib/rails_spotlight/configuration.rb', line 41 def directory_index_ignore @directory_index_ignore end |
#form_js_execution_token ⇒ Object (readonly)
Returns the value of attribute form_js_execution_token.
41 42 43 |
# File 'lib/rails_spotlight/configuration.rb', line 41 def form_js_execution_token @form_js_execution_token end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
41 42 43 |
# File 'lib/rails_spotlight/configuration.rb', line 41 def logger @logger end |
#middleware_skipped_paths ⇒ Object (readonly)
Returns the value of attribute middleware_skipped_paths.
41 42 43 |
# File 'lib/rails_spotlight/configuration.rb', line 41 def middleware_skipped_paths @middleware_skipped_paths end |
#not_encodable_event_values ⇒ Object (readonly)
Returns the value of attribute not_encodable_event_values.
41 42 43 |
# File 'lib/rails_spotlight/configuration.rb', line 41 def not_encodable_event_values @not_encodable_event_values end |
#project_name ⇒ Object (readonly)
Returns the value of attribute project_name.
41 42 43 |
# File 'lib/rails_spotlight/configuration.rb', line 41 def project_name @project_name end |
#rubocop_config_path ⇒ Object (readonly)
Returns the value of attribute rubocop_config_path.
41 42 43 |
# File 'lib/rails_spotlight/configuration.rb', line 41 def rubocop_config_path @rubocop_config_path end |
#skip_rendered_ivars ⇒ Object (readonly)
Returns the value of attribute skip_rendered_ivars.
41 42 43 |
# File 'lib/rails_spotlight/configuration.rb', line 41 def skip_rendered_ivars @skip_rendered_ivars end |
#source_path ⇒ Object (readonly)
Returns the value of attribute source_path.
41 42 43 |
# File 'lib/rails_spotlight/configuration.rb', line 41 def source_path @source_path end |
#storage_path ⇒ Object (readonly)
Returns the value of attribute storage_path.
41 42 43 |
# File 'lib/rails_spotlight/configuration.rb', line 41 def storage_path @storage_path end |
#storage_pool_size ⇒ Object (readonly)
Returns the value of attribute storage_pool_size.
41 42 43 |
# File 'lib/rails_spotlight/configuration.rb', line 41 def storage_pool_size @storage_pool_size end |
#use_action_cable ⇒ Object (readonly) Also known as: use_action_cable?
Returns the value of attribute use_action_cable.
41 42 43 |
# File 'lib/rails_spotlight/configuration.rb', line 41 def use_action_cable @use_action_cable end |
Class Method Details
.load_config ⇒ Object
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/rails_spotlight/configuration.rb', line 98 def self.load_config config_file = File.join(rails_root, 'config', 'rails_spotlight.yml') return new unless File.exist?(config_file) erb_result = ERB.new(File.read(config_file)).result data = YAML.safe_load(erb_result) || {} # Support older versions of Ruby and Rails opts = data.each_with_object({}) do |(key, value), memo| new_key = key.is_a?(String) ? key.downcase.to_sym : key memo[new_key] = value end new(opts) end |
.rails_root ⇒ Object
114 115 116 |
# File 'lib/rails_spotlight/configuration.rb', line 114 def self.rails_root @rails_root ||= (Rails.root.to_s.presence || Dir.pwd).freeze end |
Instance Method Details
#action_cable_present? ⇒ Boolean
94 95 96 |
# File 'lib/rails_spotlight/configuration.rb', line 94 def action_cable_present? defined?(ActionCable) && true end |
#auto_mount_action_cable ⇒ Object Also known as: auto_mount_action_cable?
88 89 90 |
# File 'lib/rails_spotlight/configuration.rb', line 88 def auto_mount_action_cable @auto_mount_action_cable && use_action_cable && action_cable_present? end |
#live_console_enabled ⇒ Object Also known as: live_console_enabled?
70 71 72 |
# File 'lib/rails_spotlight/configuration.rb', line 70 def live_console_enabled @live_console_enabled && use_action_cable && action_cable_present? end |
#live_logs_enabled ⇒ Object Also known as: live_logs_enabled?
74 75 76 |
# File 'lib/rails_spotlight/configuration.rb', line 74 def live_logs_enabled @live_logs_enabled && use_action_cable && action_cable_present? end |
#rails_root ⇒ Object
118 119 120 |
# File 'lib/rails_spotlight/configuration.rb', line 118 def rails_root self.class.rails_root end |
#request_completed_broadcast_enabled ⇒ Object Also known as: request_completed_broadcast_enabled?
82 83 84 |
# File 'lib/rails_spotlight/configuration.rb', line 82 def request_completed_broadcast_enabled @request_completed_broadcast_enabled && use_action_cable && action_cable_present? end |