class StartingBlocks::Extensions::BlinkyLighting

Public Class Methods

new() click to toggle source
# File lib/starting_blocks-blinky.rb, line 22
def initialize
  @light = Blinky.new.light
end
turn_off!() click to toggle source
# File lib/starting_blocks-blinky.rb, line 26
def self.turn_off!
  Blinky.new.light.off!
end

Public Instance Methods

change_color_to(color) click to toggle source
# File lib/starting_blocks-blinky.rb, line 59
def change_color_to(color)
  case color
  when :green
    @light.success!
  when :red
    @light.failure!
  when :yellow
    @light.building!
  end
rescue
end
receive_files_to_run(files) click to toggle source
# File lib/starting_blocks-blinky.rb, line 30
def receive_files_to_run files
  @spec_count = files.count
  return if files.count == 0
  change_color_to :yellow
end
receive_results(results) click to toggle source
# File lib/starting_blocks-blinky.rb, line 36
def receive_results results
  return if @spec_count.to_i == 0
  if results[:color]
    change_color_to results[:color]
  else
    run_the_old_logic_with results
  end
end
run_the_old_logic_with(results) click to toggle source
# File lib/starting_blocks-blinky.rb, line 45
def run_the_old_logic_with results
  if (results[:tests] || 0) == 0
    change_color_to :red
  elsif (results[:errors] || 0) > 0
    change_color_to :red
  elsif (results[:failures] || 0) > 0
    change_color_to :red
  elsif (results[:skips] || 0) > 0
    change_color_to :yellow
  else
    change_color_to :green
  end
end