From dd6cc19307484992b2c7237d48ef3352ed70562c Mon Sep 17 00:00:00 2001 From: Richard Huang Date: Thu, 24 Mar 2022 19:36:07 +0800 Subject: [PATCH] drop Growl support --- README.md | 33 ++----------- lib/uniform_notifier.rb | 8 --- lib/uniform_notifier/growl.rb | 76 ----------------------------- spec/spec_helper.rb | 1 - spec/uniform_notifier/growl_spec.rb | 69 -------------------------- uniform_notifier.gemspec | 6 +-- 6 files changed, 6 insertions(+), 187 deletions(-) delete mode 100644 lib/uniform_notifier/growl.rb delete mode 100644 spec/uniform_notifier/growl_spec.rb diff --git a/README.md b/README.md index 2b85346..7e7745c 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Status](https://secure.travis-ci.org/flyerhzm/uniform_notifier.svg)](http://travis-ci.org/flyerhzm/uniform_notifier) [![AwesomeCode Status for flyerhzm/uniform_notifier](https://awesomecode.io/projects/3e29a7de-0b37-4ecf-b06d-410ebf815174/status)](https://awesomecode.io/repos/flyerhzm/uniform_notifier) -uniform_notifier is extracted from [bullet][0], it gives you the ability to send notification through rails logger, customized logger, javascript alert, javascript console, growl, xmpp, airbrake, honeybadger and AppSignal. +uniform_notifier is extracted from [bullet][0], it gives you the ability to send notification through rails logger, customized logger, javascript alert, javascript console, xmpp, airbrake, honeybadger and AppSignal. ## Install @@ -12,14 +12,6 @@ uniform_notifier is extracted from [bullet][0], it gives you the ability to send gem install uniform_notifier -if you want to notify by growl < v1.3, you should install ruby-growl first - - gem install ruby-growl - -if you want to notify by growl v1.3+, you should install ruby_gntp first - - gem install ruby_gntp - if you want to notify by xmpp, you should install xmpp4r first gem install xmpp4r @@ -56,13 +48,13 @@ if you want to notify by terminal-notifier, you must install it first gem "uniform_notifier" - you should add ruby-growl, ruby_gntp, xmpp4r, airbrake, bugsnag, honeybadger, slack-notifier, terminal-notifier gem if you want. + you should add xmpp4r, airbrake, bugsnag, honeybadger, slack-notifier, terminal-notifier gem if you want. ## Usage There are two types of notifications, one is inline_notify, for javascript alert and javascript console notifiers, which returns a string and will be combined, -the other is out_of_channel_notify, for rails logger, customized logger, growl and xmpp, which doesn't return anything, just send the message to the notifiers. +the other is out_of_channel_notify, for rails logger, customized logger, xmpp, which doesn't return anything, just send the message to the notifiers. By default, all notifiers are disabled, you should enable them first. @@ -120,11 +112,6 @@ logger = File.open('notify.log', 'a+') logger.sync = true UniformNotifier.customized_logger = logger -# growl without password -UniformNotifier.growl = true -# growl with passowrd -UniformNotifier.growl = { :password => 'growl password' } - # xmpp UniformNotifier.xmpp = { :account => 'sender_account@jabber.org', :password => 'password_for_jabber', @@ -146,7 +133,7 @@ UniformNotifier.raise = false # don't raise errors After that, you can enjoy the notifiers, that's cool! ```ruby -# the notify message will be notified to rails logger, customized logger, growl or xmpp. +# the notify message will be notified to rails logger, customized logger or xmpp. UniformNotifier.active_notifiers.each do |notifier| notifier.out_of_channel_notify("customize message") end @@ -161,18 +148,6 @@ end javascript_str = responses.join("\n") ``` -## Growl Support - -To get Growl support up-and-running, follow the steps below: - -* For Growl < v1.3, install the ruby-growl gem: gem install ruby-growl -* For Growl v1.3+, install the ruby_gntp gem: gem install ruby_gntp -* Open the Growl preference pane in Systems Preferences -* Click the "Network" tab -* Make sure both "Listen for incoming notifications" and "Allow remote application registration" are checked. *Note*: If you set a password, you will need to set UniformNotifier.growl_password = { :password => 'growl password' } in the config file. -* Restart Growl ("General" tab -> Stop Growl -> Start Growl) -* Boot up your application. UniformNotifier will automatically send a Growl notification when Growl is turned on. If you do not see it when your application loads, make sure it is enabled in your initializer and double-check the steps above. - ## XMPP/Jabber Support To get XMPP support up-and-running, follow the steps below: diff --git a/lib/uniform_notifier.rb b/lib/uniform_notifier.rb index 0cd6732..c097bb1 100644 --- a/lib/uniform_notifier.rb +++ b/lib/uniform_notifier.rb @@ -4,7 +4,6 @@ require 'uniform_notifier/errors' require 'uniform_notifier/javascript_alert' require 'uniform_notifier/javascript_console' -require 'uniform_notifier/growl' require 'uniform_notifier/honeybadger' require 'uniform_notifier/xmpp' require 'uniform_notifier/rails_logger' @@ -22,7 +21,6 @@ class UniformNotifier AVAILABLE_NOTIFIERS = %i[ alert console - growl honeybadger xmpp rails_logger @@ -40,7 +38,6 @@ class UniformNotifier NOTIFIERS = [ JavascriptAlert, JavascriptConsole, - Growl, HoneybadgerNotifier, Xmpp, RailsLogger, @@ -65,11 +62,6 @@ def active_notifiers NOTIFIERS.select(&:active?) end - undef growl= - def growl=(growl) - UniformNotifier::Growl.setup_connection(growl) - end - undef xmpp= def xmpp=(xmpp) UniformNotifier::Xmpp.setup_connection(xmpp) diff --git a/lib/uniform_notifier/growl.rb b/lib/uniform_notifier/growl.rb deleted file mode 100644 index 3d2debd..0000000 --- a/lib/uniform_notifier/growl.rb +++ /dev/null @@ -1,76 +0,0 @@ -# frozen_string_literal: true - -class UniformNotifier - class Growl < Base - class << self - @growl = nil - - def active? - @growl - end - - def setup_connection(growl) - setup_connection_growl(growl) - rescue LoadError - begin - setup_connection_gntp(growl) - rescue LoadError - @growl = nil - raise NotificationError, - 'You must install the ruby-growl or the ruby_gntp gem to use Growl notification: `gem install ruby-growl` or `gem install ruby_gntp`' - end - end - - def setup_connection_growl(growl) - return unless growl - - require 'ruby-growl' - if growl.instance_of?(Hash) - @password = growl.include?(:password) ? growl[:password] : nil - @host = growl.include?(:host) ? growl[:host] : 'localhost' - end - @password ||= nil - @host ||= 'localhost' - @growl = ::Growl.new @host, 'uniform_notifier' - @growl.add_notification 'uniform_notifier' - @growl.password = @password - - notify 'Uniform Notifier Growl has been turned on' if !growl.instance_of?(Hash) || !growl[:quiet] - end - - def setup_connection_gntp(growl) - return unless growl - - require 'ruby_gntp' - if growl.instance_of?(Hash) - @password = growl.include?(:password) ? growl[:password] : nil - @host = growl.include?(:host) ? growl[:host] : 'localhost' - end - @password ||= nil - @host ||= 'localhost' - @growl = GNTP.new('uniform_notifier', @host, @password, 23_053) - @growl.register(notifications: [{ name: 'uniform_notifier', enabled: true }]) - - notify 'Uniform Notifier Growl has been turned on (using GNTP)' if !growl.instance_of?(Hash) || !growl[:quiet] - end - - protected - - def _out_of_channel_notify(data) - message = data.values.compact.join("\n") - - notify(message) - end - - private - - def notify(message) - if defined?(::Growl) && @growl.is_a?(::Growl) - @growl.notify('uniform_notifier', 'Uniform Notifier', message) - elsif defined?(::GNTP) && @growl.is_a?(::GNTP) - @growl.notify(name: 'uniform_notifier', title: 'Uniform Notifier', text: message) - end - end - end - end -end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 0c8fef8..b865c3c 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -3,7 +3,6 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) require 'uniform_notifier' -require 'ruby-growl' require 'xmpp4r' require 'slack-notifier' require 'rspec' diff --git a/spec/uniform_notifier/growl_spec.rb b/spec/uniform_notifier/growl_spec.rb deleted file mode 100644 index bb8c64f..0000000 --- a/spec/uniform_notifier/growl_spec.rb +++ /dev/null @@ -1,69 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe UniformNotifier::Growl do - it 'should not notify growl' do - expect(UniformNotifier::Growl.out_of_channel_notify(title: 'notify growl')).to be_nil - end - - it 'should notify growl without password' do - growl = double('growl', is_a?: true) - expect(Growl).to receive(:new).with('localhost', 'uniform_notifier').and_return(growl) - expect(growl).to receive(:add_notification).with('uniform_notifier') - expect(growl).to receive(:password=).with(nil) - expect(growl).to receive(:notify) - .with('uniform_notifier', 'Uniform Notifier', 'Uniform Notifier Growl has been turned on') - .ordered - expect(growl).to receive(:notify) - .with('uniform_notifier', 'Uniform Notifier', 'notify growl without password') - .ordered - - UniformNotifier.growl = true - UniformNotifier::Growl.out_of_channel_notify(title: 'notify growl without password') - end - - it 'should notify growl with password' do - growl = double('growl', is_a?: true) - expect(Growl).to receive(:new).with('localhost', 'uniform_notifier').and_return(growl) - expect(growl).to receive(:add_notification).with('uniform_notifier') - expect(growl).to receive(:password=).with('123456') - expect(growl).to receive(:notify) - .with('uniform_notifier', 'Uniform Notifier', 'Uniform Notifier Growl has been turned on') - .ordered - expect(growl).to receive(:notify).with('uniform_notifier', 'Uniform Notifier', 'notify growl with password').ordered - - UniformNotifier.growl = { password: '123456' } - UniformNotifier::Growl.out_of_channel_notify(title: 'notify growl with password') - end - - it 'should notify growl with host' do - growl = double('growl', is_a?: true) - expect(Growl).to receive(:new).with('10.10.156.17', 'uniform_notifier').and_return(growl) - expect(growl).to receive(:add_notification).with('uniform_notifier') - expect(growl).to receive(:password=).with('123456') - expect(growl).to receive(:notify) - .with('uniform_notifier', 'Uniform Notifier', 'Uniform Notifier Growl has been turned on') - .ordered - expect(growl).to receive(:notify).with('uniform_notifier', 'Uniform Notifier', 'notify growl with password').ordered - - UniformNotifier.growl = { password: '123456', host: '10.10.156.17' } - UniformNotifier::Growl.out_of_channel_notify(title: 'notify growl with password') - end - - it 'should notify growl with quiet' do - growl = double('growl', is_a?: true) - expect(Growl).to receive(:new).with('localhost', 'uniform_notifier').and_return(growl) - expect(growl).to receive(:add_notification).with('uniform_notifier') - expect(growl).to receive(:password=).with('123456') - expect(growl).not_to receive(:notify).with( - 'uniform_notifier', - 'Uniform Notifier', - 'Uniform Notifier Growl has been turned on' - ) - expect(growl).to receive(:notify).with('uniform_notifier', 'Uniform Notifier', 'notify growl with password') - - UniformNotifier.growl = { password: '123456', quiet: true } - UniformNotifier::Growl.out_of_channel_notify(title: 'notify growl with password') - end -end diff --git a/uniform_notifier.gemspec b/uniform_notifier.gemspec index 79316d4..d3dc679 100644 --- a/uniform_notifier.gemspec +++ b/uniform_notifier.gemspec @@ -10,15 +10,13 @@ Gem::Specification.new do |s| s.authors = ['Richard Huang'] s.email = ['flyerhzm@gmail.com'] s.homepage = 'http://rubygems.org/gems/uniform_notifier' - s.summary = 'uniform notifier for rails logger, customized logger, javascript alert, javascript console, growl and xmpp' - s.description = 'uniform notifier for rails logger, customized logger, javascript alert, javascript console, growl and xmpp' + s.summary = 'uniform notifier for rails logger, customized logger, javascript alert, javascript console and xmpp' + s.description = 'uniform notifier for rails logger, customized logger, javascript alert, javascript console and xmpp' s.license = 'MIT' s.required_ruby_version = '>= 2.3' s.add_development_dependency 'rspec', ['> 0'] - s.add_development_dependency 'ruby_gntp', ['= 0.3.4'] - s.add_development_dependency 'ruby-growl', ['= 4.0'] s.add_development_dependency 'slack-notifier', ['>= 1.0'] s.add_development_dependency 'xmpp4r', ['= 0.5']