Class: OpenvoxLint::Configuration

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

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

#columnObject

Returns the value of attribute column.



13
14
15
# File 'lib/openvox-lint/configuration.rb', line 13

def column
  @column
end

#custom_log_formatObject

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_checksObject

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_warningsObject

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

#fixObject

Returns the value of attribute fix.



13
14
15
# File 'lib/openvox-lint/configuration.rb', line 13

def fix
  @fix
end

#ignore_pathsObject

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_formatObject

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_checksObject

Returns the value of attribute only_checks.



13
14
15
# File 'lib/openvox-lint/configuration.rb', line 13

def only_checks
  @only_checks
end

#relativeObject

Returns the value of attribute relative.



13
14
15
# File 'lib/openvox-lint/configuration.rb', line 13

def relative
  @relative
end

#with_filenameObject

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

Returns:

  • (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