Module: Notifier::GNTP
Instance Method Summary collapse
- #host ⇒ Object
- #notify(options) ⇒ Object
- #port ⇒ Object
- #ssh_connection ⇒ Object
- #supported? ⇒ Boolean
Instance Method Details
#host ⇒ Object
14 15 16 |
# File 'lib/notifier/gntp.rb', line 14 def host ENV["GNTP_HOST"] || ssh_connection || "127.0.0.1" end |
#notify(options) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/notifier/gntp.rb', line 22 def notify() gntp = Adapters::GNTP.new({ name: "test_notifier", host: host, port: port }) gntp.notify({ name: "status", title: [:title], message: [:message], icon: [:image] }) end |
#port ⇒ Object
10 11 12 |
# File 'lib/notifier/gntp.rb', line 10 def port ENV.fetch("GNTP_PORT", 23053) end |
#ssh_connection ⇒ Object
18 19 20 |
# File 'lib/notifier/gntp.rb', line 18 def ssh_connection ENV["SSH_CONNECTION"][/^([^ ]+)/, 1] if ENV["SSH_CONNECTION"] end |
#supported? ⇒ Boolean
3 4 5 6 7 8 |
# File 'lib/notifier/gntp.rb', line 3 def supported? Timeout.timeout(1) { TCPSocket.new(host, port).close } true rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH, Timeout::Error false end |