terminal-notifier 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -21,10 +21,11 @@ Examples are:
21
21
  ```ruby
22
22
  TerminalNotifier.notify('Hello World')
23
23
  TerminalNotifier.notify('Hello World', :title => 'Ruby')
24
- TerminalNotifier.notify('Hello World', :group => Process.pid)
25
24
  TerminalNotifier.notify('Hello World', :activate => 'com.apple.Safari')
26
25
  TerminalNotifier.notify('Hello World', :open => 'http://twitter.com/alloy')
27
26
  TerminalNotifier.notify('Hello World', :execute => 'say "OMG"')
27
+ TerminalNotifier.notify('Hello World', :group => Process.pid)
28
+ TerminalNotifier.remove('previous Process.pid')
28
29
  ```
29
30
 
30
31
 
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ if $0 == __FILE__
4
+ $:.unshift File.expand_path('../../lib', __FILE__)
5
+ end
6
+
7
+ require 'terminal-notifier'
8
+
9
+ TerminalNotifier.execute(ARGV)
@@ -9,16 +9,26 @@ module TerminalNotifier
9
9
  @available
10
10
  end
11
11
 
12
- # Executes the `terminal-notifier` tool through Kernel::system while
13
- # redirecting output to `/dev/null`.
14
- def self.silent_execute(options)
12
+ def self.silence_stdout
15
13
  stdout = STDOUT.clone
16
14
  STDOUT.reopen(File.new('/dev/null', 'w'))
17
- system(BIN_PATH, *options)
15
+ yield
18
16
  ensure
19
17
  STDOUT.reopen(stdout)
20
18
  end
21
19
 
20
+ def self.execute_with_options(options)
21
+ execute(options.map { |k,v| ["-#{k}", v.to_s] }.flatten)
22
+ end
23
+
24
+ def self.execute(argv)
25
+ if available?
26
+ system(BIN_PATH, *argv)
27
+ else
28
+ raise "terminal-notifier is only supported on Mac OS X 10.8, or higher."
29
+ end
30
+ end
31
+
22
32
  # Sends a User Notification and returns wether or not it was a success.
23
33
  #
24
34
  # The available options are `:title`, `:group`, `:activate`, `:open`, and
@@ -37,11 +47,26 @@ module TerminalNotifier
37
47
  #
38
48
  # Raises if not supported on the current platform.
39
49
  def notify(message, options = {})
40
- if TerminalNotifier.available?
41
- TerminalNotifier.silent_execute(options.merge(:message => message).map { |k,v| ["-#{k}", v.to_s] }.flatten)
42
- else
43
- raise "terminal-notifier is only supported on Mac OS X 10.8, or higher."
44
- end
50
+ TerminalNotifier.silence_stdout { TerminalNotifier.verbose_notify(message, options) }
45
51
  end
46
52
  module_function :notify
53
+
54
+ # The same as `verbose`, but sends the output from the tool to STDOUT.
55
+ def verbose_notify(message, options = {})
56
+ TerminalNotifier.execute_with_options(options.merge(:message => message))
57
+ end
58
+ module_function :verbose_notify
59
+
60
+ # Removes a notification that was previously sent with the specified
61
+ # ‘group’ ID, if one exists.
62
+ def remove(group)
63
+ TerminalNotifier.silence_stdout { TerminalNotifier.verbose_remove(group) }
64
+ end
65
+ module_function :remove
66
+
67
+ # The same as `remove`, but sends the output from the tool to STDOUT.
68
+ def verbose_remove(group)
69
+ TerminalNotifier.execute_with_options(:remove => group)
70
+ end
71
+ module_function :verbose_remove
47
72
  end
@@ -20,19 +20,38 @@ status of commands which are executed due to filesystem changes. (v3.0.0)
20
20
  Prebuilt binaries, which are code-signed and ready to use, are available from
