class SorbetProgress::CLI
Parses the provided metrics file and prints a report.
Constants
- USAGE
Public Class Methods
new(argv)
click to toggle source
# File lib/sorbet_progress/cli.rb, line 24 def initialize(argv) # TODO: use an actual CLI args parser, like optparse or trollop case argv.length when 1 @path = argv.first @reporter_name = "verbose" when 3 @path = argv.last @reporter_name = argv[1] else raise Error.new(1, USAGE) end end
Public Instance Methods
run()
click to toggle source
# File lib/sorbet_progress/cli.rb, line 39 def run metrics = parse(@path) calculator = Calculator.new(metrics) reporter = reporter_class(@reporter_name).new(calculator) puts reporter.report end
Private Instance Methods
parse(path)
click to toggle source
# File lib/sorbet_progress/cli.rb, line 49 def parse(path) Parser.new.parse(File.read(path)) rescue Errno::ENOENT => e raise Error.new(2, "Metrics file not found: " + e.message) end
reporter_class(name)
click to toggle source
# File lib/sorbet_progress/cli.rb, line 56 def reporter_class(name) case name when "verbose" Reporters::Verbose when "bar_chart" Reporters::BarChart else raise format("Invalid reporter name: %s", @reporter_name) end end