diff --git a/dashboard.rb b/dashboard.rb index b4238b9..5413f73 100755 --- a/dashboard.rb +++ b/dashboard.rb @@ -1,33 +1,7 @@ #!/usr/bin/env ruby -require 'colorize' +require_relative 'lib/dashboard' -dashboard = "".ljust(10) -dashboard += "Test Results".ljust(25) -dashboard += "Rubocop Results".ljust(26) -dashboard += "Time until last run".ljust(25) -dashboard += " Total" -dashboard += "\n\n" - -require_relative 'game' -game = Game.new(teams: ARGV[0].split(",")) - - -for team in game.teams - dashboard += "Team #{team.number}".ljust(10) - dashboard += team.rspec_result.ljust(25).colorize(team.rspec_color) - dashboard += team.rubocop_result.ljust(26).colorize(team.rubocop_color) - dashboard += team.time_result.ljust(25).colorize(:white) - dashboard += team.total_points.green - dashboard += "\n\n" -end - -puts dashboard.bold - -rules = "\n * 20 points if you get 100% of the tests passing" -rules += "\n * 10 points if you make Rubocop happy. Each offense takes one point." -rules += "\n * 10 points if you finish in 10 minutes or less. Each additional minute takes one point." - -puts rules - -# puts String.color_samples +team_numbers = ARGV[0].split(',') +game = Game.new(teams: team_numbers) +puts Dashboard.new(game) diff --git a/lib/dashboard.rb b/lib/dashboard.rb new file mode 100755 index 0000000..b2dee7c --- /dev/null +++ b/lib/dashboard.rb @@ -0,0 +1,38 @@ +#!/usr/bin/env ruby + +require 'colorize' +require_relative 'game' + +class Dashboard + def initialize(game) + @game = game + end + + def to_s + dashboard = "".ljust(10) + dashboard += "Test Results".ljust(25) + dashboard += "Rubocop Results".ljust(26) + dashboard += "Time until last run".ljust(25) + dashboard += " Total" + dashboard += "\n\n" + + game = @game + + + for team in game.teams + dashboard += "Team #{team.number}".ljust(10) + dashboard += team.rspec_result.ljust(25).colorize(team.rspec_color) + dashboard += team.rubocop_result.ljust(26).colorize(team.rubocop_color) + dashboard += team.time_result.ljust(25).colorize(:white) + dashboard += team.total_points.green + dashboard += "\n\n" + end + + + rules = "\n * 20 points if you get 100% of the tests passing" + rules += "\n * 10 points if you make Rubocop happy. Each offense takes one point." + rules += "\n * 10 points if you finish in 10 minutes or less. Each additional minute takes one point." + + dashboard.bold + rules + end +end diff --git a/game.rb b/lib/game.rb similarity index 100% rename from game.rb rename to lib/game.rb