Class: OpenvoxLint::Configuration
- Inherits:
-
Object
- Object
- OpenvoxLint::Configuration
- Defined in:
- lib/openvox-lint/configuration.rb
Overview
Holds all runtime configuration.
Constant Summary collapse
- DEFAULTS =
{ log_format: 'text', with_filename: true, fail_on_warnings: false, fix: false, only_checks: [], disabled_checks: [], ignore_paths: %w[vendor/**/*.pp pkg/**/*.pp spec/**/*.pp], relative: false, column: true, custom_log_format: nil, }.freeze
Instance Attribute Summary collapse
-
#column ⇒ Object
Returns the value of attribute column.
-
#custom_log_format ⇒ Object
Returns the value of attribute custom_log_format.
-
#disabled_checks ⇒ Object
Returns the value of attribute disabled_checks.
-
#fail_on_warnings ⇒ Object
Returns the value of attribute fail_on_warnings.
-
#fix ⇒ Object
Returns the value of attribute fix.
-
#ignore_paths ⇒ Object
Returns the value of attribute ignore_paths.
-
#log_format ⇒ Object
Returns the value of attribute log_format.
-
#only_checks ⇒ Object
Returns the value of attribute only_checks.
-
#relative ⇒ Object
Returns the value of attribute relative.
-
#with_filename ⇒ Object
Returns the value of attribute with_filename.
Instance Method Summary collapse
- #check_enabled?(name) ⇒ Boolean
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #load_from_rc(path) ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
17 18 19 20 21 |
# File 'lib/openvox-lint/configuration.rb', line 17 def initialize DEFAULTS.each do |k, v| send(:"#{k}=", v.is_a?(Array) ? v.dup : v) end end |
Instance Attribute Details
#column ⇒ Object
Returns the value of attribute column.
13 14 15 |
# File 'lib/openvox-lint/configuration.rb', line 13 def column @column end |
#custom_log_format ⇒ Object
Returns the value of attribute custom_log_format.
13 14 15 |
# File 'lib/openvox-lint/configuration.rb', line 13 def custom_log_format @custom_log_format end |
#disabled_checks ⇒ Object
Returns the value of attribute disabled_checks.
13 14 15 |
# File 'lib/openvox-lint/configuration.rb', line 13 def disabled_checks @disabled_checks end |
#fail_on_warnings ⇒ Object
Returns the value of attribute fail_on_warnings.
13 14 15 |
# File 'lib/openvox-lint/configuration.rb', line 13 def fail_on_warnings @fail_on_warnings end |
#fix ⇒ Object
Returns the value of attribute fix.
13 14 15 |
# File 'lib/openvox-lint/configuration.rb', line 13 def fix @fix end |
#ignore_paths ⇒ Object
Returns the value of attribute ignore_paths.
13 14 15 |
# File 'lib/openvox-lint/configuration.rb', line 13 def ignore_paths @ignore_paths end |
#log_format ⇒ Object
Returns the value of attribute log_format.
13 14 15 |
# File 'lib/openvox-lint/configuration.rb', line 13 def log_format @log_format end |
#only_checks ⇒ Object
Returns the value of attribute only_checks.
13 14 15 |
# File 'lib/openvox-lint/configuration.rb', line 13 def only_checks @only_checks end |
#relative ⇒ Object
Returns the value of attribute relative.
13 14 15 |
# File 'lib/openvox-lint/configuration.rb', line 13 def relative @relative end |
#with_filename ⇒ Object
Returns the value of attribute with_filename.
13 14 15 |
# File 'lib/openvox-lint/configuration.rb', line 13 def with_filename @with_filename end |
Instance Method Details
#check_enabled?(name) ⇒ Boolean
33 34 35 36 37 38 |
# File 'lib/openvox-lint/configuration.rb', line 33 def check_enabled?(name) name = name.to_sym return false if disabled_checks.include?(name) return only_checks.include?(name) unless only_checks.empty? true end |
#load_from_rc(path) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/openvox-lint/configuration.rb', line 23 def load_from_rc(path) return unless File.exist?(path) File.readlines(path).each do |line| line = line.strip next if line.empty? || line.start_with?('#') flag, value = line.split(/\s+/, 2) apply_flag(flag, value) end end |