Sha256: 9661d018cbc1e23502cf9bee63720ee55f187e939623d564a461c7667b11684a
Contents?: true
Size: 1.24 KB
Versions: 1
Compression:
Stored size: 1.24 KB
Contents
require 'fileutils' require 'rbconfig' # default helpers module Sidekick::Helpers module Util # :linux, :darwin, :other def platform [:linux, :darwin].each do |plf| return plf if Config::CONFIG['target_os'] =~ /#{plf}/i end; :other end def running?(plf) plf == platform end def gem_load?(gemname) @installed ||= begin require gemname true rescue LoadError puts "Please install the #{gemname} gem to enable all functions." false end end end include Util extend Util module Notification extend ::Sidekick::Helpers::Util def self.show(message, title='Sidekick') if running?(:linux) and gem_load?('libnotify') Libnotify.show :body => message, :summary => title elsif running?(:darwin) and gem_load?('growl') Growl.notify message, :title => title, :name => 'Sidekick' else puts "Notification: #{title} #{message}" end end end def log(str) puts ' -> ' + str end def notify(*args) Notification.show(*args) end def sh(cmd) log cmd puts `#{cmd}` end def restart_passenger FileUtils.touch './tmp/restart.txt' log 'restarted passenger' end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sidekick-0.2.0 | lib/sidekick/helpers.rb |