Class: Guard::Notifier::TerminalTitle

Inherits:
Base
  • Object
show all
Defined in:
lib/guard/notifiers/terminal_title.rb

Overview

Shows system notifications in the terminal title bar.

Constant Summary

Constants inherited from Base

Base::HOSTS

Instance Attribute Summary

Attributes inherited from Base

#options

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

_supported_host?, available?, gem_name, #images_path, #initialize, name, #name, #normalize_standard_options!, require_gem_safely, supported_hosts, title, #title

Constructor Details

This class inherits a constructor from Guard::Notifier::Base

Class Method Details

.turn_offObject

Clears the terminal title



28
29
30
# File 'lib/guard/notifiers/terminal_title.rb', line 28

def self.turn_off
  puts "\e]2;\a"
end

Instance Method Details

#notify(message, opts = {}) ⇒ Object

Shows a system notification.

Options Hash (opts):

  • message (String)

    the notification message body

  • type (String)

    the notification type. Either 'success', 'pending', 'failed' or 'notify'

  • title (String)

    the notification title



18
19
20
21
22
23
24
# File 'lib/guard/notifiers/terminal_title.rb', line 18

def notify(message, opts = {})
  super

  first_line = message.sub(/^\n/, '').sub(/\n.*/m, '')

  puts "\e]2;[#{ opts[:title] }] #{ first_line }\a"
end