Class: RSpecTelemetry::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec_telemetry/cli.rb

Constant Summary collapse

DEFAULT_GLOB =
"tmp/rspec_telemetry*.ndjson"

Instance Method Summary collapse

Constructor Details

#initialize(argv, out: $stdout, err: $stderr) ⇒ CLI

Returns a new instance of CLI.



12
13
14
15
16
17
# File 'lib/rspec_telemetry/cli.rb', line 12

def initialize(argv, out: $stdout, err: $stderr)
  @argv = argv
  @out = out
  @err = err
  @options = {top: 15, example: nil}
end

Instance Method Details

#runObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/rspec_telemetry/cli.rb', line 19

def run
  paths = parse!
  if paths.empty?
    @err.puts("No telemetry files found (looked for #{DEFAULT_GLOB}).")
    @err.puts("Run `bundle exec rspec` first, or pass file paths explicitly.")
    return 1
  end

  @options[:example] ? drill_down(paths, @options[:example]) : report(paths)
  0
rescue Errno::ENOENT => e
  @err.puts("File not found: #{e.message}")
  1
end