Class: Undercover::Options
- Inherits:
-
Object
- Object
- Undercover::Options
- Defined in:
- lib/undercover/options.rb
Overview
rubocop:disable Metrics/ClassLength
Constant Summary collapse
- DIFF_TRIGGER_MODE =
[ # Default, analyse all code blocks with changed lines. Untested lines and branches will trigger warnings if they # strictly belong to the diff. DIFF_TRIGGER_LINE = :diff_trigger_line, # # Doesn't exist yet # Analyse all code blocks with changed lines. Untested lines and branches always trigger warnings for code block. # DIFF_TRIGGER_BLOCK = :diff_trigger_block, # Analyse all code blocks in each changed file. # DIFF_TRIGGER_FILE = :diff_trigger_file, # Analyse all code blocks in all files, ignores current diff (use --include-files and --exclude-files for control) # ALL = :all, ].freeze
- FILE_SCOPE =
[ # Extended scope helps identify Ruby files that are not required in the test suite. # Warning: currently doesn't respect :nocov: syntax in files not traced by SimpleCov. # (use --include-files and --exclude-files for control) FILE_SCOPE_EXTENDED = :scope_extended, # # Doesn't exist yet # Analyse file that appear in coverage reports. Historically, the default undercover mode. # FILE_SCOPE_COVERAGE = :scope_coverage, ].freeze
- DEFAULT_FILE_INCLUDE_GLOBS =
%w[*.rb *.rake *.ru Rakefile].freeze
- DEFAULT_FILE_EXCLUDE_GLOBS =
%w[test/* spec/* db/* config/* *_test.rb *_spec.rb].freeze
Instance Attribute Summary collapse
-
#compare ⇒ Object
Returns the value of attribute compare.
-
#file_scope ⇒ Object
Returns the value of attribute file_scope.
-
#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.
-
#max_warnings_limit ⇒ Object
Returns the value of attribute max_warnings_limit.
-
#path ⇒ Object
Returns the value of attribute path.
-
#run_mode ⇒ Object
Returns the value of attribute run_mode.
-
#simplecov_resultset ⇒ Object
Returns the value of attribute simplecov_resultset.
-
#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.
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/undercover/options.rb', line 49 def initialize @run_mode = DIFF_TRIGGER_LINE @file_scope = FILE_SCOPE_EXTENDED # set defaults self.path = '.' self.git_dir = '.git' self.glob_allow_filters = DEFAULT_FILE_INCLUDE_GLOBS self.glob_reject_filters = DEFAULT_FILE_EXCLUDE_GLOBS self.max_warnings_limit = nil end |
Instance Attribute Details
#compare ⇒ Object
Returns the value of attribute compare.
37 38 39 |
# File 'lib/undercover/options.rb', line 37 def compare @compare end |
#file_scope ⇒ Object
Returns the value of attribute file_scope.
37 38 39 |
# File 'lib/undercover/options.rb', line 37 def file_scope @file_scope end |
#git_dir ⇒ Object
Returns the value of attribute git_dir.
37 38 39 |
# File 'lib/undercover/options.rb', line 37 def git_dir @git_dir end |
#glob_allow_filters ⇒ Object
Returns the value of attribute glob_allow_filters.
37 38 39 |
# File 'lib/undercover/options.rb', line 37 def glob_allow_filters @glob_allow_filters end |
#glob_reject_filters ⇒ Object
Returns the value of attribute glob_reject_filters.
37 38 39 |
# File 'lib/undercover/options.rb', line 37 def glob_reject_filters @glob_reject_filters end |
#lcov ⇒ Object
Returns the value of attribute lcov.
37 38 39 |
# File 'lib/undercover/options.rb', line 37 def lcov @lcov end |
#max_warnings_limit ⇒ Object
Returns the value of attribute max_warnings_limit.
37 38 39 |
# File 'lib/undercover/options.rb', line 37 def max_warnings_limit @max_warnings_limit end |
#path ⇒ Object
Returns the value of attribute path.
37 38 39 |
# File 'lib/undercover/options.rb', line 37 def path @path end |
#run_mode ⇒ Object
Returns the value of attribute run_mode.
37 38 39 |
# File 'lib/undercover/options.rb', line 37 def run_mode @run_mode end |
#simplecov_resultset ⇒ Object
Returns the value of attribute simplecov_resultset.
37 38 39 |
# File 'lib/undercover/options.rb', line 37 def simplecov_resultset @simplecov_resultset end |
#syntax_version ⇒ Object
Returns the value of attribute syntax_version.
37 38 39 |
# File 'lib/undercover/options.rb', line 37 def syntax_version @syntax_version end |
Instance Method Details
#parse(args) ⇒ Object
rubocop:disable Metrics/MethodLength, Metrics/AbcSize
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/undercover/options.rb', line 61 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 # :nocov: puts VERSION exit # :nocov: end lcov_path_option(opts) resultset_path_option(opts) project_path_option(opts) git_dir_option(opts) compare_option(opts) ruby_syntax_option(opts) max_warnings_limit_option(opts) file_filters(opts) end.parse(args) guess_resultset_path unless simplecov_resultset guess_lcov_path unless lcov self end |