Class: RSpecTelemetry::CompareCLI
- Inherits:
-
Object
- Object
- RSpecTelemetry::CompareCLI
- Defined in:
- lib/rspec_telemetry/compare_cli.rb
Instance Method Summary collapse
-
#initialize(argv, out: $stdout, err: $stderr) ⇒ CompareCLI
constructor
A new instance of CompareCLI.
- #run ⇒ Object
Constructor Details
#initialize(argv, out: $stdout, err: $stderr) ⇒ CompareCLI
Returns a new instance of CompareCLI.
9 10 11 12 13 14 |
# File 'lib/rspec_telemetry/compare_cli.rb', line 9 def initialize(argv, out: $stdout, err: $stderr) @argv = argv @out = out @err = err @options = {all_depths: false, sort: "duration"} end |
Instance Method Details
#run ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/rspec_telemetry/compare_cli.rb', line 16 def run paths = parse! unless paths.length == 2 @err.puts("Specify exactly two telemetry files: BEFORE AFTER") return 1 end comparison = FactoryComparison.new(paths[0], paths[1], all_depths: @options[:all_depths]) rows = sort_rows(comparison.rows) @out.puts(render(rows, duration_label: comparison.all_depths ? "Self(ms)" : "Total(ms)")) 0 rescue Errno::ENOENT => e @err.puts("File not found: #{e.}") 1 rescue OptionParser::ParseError => e @err.puts(e.) 1 end |