Class: QuietQuality::Config::ToolOptions

Inherits:
Object
  • Object
show all
Defined in:
lib/quiet_quality/config/tool_options.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tool, **options) ⇒ ToolOptions

Returns a new instance of ToolOptions.



4
5
6
7
8
9
10
11
# File 'lib/quiet_quality/config/tool_options.rb', line 4

def initialize(tool, **options)
  @tool_name = tool.to_sym
  @limit_targets = options.fetch(:limit_targets, true)
  @filter_messages = options.fetch(:filter_messages, true)
  @file_filter = options.fetch(:file_filter, nil)
  @command = options.fetch(:command, nil)
  @exec_command = options.fetch(:exec_command, nil)
end

Instance Attribute Details

#commandObject

Returns the value of attribute command.



13
14
15
# File 'lib/quiet_quality/config/tool_options.rb', line 13

def command
  @command
end

#exec_commandObject

Returns the value of attribute exec_command.



13
14
15
# File 'lib/quiet_quality/config/tool_options.rb', line 13

def exec_command
  @exec_command
end

#file_filterObject

Returns the value of attribute file_filter.



13
14
15
# File 'lib/quiet_quality/config/tool_options.rb', line 13

def file_filter
  @file_filter
end

#filter_messages=(value) ⇒ Object (writeonly)

Sets the attribute filter_messages

Parameters:

  • value

    the value to set the attribute filter_messages to.



15
16
17
# File 'lib/quiet_quality/config/tool_options.rb', line 15

def filter_messages=(value)
  @filter_messages = value
end

#limit_targets=(value) ⇒ Object (writeonly)

Sets the attribute limit_targets

Parameters:

  • value

    the value to set the attribute limit_targets to.



15
16
17
# File 'lib/quiet_quality/config/tool_options.rb', line 15

def limit_targets=(value)
  @limit_targets = value
end

#tool_nameObject (readonly)

Returns the value of attribute tool_name.



14
15
16
# File 'lib/quiet_quality/config/tool_options.rb', line 14

def tool_name
  @tool_name
end

Instance Method Details

#filter_messages?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/quiet_quality/config/tool_options.rb', line 21

def filter_messages?
  @filter_messages
end

#limit_targets?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/quiet_quality/config/tool_options.rb', line 17

def limit_targets?
  @limit_targets
end

#parser_classObject



33
34
35
# File 'lib/quiet_quality/config/tool_options.rb', line 33

def parser_class
  tool_namespace::Parser
end

#runner_classObject



29
30
31
# File 'lib/quiet_quality/config/tool_options.rb', line 29

def runner_class
  tool_namespace::Runner
end

#to_hObject



37
38
39
40
41
42
43
44
45
46
47
# File 'lib/quiet_quality/config/tool_options.rb', line 37

def to_h
  {
    tool_name: tool_name,
    limit_targets: limit_targets?,
    filter_messages: filter_messages?,
    file_filter: file_filter&.regex&.to_s,
    command: command,
    exec_command: exec_command,
    excludes: file_filter&.excludes&.map(&:to_s)
  }
end

#tool_namespaceObject



25
26
27
# File 'lib/quiet_quality/config/tool_options.rb', line 25

def tool_namespace
  Tools::AVAILABLE.fetch(tool_name)
end