Module: SimpleCov::CLI::Clean
- Defined in:
- lib/simplecov/cli/clean.rb
Overview
‘simplecov clean [–dry-run]` — remove the coverage report directory (or whatever `SimpleCov.coverage_dir` resolves to). The `–dry-run` flag prints what would be deleted without touching disk, for when you’re not sure what’s in there.
Class Method Summary collapse
- .announce(stdout, opts, message) ⇒ Object
- .parse(args) ⇒ Object
- .run(args, stdout:) ⇒ Object
- .sweep(dir, opts, stdout) ⇒ Object
Class Method Details
.announce(stdout, opts, message) ⇒ Object
33 34 35 |
# File 'lib/simplecov/cli/clean.rb', line 33 def announce(stdout, opts, ) stdout.puts("simplecov clean: #{}") unless opts[:quiet] end |
.parse(args) ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/simplecov/cli/clean.rb', line 37 def parse(args) opts = {dry_run: false, quiet: false} OptionParser.new do |o| o.on("--dry-run") { opts[:dry_run] = true } o.on("-q", "--quiet") { opts[:quiet] = true } end.parse(args) opts end |
.run(args, stdout:) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/simplecov/cli/clean.rb', line 14 def run(args, stdout:, **) opts = parse(args) dir = SimpleCov::CLI.coverage_dir return announce(stdout, opts, "#{dir} doesn't exist; nothing to do") || 0 unless File.directory?(dir) sweep(dir, opts, stdout) 0 end |
.sweep(dir, opts, stdout) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/simplecov/cli/clean.rb', line 23 def sweep(dir, opts, stdout) if opts[:dry_run] announce(stdout, opts, "would remove #{dir} (#{Dir["#{dir}/**/*"].size} entries)") else require "fileutils" FileUtils.rm_rf(dir) announce(stdout, opts, "removed #{dir}") end end |