21
21
  the [downloads section](https://github.com/alloy/terminal-notifier/downloads).
22
22
 
23
+ Or if you want to use this from
24
+ [Ruby](https://github.com/alloy/terminal-notifier/tree/master/Ruby), you can
25
+ install it through RubyGems:
26
+
27
+ ```
28
+ $ [sudo] gem install terminal-notifier
29
+ ```
30
+
23
31
 
24
32
  ## Usage
25
33
 
26
34
  ```
27
- $ ./terminal-notifier.app/Contents/MacOS/terminal-notifier -message VALUE [options]
35
+ $ ./terminal-notifier.app/Contents/MacOS/terminal-notifier -[message|group] [VALUE|ID] [options]
28
36
  ```
29
37
 
30
38
  In order to use terminal-notifier, you have to call the binary _inside_ the
31
- application mbundle.
39
+ application bundle.
40
+
41
+ The Ruby gem, which wraps this tool, _does_ have a bin wrapper. If installed
42
+ you can simply do:
43
+
44
+ ```
45
+ $ terminal-notifier -[message|group] [VALUE|ID] [options]
46
+ ```
47
+
48
+ This will obviously be a bit slower than using the tool without the wrapper.
49
+
32
50
 
33
51
  #### Options
34
52
 
35
- The `-message` option is the only one that is required.
53
+ At a minimum, you have to specify either the `-message` option or the `-remove`
54
+ option.
36
55
 
37
56
  -------------------------------------------------------------------------------
38
57
 
@@ -53,6 +72,9 @@ The title of the notification. This defaults to ‘Terminal’.
53
72
  Specifies the ‘group’ a notification belongs to. For any ‘group’ only _one_
54
73
  notification will ever be shown, replacing previously posted notifications.
55
74
 
75
+ A notification can be explicitely removed with the `-remove` option, describe
76
+ below.
77
+
56
78
  Examples are:
57
79
 
58
80
  * The sender’s name to scope the notifications by tool.
@@ -61,6 +83,13 @@ Examples are:
61
83
 
62
84
  -------------------------------------------------------------------------------
63
85
 
86
+ `-remove ID` **[required]**
87
+
88
+ Removes a notification that was previously sent with the specified ‘group’ ID,
89
+ if one exists.
90
+
91
+ -------------------------------------------------------------------------------
92
+
64
93
  `-activate ID`
65
94
 
66
95
  Specifies which application should be activated when the user clicks the
@@ -19,11 +19,11 @@
19
19
  <key>CFBundlePackageType</key>
20
20
  <string>APPL</string>
21
21
  <key>CFBundleShortVersionString</key>
22
- <string>1.2.0</string>
22
+ <string>1.3.0</string>
23
23
  <key>CFBundleSignature</key>
24
24
  <string>????</string>
25
25
  <key>CFBundleVersion</key>
26
- <string>3</string>
26
+ <string>4</string>
27
27
  <key>DTCompiler</key>
28
28
  <string></string>
29
29
  <key>DTPlatformBuild</key>
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: terminal-notifier
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
- - 2
8
+ - 3
9
9
  - 0
10
- version: 1.2.0
10
+ version: 1.3.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Eloy Duran
@@ -15,19 +15,61 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-07-28 00:00:00 Z
19
- dependencies: []
20
-
18
+ date: 2012-07-30 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: bacon
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
31
+ version: "0"
32
+ type: :development
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: mocha
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ hash: 3
43
+ segments:
44
+ - 0
45
+ version: "0"
46
+ type: :development
47
+ version_requirements: *id002
48
+ - !ruby/object:Gem::Dependency
49
+ name: mocha-on-bacon
50
+ prerelease: false
51
+ requirement: &id003 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ hash: 3
57
+ segments:
58
+ - 0
59
+ version: "0"
60
+ type: :development
61
+ version_requirements: *id003
21
62
  description:
22
63
  email:
23
64
  - eloy.de.enige@gmail.com
24
- executables: []
25
-
65
+ executables:
66
+ - terminal-notifier
26
67
  extensions: []
27
68
 
28
69
  extra_rdoc_files:
29
70
  - README.markdown
30
71
  files:
72
+ - bin/terminal-notifier
31
73
  - lib/terminal-notifier.rb
32
74
  - vendor/terminal-notifier/README.markdown
33
75
  - vendor/terminal-notifier/terminal-notifier.app/Contents/_CodeSignature/CodeResources