Sha256: 1845a12bcfc2fa6ffca95bb9273fc75ee75088d579c64076f106ac0a643cf36a

Contents?: true

Size: 953 Bytes

Versions: 12

Compression:

Stored size: 953 Bytes

Contents

require "notiffany/notifier/base"

module Notiffany
  class Notifier
    # Shows system notifications in the terminal title bar.
    #
    class TerminalTitle < Base
      DEFAULTS = {}

      # Clears the terminal title
      def turn_off
        STDOUT.puts "\e]2;\a"
      end

      private

      def _gem_name
        nil
      end

      def _check_available(_options)
      end

      # Shows a system notification.
      #
      # @param [Hash] opts additional notification library options
      # @option opts [String] message the notification message body
      # @option opts [String] type the notification type. Either 'success',
      #   'pending', 'failed' or 'notify'
      # @option opts [String] title the notification title
      #
      def _perform_notify(message, opts = {})
        first_line = message.sub(/^\n/, "").sub(/\n.*/m, "")

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

Version data entries

12 entries across 12 versions & 3 rubygems

Version Path
mastermind_adeybee-0.1.4 vendor/bundle/ruby/2.2.0/gems/notiffany-0.0.8/lib/notiffany/notifier/terminal_title.rb
mastermind_adeybee-0.1.3 vendor/bundle/ruby/2.2.0/gems/notiffany-0.0.8/lib/notiffany/notifier/terminal_title.rb
mastermind_adeybee-0.1.2 vendor/bundle/ruby/2.2.0/gems/notiffany-0.0.8/lib/notiffany/notifier/terminal_title.rb
mastermind_adeybee-0.1.1 vendor/bundle/ruby/2.2.0/gems/notiffany-0.0.8/lib/notiffany/notifier/terminal_title.rb
notiffany-0.0.8 lib/notiffany/notifier/terminal_title.rb
geminfo-0.1.0 path/gems/notiffany-0.0.7/lib/notiffany/notifier/terminal_title.rb
notiffany-0.0.7 lib/notiffany/notifier/terminal_title.rb
notiffany-0.0.6 lib/notiffany/notifier/terminal_title.rb
notiffany-0.0.5 lib/notiffany/notifier/terminal_title.rb
notiffany-0.0.4 lib/notiffany/notifier/terminal_title.rb
notiffany-0.0.3 lib/notiffany/notifier/terminal_title.rb
notiffany-0.0.2 lib/notiffany/notifier/terminal_title.rb