Sha256: 6019a664c40637e826b95572ba90ffa8e106b0b0aeb99109b9c28160e2931697

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

module RiotNotifier
  class Base < Riot::DotMatrixReporter
    def notify(color, msg)
      # overwrite me
    end

    def fail(desc, message)
      super
      say "#{desc}: #{message}".yellow
      notify(:red, "FAILURE: #{message}")
    end

    def error(desc, error)
      super
      say "#{desc}: #{error}".red
      notify(:red, "ERROR: #{error}")
    end

    def results(time_taken)
      super
      unless bad_results?
        notify(:green, "%d passes, %d failures, %d errors in %s seconds" % [passes, failures, errors, ("%0.6f" % time_taken)])
      end
    end

  private

    def bad_results?
      failures + errors > 0
    end
  end

  class RedgreenNotifier < Base
    attr_reader :path
    PATH = ENV['HOME'] + "/bin/notify_redgreen"
    
    def initialize(path = PATH)
      super()
      @path = path
    end

    def notify(color, msg)
      msg.gsub!(/</, '&lt;')
      msg.gsub!(/"/, "\\\"")
      exec "#{@path} #{color} \"#{msg}\""
    end

    def exec(*args)
      Kernel.system(*args)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
riot_notifier-0.0.1 lib/riot_notifier.rb