Sha256: 97299bde8b5381fe61454b28db4b2298facce4096d490b5b629e2662957cb39d

Contents?: true

Size: 1002 Bytes

Versions: 4

Compression:

Stored size: 1002 Bytes

Contents

# -*- encoding : utf-8 -*-

# Wrapper for the UI notifier
class Gitdocs::Notifier
  INFO_ICON = File.expand_path('../../img/icon.png', __FILE__)

  def initialize(show_notifications)
    @show_notifications = show_notifications
    Guard::Notifier.turn_on if @show_notifications
  end

  def info(title, message)
    if @show_notifications
      Guard::Notifier.notify(message, title: title, image: INFO_ICON)
    else
      puts("#{title}: #{message}")
    end
  rescue # Prevent StandardErrors from stopping the daemon.
  end

  def warn(title, msg)
    if @show_notifications
      Guard::Notifier.notify(msg, title: title)
    else
      Kernel.warn("#{title}: #{msg}")
    end
  rescue # Prevent StandardErrors from stopping the daemon.
  end

  def error(title, message)
    if @show_notifications
      Guard::Notifier.notify(message, title: title, image: :failure)
    else
      Kernel.warn("#{title}: #{message}")
    end
  rescue # Prevent StandardErrors from stopping the daemon.
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
gitdocs-0.5.0.pre6 lib/gitdocs/notifier.rb
gitdocs-0.5.0.pre5 lib/gitdocs/notifier.rb
gitdocs-0.5.0.pre3 lib/gitdocs/notifier.rb
gitdocs-0.5.0.pre2 lib/gitdocs/notifier.rb