Skip to content

Instantly share code, notes, and snippets.

@paneq
Created June 14, 2012 22:46
Show Gist options
  • Save paneq/2933478 to your computer and use it in GitHub Desktop.
Save paneq/2933478 to your computer and use it in GitHub Desktop.
Native operating system notifications about rails requests time
# config/environments/development.rb
NOTIFIER = case RUBY_PLATFORM
when /linux/
Bundler.require(:linux)
Proc.new{|title, text| Libnotify.show(:body => text, :summary => title) }
when /darwin|mac/
Bundler.require(:darwin)
Proc.new{|title, text| Growl.notify(text, :title => title) }
else
nil
end
ActiveSupport::Notifications.subscribe "process_action.action_controller" do |name, start, finish, id, payload|
NOTIFIER.call(payload[:path], (finish - start).to_s) if NOTIFIER
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment