lib/undercover/options.rb in undercover-0.2.3 vs lib/undercover/options.rb in undercover-0.3.0
- old
+ new
@@ -29,10 +29,12 @@
self.git_dir = '.git'
end
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
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)
@@ -51,15 +53,34 @@
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
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
private
+
+ def build_opts(args)
+ project_options.concat(args)
+ end
+
+ def project_options
+ args_from_options_file(project_options_file)
+ end
+
+ def args_from_options_file(path)
+ return [] unless File.exist?(path)
+
+ File.read(path).split('\n').flat_map { |line| line.split(' ') }
+ end
+
+ def project_options_file
+ './.undercover'
+ end
def lcov_path_option(parser)
parser.on('-l', '--lcov path', 'LCOV report file path') do |path|
self.lcov = path
end