Module: Kvetch
- Defined in:
- lib/kvetch.rb,
lib/kvetch/version.rb
Constant Summary collapse
- VERSION =
"1.0.3"
Class Method Summary collapse
-
.silence! ⇒ Object
Silence methods.
- .silent? ⇒ Boolean
- .unsilence! ⇒ Object
-
.yell(message, options = {}) ⇒ Object
Main usage: Kvetch.yell(MESSAGE).
Class Method Details
.silence! ⇒ Object
Silence methods
34 |
# File 'lib/kvetch.rb', line 34 def self.silence!() @silenced = true end |
.silent? ⇒ Boolean
36 |
# File 'lib/kvetch.rb', line 36 def self.silent?() @silenced end |
.unsilence! ⇒ Object
35 |
# File 'lib/kvetch.rb', line 35 def self.unsilence!() @silenced = false end |
.yell(message, options = {}) ⇒ Object
Main usage: Kvetch.yell(MESSAGE)
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/kvetch.rb', line 7 def self.yell(, = {}) return false if @silenced if .is_a? String if OS.mac? && `sw_vers -productVersion` >= '10.8' bin = File.('../../vendor/terminal-notifier/kvetch.app/Contents/MacOS/terminal-notifier', __FILE__) [:sound].capitalize! if [:sound] = .merge(:message => ).map do |argument, value| value = value.to_s; ["-#{argument}", "#{Shellwords.escape(value[0,1])}#{value[1..-1]}"] end command = [bin, *.flatten] command = Shellwords.join(command) if RUBY_VERSION < '1.9' IO.popen(command) # send message and options to terminal-notifier/kvetch.app elsif OS.linux? || OS.unix? `notify-send \"#{message}\"` else # OS doesn't have notification support return "Kvetch works on Linux, Unix, or Mac OS X >= 10.8." end else # message is not a string return "You should give that kvetch a string. Kvetches love strings." end end |