Sha256: 2174ec4f13b6ceae0276eb6bfc7aea817f74f174857d28c7a03dd941ad0630ae

Contents?: true

Size: 1.25 KB

Versions: 2

Compression:

Stored size: 1.25 KB

Contents

require 'blinky'

# fix issue where no light will cause lock-up
module Blinky
  class LightFactory
    class << self
      alias :original_detect_lights :detect_lights
      def detect_lights plugins, recipes
        original_detect_lights plugins, recipes
      rescue
        []
      end
    end
  end
end

module StartingBlocks
  module Extensions
    class GreenOnSuccessRedOnFailure

      def initialize
        @light = Blinky.new.light
      end

      def receive_files_to_run files
        @spec_count = files.count
        return if files.count == 0
        change_color_to :yellow
      end

      def receive_results results
        return if @spec_count == 0
        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

      def change_color_to(color)
        case color
        when :green
          @light.success!
        when :red
          @light.failure!
        when :yellow
          @light.building!
        end
      rescue
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
starting_blocks-0.0.20 lib/extensions/blinky.rb
starting_blocks-0.0.19 lib/extensions/blinky.rb