Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

added terminal-notifier gem as dependency. server now detects termina…

…l-notifier binary.
  • Loading branch information...
commit ee575635025daffe5f72ec2a5025874e77d89fe9 1 parent 48e95a6
Damon Davison authored August 02, 2012
17  lib/synack/server.rb
@@ -7,13 +7,11 @@ class Server
7 7
 
8 8
     DEFAULT_OPTIONS = {
9 9
       host: 'localhost',
10  
-      port: 11113
  10
+      port: 11113,
11 11
     }
12 12
 
13 13
     attr_reader :host, :port, :socket
14 14
 
15  
-    # Class methods ================================================================================
16  
-
17 15
     def self.start(options={})
18 16
       options = DEFAULT_OPTIONS.merge(options)
19 17
       @host = options[:host]
@@ -28,7 +26,15 @@ def self.stop
28 26
       ::DRb.stop_service
29 27
     end
30 28
 
31  
-    # Instance methods =============================================================================
  29
+    def binary
  30
+      binary = '/Applications/terminal-notifier.app/Contents/MacOS/terminal-notifier'
  31
+      unless File.exists? binary
  32
+        binary = `which "terminal-notifier"`
  33
+        binary.chomp!
  34
+        raise "terminal-notifier could not be found in path" unless $? == 0
  35
+      end
  36
+      binary
  37
+    end
32 38
 
33 39
     def sanitize(message)
34 40
       message && message.gsub(/[^0-9A-z\.\-\'\, ]/, '_')
@@ -36,7 +42,8 @@ def sanitize(message)
36 42
 
37 43
     def say(message)
38 44
       puts message
39  
-      system "/Applications/terminal-notifier.app/Contents/MacOS/terminal-notifier -message \"#{sanitize(message)}\""
  45
+      STDERR.puts command = "#{self.binary} -message \"#{sanitize(message)}\""
  46
+      system command
40 47
     end
41 48
 
42 49
   end
1  synack.gemspec
@@ -68,5 +68,6 @@ Gem::Specification.new do |s|
68 68
     s.add_dependency(%q<shoulda>, [">= 0"])
69 69
     s.add_dependency(%q<simplecov>, [">= 0"])
70 70
   end
  71
+  s.add_dependency "terminal-notifier"
71 72
 end
72 73
 

0 notes on commit ee57563

Please sign in to comment.
Something went wrong with that request. Please try again.