Sha256: 66965cc3a416af212932614fa608a0ca664ec96ccb28d41be223831524cd51a7

Contents?: true

Size: 1.12 KB

Versions: 10

Compression:

Stored size: 1.12 KB

Contents

module Autotest::GnomeNotify

  # Time notification will be displayed before disappearing automatically
  EXPIRATION_IN_SECONDS = 2
  ERROR_STOCK_ICON = "gtk-dialog-error"
  SUCCESS_STOCK_ICON = "gtk-dialog-info"

  # Convenience method to send an error notification message
  #
  # [stock_icon]   Stock icon name of icon to display
  # [title]        Notification message title
  # [message]      Core message for the notification
  def self.notify stock_icon, title, message
    options = "-t #{EXPIRATION_IN_SECONDS * 1000} -i #{stock_icon}"
    system "notify-send #{options} '#{title}' \"#{message}\""
  end

  Autotest.add_hook :red do |at|
    example_text = ""
    num_examples = 0
    examples = at.files_to_test.each_pair do |key, values|
      example_text += "- #{key}\n"
      values.each do |value|
        num_examples += 1
        example_text += "  * #{value}\n"
      end
    end
    notify ERROR_STOCK_ICON, "Tests failed", "<b>#{num_examples} examples failed in #{at.files_to_test.size} files</b>\n#{example_text}"
  end

  Autotest.add_hook :green do |at|
    notify SUCCESS_STOCK_ICON, "All tests passed, good job!", ""
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
bencodr-3.0.2 .autotest
bencodr-3.0.1 .autotest
bencodr-2.0.1 .autotest
bencodr-3.0.0 .autotest
bencodr-2.0.0 .autotest
bencodr-1.2.0 .autotest
bencodr-1.1.0 .autotest
bencodr-1.0.1 .autotest
bencode_blatyo-1.0.1 .autotest
bencode_blatyo-1.0.0 .autotest