Sha256: bccb7c7be8e177587619fb3ae34edb09c71dcaa6e6060e8aa69c29ba665fe90e

Contents?: true

Size: 949 Bytes

Versions: 26

Compression:

Stored size: 949 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

26 entries across 26 versions & 8 rubygems

Version Path
honeybadger-5.4.0 vendor/bundle/ruby/3.2.0/gems/notiffany-0.1.3/lib/notiffany/notifier/terminal_title.rb
honeybadger-5.3.0 vendor/bundle/ruby/3.2.0/gems/notiffany-0.1.3/lib/notiffany/notifier/terminal_title.rb
op_connect-0.1.2 vendor/bundle/ruby/3.1.0/gems/notiffany-0.1.3/lib/notiffany/notifier/terminal_title.rb
qiita_org-0.1.35 gems/ruby/2.7.0/gems/notiffany-0.1.3/lib/notiffany/notifier/terminal_title.rb
qiita_org-0.1.34 gems/ruby/2.7.0/gems/notiffany-0.1.3/lib/notiffany/notifier/terminal_title.rb
qiita_org-0.1.33 gems/ruby/2.7.0/gems/notiffany-0.1.3/lib/notiffany/notifier/terminal_title.rb
qiita_org-0.1.32 gems/ruby/2.7.0/gems/notiffany-0.1.3/lib/notiffany/notifier/terminal_title.rb
qiita_org-0.1.31 gems/ruby/2.7.0/gems/notiffany-0.1.3/lib/notiffany/notifier/terminal_title.rb
qiita_org-0.1.30 gems/ruby/2.7.0/gems/notiffany-0.1.3/lib/notiffany/notifier/terminal_title.rb
qiita_org-0.1.29 gems/ruby/2.7.0/gems/notiffany-0.1.3/lib/notiffany/notifier/terminal_title.rb
qiita_org-0.1.28 gems/ruby/2.7.0/gems/notiffany-0.1.3/lib/notiffany/notifier/terminal_title.rb
qiita_org-0.1.27 gems/ruby/2.7.0/gems/notiffany-0.1.3/lib/notiffany/notifier/terminal_title.rb
qiita_org-0.1.26 gems/ruby/2.7.0/gems/notiffany-0.1.3/lib/notiffany/notifier/terminal_title.rb
qiita_org-0.1.25 gems/ruby/2.7.0/gems/notiffany-0.1.3/lib/notiffany/notifier/terminal_title.rb
honeybadger-4.5.3 vendor/bundle/ruby/2.6.0/gems/notiffany-0.1.1/lib/notiffany/notifier/terminal_title.rb
notiffany-0.1.3 lib/notiffany/notifier/terminal_title.rb
notiffany-0.1.2 lib/notiffany/notifier/terminal_title.rb
alimentos-alu0100945645-0.1.0 vendor/bundle/ruby/2.3.0/gems/notiffany-0.1.1/lib/notiffany/notifier/terminal_title.rb
alimentos-alu0100945645-1.0.0 vendor/bundle/ruby/2.3.0/gems/notiffany-0.1.1/lib/notiffany/notifier/terminal_title.rb
comiditaULL-0.1.1 vendor/bundle/ruby/2.3.0/gems/notiffany-0.1.1/lib/notiffany/notifier/terminal_title.rb