Class: PasteHub::NotificationCenter
- Inherits:
-
PluginBase
- Object
- PluginBase
- PasteHub::NotificationCenter
- Defined in:
- lib/pastehub/plugin/notification_center.rb
Instance Method Summary collapse
- #display_config ⇒ Object
-
#initialize ⇒ NotificationCenter
constructor
A new instance of NotificationCenter.
- #newly_arrived(message) ⇒ Object
Constructor Details
#initialize ⇒ NotificationCenter
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/pastehub/plugin/notification_center.rb', line 39 def initialize() @enable = false case RbConfig::CONFIG['host_os'] when /^darwin/ # MacOS X @notifier_path = RbConfig::CONFIG['bindir'] + "/" + "terminal-notifier" if File.exist?( @notifier_path ) @enable = true end end end |
Instance Method Details
#display_config ⇒ Object
51 52 53 54 55 |
# File 'lib/pastehub/plugin/notification_center.rb', line 51 def display_config if @enable STDERR.puts( "Info: found terminal-notifier for MacOS X." ) end end |
#newly_arrived(message) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/pastehub/plugin/notification_center.rb', line 57 def newly_arrived() config = PasteHub::Config.instance if @enable str = if config.notifyMessageMax < .size [0...config.notifyMessageMax] + " ..." else end url_option = '' util = PasteHub::Util.new if util.pulloutURL( str ) url_option = '-open \'' + util.pulloutURL( str ) + '\'' end command = sprintf( "%s -title 'PasteHub' -message '\\%s' %s", @notifier_path, str, url_option ) system( command ) end nil end |