Sha256: 3d8b98c8e19a00367613952fe1c94cfabe7286bf996499dfd9591d6c2e2c9b5e
Contents?: true
Size: 1.36 KB
Versions: 14
Compression:
Stored size: 1.36 KB
Contents
module Guard class RSpec < Plugin class Notifier attr_accessor :options def initialize(options = {}) @options = options end def notify(summary) return unless options[:notification] failure_count, pending_count = _parse_summary(summary) image = _image(failure_count, pending_count) priority = _priority(image) Guard::Compat::UI.notify(summary, title: @options[:title], image: image, priority: priority) end def notify_failure return unless options[:notification] Guard::Compat::UI.notify("Failed", title: @options[:title], image: :failed, priority: 2) end private def _parse_summary(summary) summary.match(/(\d+) failures( \((\d+) pending\))?/) do |m| return m[1].to_i, m[3].to_i end [0, 0] end def _image(failure_count, pending_count) if failure_count > 0 :failed elsif pending_count > 0 :pending else :success end end def _priority(image) { failed: 2, pending: -1, success: -2 }[image] end end end end
Version data entries
14 entries across 14 versions & 6 rubygems