Class: Undercover::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/undercover/options.rb

Constant Summary collapse

RUN_MODE =
[
  RUN_MODE_DIFF_STRICT = :diff_strict, # warn for changed lines
  # RUN_MODE_DIFF_FILES  = :diff_files, # warn for changed whole files
  # RUN_MODE_ALL         = :diff_all, # warn for allthethings
  # RUN_MODE_FILES       = :files # warn for specific files (cli option)
].freeze
OUTPUT_FORMATTERS =
[
  OUTPUT_STDOUT = :stdout, # outputs warnings to stdout with exit 1
  # OUTPUT_CIRCLEMATOR = :circlemator # posts warnings as review comments
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeOptions

Returns a new instance of Options.



22
23
24
25
26
27
28
29
30
# File 'lib/undercover/options.rb', line 22

def initialize
  # TODO: use run modes
  # TODO: use formatters
  @run_mode = RUN_MODE_DIFF_STRICT
  @enabled_formatters = [OUTPUT_STDOUT]
  # set defaults
  self.path = '.'
  self.git_dir = '.git'
end

Instance Attribute Details

#compareObject

Returns the value of attribute compare.



20
21
22
# File 'lib/undercover/options.rb', line 20

def compare
  @compare
end

#git_dirObject

Returns the value of attribute git_dir.



20
21
22
# File 'lib/undercover/options.rb', line 20

def git_dir
  @git_dir
end

#lcovObject

Returns the value of attribute lcov.



20
21
22
# File 'lib/undercover/options.rb', line 20

def lcov
  @lcov
end

#pathObject

Returns the value of attribute path.



20
21
22
# File 'lib/undercover/options.rb', line 20

def path
  @path
end

#syntax_versionObject

Returns the value of attribute syntax_version.



20
21
22
# File 'lib/undercover/options.rb', line 20

def syntax_version
  @syntax_version
end

Instance Method Details

#parse(args) ⇒ Object

rubocop:disable Metrics/MethodLength, Metrics/AbcSize



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/undercover/options.rb', line 33

def parse(args)
  args = build_opts(args)

  OptionParser.new do |opts|
    opts.banner = 'Usage: undercover [options]'

    opts.on_tail('-h', '--help', 'Prints this help') do
      puts(opts)
      exit
    end

    opts.on_tail('--version', 'Show version') do
      puts VERSION
      exit
    end

    lcov_path_option(opts)
    project_path_option(opts)
    git_dir_option(opts)
    compare_option(opts)
    ruby_syntax_option(opts)
    # TODO: parse dem other options and assign to self
    # --quiet (skip progress bar)
    # --exit-status (do not print report, just exit)
  end.parse(args)

  guess_lcov_path unless lcov
  self
end