Class: Undercover::Options
- Inherits:
-
Object
- Object
- Undercover::Options
- Defined in:
- lib/undercover/options.rb
Overview
rubocop:disable Metrics/ClassLength
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
- DEFAULT_FILE_INCLUDE_GLOBS =
%w[*.rb *.rake *.ru Rakefile].freeze
- DEFAULT_FILE_EXCLUDE_GLOBS =
%w[test/* spec/* db/* *_test.rb *_spec.rb].freeze
Instance Attribute Summary collapse
-
#compare ⇒ Object
Returns the value of attribute compare.
-
#git_dir ⇒ Object
Returns the value of attribute git_dir.
-
#glob_allow_filters ⇒ Object
Returns the value of attribute glob_allow_filters.
-
#glob_reject_filters ⇒ Object
Returns the value of attribute glob_reject_filters.
-
#lcov ⇒ Object
Returns the value of attribute lcov.
-
#path ⇒ Object
Returns the value of attribute path.
-
#syntax_version ⇒ Object
Returns the value of attribute syntax_version.
Instance Method Summary collapse
-
#initialize ⇒ Options
constructor
A new instance of Options.
-
#parse(args) ⇒ Object
rubocop:disable Metrics/MethodLength, Metrics/AbcSize.
Constructor Details
#initialize ⇒ Options
Returns a new instance of Options.
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/undercover/options.rb', line 31 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' self.glob_allow_filters = DEFAULT_FILE_INCLUDE_GLOBS self.glob_reject_filters = DEFAULT_FILE_EXCLUDE_GLOBS end |
Instance Attribute Details
#compare ⇒ Object
Returns the value of attribute compare.
23 24 25 |
# File 'lib/undercover/options.rb', line 23 def compare @compare end |
#git_dir ⇒ Object
Returns the value of attribute git_dir.
23 24 25 |
# File 'lib/undercover/options.rb', line 23 def git_dir @git_dir end |
#glob_allow_filters ⇒ Object
Returns the value of attribute glob_allow_filters.
23 24 25 |
# File 'lib/undercover/options.rb', line 23 def glob_allow_filters @glob_allow_filters end |
#glob_reject_filters ⇒ Object
Returns the value of attribute glob_reject_filters.
23 24 25 |
# File 'lib/undercover/options.rb', line 23 def glob_reject_filters @glob_reject_filters end |
#lcov ⇒ Object
Returns the value of attribute lcov.
23 24 25 |
# File 'lib/undercover/options.rb', line 23 def lcov @lcov end |
#path ⇒ Object
Returns the value of attribute path.
23 24 25 |
# File 'lib/undercover/options.rb', line 23 def path @path end |
#syntax_version ⇒ Object
Returns the value of attribute syntax_version.
23 24 25 |
# File 'lib/undercover/options.rb', line 23 def syntax_version @syntax_version end |
Instance Method Details
#parse(args) ⇒ Object
rubocop:disable Metrics/MethodLength, Metrics/AbcSize
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/undercover/options.rb', line 44 def parse(args) args = build_opts(args) OptionParser.new do |opts| opts. = '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) file_filters(opts) end.parse(args) guess_lcov_path unless lcov self end |