Class: QuietQuality::Config::ParsedOptions

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

Constant Summary collapse

InvalidOptionName =
Class.new(Error)
GLOBAL_OPTIONS =
[
  :no_config,
  :config_path,
  :annotator,
  :executor,
  :exec_tool,
  :comparison_branch,
  :colorize,
  :logging,
  :message_format,
  :limit_targets,
  :filter_messages,
  :file_filter
].to_set
TOOL_OPTIONS =
[
  :limit_targets,
  :filter_messages,
  :file_filter,
  :excludes,
  :command,
  :exec_command
].to_set

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeParsedOptions

Returns a new instance of ParsedOptions.



30
31
32
33
34
35
# File 'lib/quiet_quality/config/parsed_options.rb', line 30

def initialize
  @tools = []
  @tool_options = {}
  @global_options = {}
  @helping = @printing_version = false
end

Instance Attribute Details

#helping=(value) ⇒ Object (writeonly)

Sets the attribute helping

Parameters:

  • value

    the value to set the attribute helping to.



38
39
40
# File 'lib/quiet_quality/config/parsed_options.rb', line 38

def helping=(value)
  @helping = value
end

#printing_version=(value) ⇒ Object (writeonly)

Sets the attribute printing_version

Parameters:

  • value

    the value to set the attribute printing_version to.



38
39
40
# File 'lib/quiet_quality/config/parsed_options.rb', line 38

def printing_version=(value)
  @printing_version = value
end

#toolsObject

Returns the value of attribute tools.



37
38
39
# File 'lib/quiet_quality/config/parsed_options.rb', line 37

def tools
  @tools
end

Instance Method Details

#global_option(name) ⇒ Object



53
54
55
56
# File 'lib/quiet_quality/config/parsed_options.rb', line 53

def global_option(name)
  validate_global_option(name)
  @global_options.fetch(name.to_sym, nil)
end

#helping?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/quiet_quality/config/parsed_options.rb', line 40

def helping?
  @helping
end

#printing_version?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/quiet_quality/config/parsed_options.rb', line 44

def printing_version?
  @printing_version
end

#set_global_option(name, value) ⇒ Object



48
49
50
51
# File 'lib/quiet_quality/config/parsed_options.rb', line 48

def set_global_option(name, value)
  validate_global_option(name)
  @global_options[name.to_sym] = value
end

#set_tool_option(tool, name, value) ⇒ Object



58
59
60
61
62
# File 'lib/quiet_quality/config/parsed_options.rb', line 58

def set_tool_option(tool, name, value)
  validate_tool_option(name)
  @tool_options[tool.to_sym] ||= {}
  @tool_options[tool.to_sym][name.to_sym] = value
end

#tool_option(tool, name) ⇒ Object



64
65
66
67
# File 'lib/quiet_quality/config/parsed_options.rb', line 64

def tool_option(tool, name)
  validate_tool_option(name)
  @tool_options.dig(tool.to_sym, name.to_sym)
end