Class: Onlylogs::Configuration
- Inherits:
-
Object
- Object
- Onlylogs::Configuration
- Defined in:
- lib/onlylogs/configuration.rb
Instance Attribute Summary collapse
-
#allowed_files ⇒ Object
Returns the value of attribute allowed_files.
-
#basic_auth_password ⇒ Object
Returns the value of attribute basic_auth_password.
-
#basic_auth_user ⇒ Object
Returns the value of attribute basic_auth_user.
-
#default_log_file_path ⇒ Object
Returns the value of attribute default_log_file_path.
-
#disable_basic_authentication ⇒ Object
Returns the value of attribute disable_basic_authentication.
-
#editor ⇒ Object
Returns the value of attribute editor.
-
#max_line_matches ⇒ Object
Returns the value of attribute max_line_matches.
-
#parent_controller ⇒ Object
Returns the value of attribute parent_controller.
-
#ripgrep_enabled ⇒ Object
Returns the value of attribute ripgrep_enabled.
Instance Method Summary collapse
- #configure {|_self| ... } ⇒ Object
- #default_allowed_files ⇒ Object
- #default_basic_auth_password ⇒ Object
- #default_basic_auth_user ⇒ Object
- #default_editor ⇒ Object
- #default_log_file_path_value ⇒ Object
- #default_ripgrep_enabled ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize ⇒ Configuration
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/onlylogs/configuration.rb', line 9 def initialize @allowed_files = default_allowed_files @default_log_file_path = default_log_file_path_value @basic_auth_user = default_basic_auth_user @basic_auth_password = default_basic_auth_password @parent_controller = nil @disable_basic_authentication = false @ripgrep_enabled = default_ripgrep_enabled @editor = default_editor @max_line_matches = 100000 end |
Instance Attribute Details
#allowed_files ⇒ Object
Returns the value of attribute allowed_files.
5 6 7 |
# File 'lib/onlylogs/configuration.rb', line 5 def allowed_files @allowed_files end |
#basic_auth_password ⇒ Object
Returns the value of attribute basic_auth_password.
5 6 7 |
# File 'lib/onlylogs/configuration.rb', line 5 def basic_auth_password @basic_auth_password end |
#basic_auth_user ⇒ Object
Returns the value of attribute basic_auth_user.
5 6 7 |
# File 'lib/onlylogs/configuration.rb', line 5 def basic_auth_user @basic_auth_user end |
#default_log_file_path ⇒ Object
Returns the value of attribute default_log_file_path.
5 6 7 |
# File 'lib/onlylogs/configuration.rb', line 5 def default_log_file_path @default_log_file_path end |
#disable_basic_authentication ⇒ Object
Returns the value of attribute disable_basic_authentication.
5 6 7 |
# File 'lib/onlylogs/configuration.rb', line 5 def disable_basic_authentication @disable_basic_authentication end |
#editor ⇒ Object
Returns the value of attribute editor.
5 6 7 |
# File 'lib/onlylogs/configuration.rb', line 5 def editor @editor end |
#max_line_matches ⇒ Object
Returns the value of attribute max_line_matches.
5 6 7 |
# File 'lib/onlylogs/configuration.rb', line 5 def max_line_matches @max_line_matches end |
#parent_controller ⇒ Object
Returns the value of attribute parent_controller.
5 6 7 |
# File 'lib/onlylogs/configuration.rb', line 5 def parent_controller @parent_controller end |
#ripgrep_enabled ⇒ Object
Returns the value of attribute ripgrep_enabled.
5 6 7 |
# File 'lib/onlylogs/configuration.rb', line 5 def ripgrep_enabled @ripgrep_enabled end |
Instance Method Details
#configure {|_self| ... } ⇒ Object
21 22 23 |
# File 'lib/onlylogs/configuration.rb', line 21 def configure yield self end |
#default_allowed_files ⇒ Object
47 48 49 50 51 52 |
# File 'lib/onlylogs/configuration.rb', line 47 def default_allowed_files # Default to environment-specific log files (without rotation suffixes) [ Rails.root.join("log/#{Rails.env}.log") ] end |
#default_basic_auth_password ⇒ Object
62 63 64 |
# File 'lib/onlylogs/configuration.rb', line 62 def default_basic_auth_password ENV["ONLYLOGS_BASIC_AUTH_PASSWORD"] || Rails.application.credentials.dig(:onlylogs, :basic_auth_password) end |
#default_basic_auth_user ⇒ Object
58 59 60 |
# File 'lib/onlylogs/configuration.rb', line 58 def default_basic_auth_user ENV["ONLYLOGS_BASIC_AUTH_USER"] || Rails.application.credentials.dig(:onlylogs, :basic_auth_user) end |
#default_editor ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/onlylogs/configuration.rb', line 25 def default_editor if (credentials_editor = Rails.application.credentials.dig(:onlylogs, :editor)) return credentials_editor end # 2. Check environment variables (ONLYLOGS_EDITOR > RAILS_EDITOR > EDITOR) if ENV["ONLYLOGS_EDITOR"] return ENV["ONLYLOGS_EDITOR"].to_sym end if ENV["RAILS_EDITOR"] return ENV["RAILS_EDITOR"].to_sym end if ENV["EDITOR"] return ENV["EDITOR"].to_sym end # 3. Default fallback :vscode end |
#default_log_file_path_value ⇒ Object
54 55 56 |
# File 'lib/onlylogs/configuration.rb', line 54 def default_log_file_path_value Rails.root.join("log/#{Rails.env}.log").to_s end |
#default_ripgrep_enabled ⇒ Object
66 67 68 |
# File 'lib/onlylogs/configuration.rb', line 66 def default_ripgrep_enabled system("which rg > /dev/null 2>&1") end |