Allows sending user notifications in a cross-platform way.
A list of commandline tool names that can be used to send notifications
Send a notification. If no notifier is found, no notification will be created.
@param [String] message The message to include in the notification
# File lib/nanoc/cli/commands/watch.rb, line 106 def notify(message) return if tool.nil? if tool == 'growlnotify' && self.on_windows? self.growlnotify_windows(message) else send(tool.tr('-', '_'), message) end end
# File lib/nanoc/cli/commands/watch.rb, line 154 def growlnotify(message) system(*self.growlnotify_cmd_for(message)) end
# File lib/nanoc/cli/commands/watch.rb, line 150 def growlnotify_cmd_for(message) [ 'growlnotify', '-m', message ] end
# File lib/nanoc/cli/commands/watch.rb, line 162 def growlnotify_windows(message) system(*self.growlnotify_windows_cmd_for(message)) end
# File lib/nanoc/cli/commands/watch.rb, line 158 def growlnotify_windows_cmd_for(message) [ 'growlnotify', '/t:nanoc', message ] end
# File lib/nanoc/cli/commands/watch.rb, line 129 def have_tool?(tool) if self.on_windows? self.have_tool_windows?(tool) else self.have_tool_nix?(tool) end end
# File lib/nanoc/cli/commands/watch.rb, line 117 def have_tool_nix?(tool) !`which #{tool}`.empty? rescue Errno::ENOENT false end
# File lib/nanoc/cli/commands/watch.rb, line 123 def have_tool_windows?(tool) !`where #{tool} 2> nul`.empty? rescue Errno::ENOENT false end
# File lib/nanoc/cli/commands/watch.rb, line 166 def notify_send(message) system('notify-send', message) end
# File lib/nanoc/cli/commands/watch.rb, line 170 def on_windows? !!(RUBY_PLATFORM =~ /(mingw|bccwin|wince|mswin32)/) end
Generated with the Darkfish Rdoc Generator 2.