guard 1.3.3 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,7 @@
1
+ ## 1.4.0 - 26 September, 2012
2
+
3
+ - [#331][] Add tmux notifier. ([@royvandewater][])
4
+
1
5
  ## 1.3.3 - 20 September, 2012
2
6
 
3
7
  - Add Guard application icon to GNTP notifier. ([@netzpirat][])
@@ -595,6 +599,7 @@ The Listen integration has been supervised by [@thibaudgg][] and executed by [@M
595
599
  [#316]: https://github.com/guard/guard/issues/316
596
600
  [#317]: https://github.com/guard/guard/issues/317
597
601
  [#324]: https://github.com/guard/guard/issues/324
602
+ [#331]: https://github.com/guard/guard/issues/331
598
603
  [@Gazer]: https://github.com/Gazer
599
604
  [@Maher4Ever]: https://github.com/Maher4Ever
600
605
  [@alandipert]: https://github.com/alandipert
@@ -648,6 +653,7 @@ The Listen integration has been supervised by [@thibaudgg][] and executed by [@M
648
653
  [@philomory]: https://github.com/philomory
649
654
  [@pirukire]: https://github.com/pirukire
650
655
  [@rmm5t]: https://github.com/rmm5t
656
+ [@royvandewater]: https://github.com/royvandewater
651
657
  [@rupert654]: https://github.com/rupert654
652
658
  [@rymai]: https://github.com/rymai
653
659
  [@scottdavis]: https://github.com/scottdavis
data/README.md CHANGED
@@ -18,7 +18,7 @@ Features
18
18
 
19
19
  * File system changes handled by our awesome [Listen](https://github.com/guard/listen) gem.
20
20
  * Support for visual system notifications.
21
- * Huge eco-system with [more than 130](https://rubygems.org/search?query=guard-) guard plugins.
21
+ * Huge eco-system with [more than 150](https://rubygems.org/search?query=guard-) guard plugins.
22
22
  * Tested against Ruby 1.8.7, 1.9.2, 1.9.3, REE and the latest versions of JRuby & Rubinius.
23
23
 
24
24
  Screencast
@@ -52,17 +52,52 @@ Generate an empty `Guardfile` with:
52
52
  $ guard init
53
53
  ```
54
54
 
55
- If you are using Windows and want colors in your terminal, you'll have to add the
56
- [win32console](https://rubygems.org/gems/win32console) gem to your `Gemfile` and install it with Bundler:
55
+ **It's important that you always run Guard through Bundler to avoid errors.** If you're getting sick of typing `bundle exec` all
56
+ the time, try the [Rubygems Bundler](https://github.com/mpapis/rubygems-bundler).
57
+
58
+ ## OS X
59
+
60
+ You may want to install the [rb-fsevent](https://github.com/thibaudgg/rb-fsevent) gem to make use of file change events
61
+ and don't rely on polling by adding the gem to your `Gemfile` and install it with Bundler:
57
62
 
58
63
  ```ruby
59
64
  group :development do
60
- gem 'win32console'
65
+ gem 'rb-fsevent', :require => false
61
66
  end
62
67
  ```
63
68
 
64
- **It's important that you always run Guard through Bundler to avoid errors.** If you're getting sick of typing `bundle exec` all
65
- the time, try the [Rubygems Bundler](https://github.com/mpapis/rubygems-bundler).
69
+ ## Linux
70
+
71
+ You may want to install the [rb-inotify](https://github.com/nex3/rb-inotify) gem to make use of file change events and
72
+ don't rely on polling by adding the gem to your `Gemfile` and install it with Bundler:
73
+
74
+ ```ruby
75
+ group :development do
76
+ gem 'rb-inotify', :require => false
77
+ end
78
+ ```
79
+
80
+ ## Windows
81
+
82
+ You may want to install the [wdm](https://github.com/Maher4Ever/wdm) gem to make use of file change events and don't
83
+ rely on polling by adding the gem to your `Gemfile` and install it with Bundler:
84
+
85
+ ```ruby
86
+ group :development do
87
+ gem 'wdm', :require => false
88
+ end
89
+ ```
90
+
91
+ Please note that you have to use at least on Ruby 1.9.2 for using WDM.
92
+
93
+ If you want colors in your terminal, you'll have to add the [win32console](https://rubygems.org/gems/win32console) gem
94
+ to your `Gemfile` and install it with Bundler:
95
+
96
+ ```ruby
97
+ group :development do
98
+ gem 'win32console'
99
+ end
100
+ ```
66
101
 
67
102
  ### System notifications
68
103
 
@@ -169,10 +204,6 @@ group :development do
169
204
  end
170
205
  ```
171
206
 
172
- #### Emacs
173
-
174
- * Runs on any platform with Emacs + emacsclient (http://www.emacswiki.org/emacs/EmacsClient)
175
-
176
207
  #### Terminal Notifier
177
208
 
178
209
  * Runs on Mac OS X 10.8 only
@@ -188,6 +219,14 @@ group :development do
188
219
  end
189
220
  ```
190
221
 
222
+ #### Emacs
223
+
224
+ * Runs on any platform with Emacs + emacsclient (http://www.emacswiki.org/emacs/EmacsClient)
225
+
226
+ ### Tmux
227
+
228
+ * To use Tmux notifications, you have to start Guard within a [tmux](http://tmux.sourceforge.net/) session.
229
+
191
230
  Add Guard plugins
192
231
  -----------------
193
232
 
@@ -12,6 +12,9 @@ module Guard
12
12
  # * GrowlNotify
13
13
  # * Libnotify
14
14
  # * rb-notifu
15
+ # * emacs
16
+ # * Terminal Notifier
17
+ # * Tmux
15
18
  #
16
19
  # Please see the documentation of each notifier for more information about the requirements
17
20
  # and configuration possibilities.
@@ -43,6 +46,7 @@ module Guard
43
46
  require 'guard/notifiers/rb_notifu'
44
47
  require 'guard/notifiers/emacs'
45
48
  require 'guard/notifiers/terminal_notifier'
49
+ require 'guard/notifiers/tmux'
46
50
 
47
51
  extend self
48
52
 
@@ -56,7 +60,8 @@ module Guard
56
60
  [:notifysend, ::Guard::Notifier::NotifySend],
57
61
  [:notifu, ::Guard::Notifier::Notifu],
58
62
  [:emacs, ::Guard::Notifier::Emacs],
59
- [:terminal_notifier, ::Guard::Notifier::TerminalNotifier]
63
+ [:terminal_notifier, ::Guard::Notifier::TerminalNotifier],
64
+ [:tmux, ::Guard::Notifier::Tmux]
60
65
  ]
61
66
 
62
67
  # Get the available notifications.
@@ -124,7 +129,7 @@ module Guard
124
129
  return turn_off if name == :off
125
130
 
126
131
  notifier = get_notifier_module(name)
127
-
132
+
128
133
  if notifier && notifier.available?(silent)
129
134
  self.notifications = notifications << { :name => name, :options => options }
130
135
  true
@@ -166,7 +171,7 @@ module Guard
166
171
  notifier = NOTIFIERS.detect { |n| n.first == name }
167
172
  notifier ? notifier.last : notifier
168
173
  end
169
-
174
+
170
175
  # Auto detect the available notification library. This goes through
171
176
  # the list of supported notification gems and picks the first that
172
177
  # is available.
@@ -5,9 +5,9 @@ module Guard
5
5
 
6
6
  # Default options for EmacsClient
7
7
  DEFAULTS = {
8
- :client => 'emacsclient',
8
+ :client => 'emacsclient',
9
9
  :success => 'ForestGreen',
10
- :failed => 'Firebrick',
10
+ :failed => 'Firebrick',
11
11
  :default => 'Black',
12
12
  }
13
13
 
@@ -25,9 +25,9 @@ module Guard
25
25
  # @return [Boolean] the availability status
26
26
  #
27
27
  def available?(silent = false)
28
- result = `#{DEFAULTS[:client]} --eval '1' 2> /dev/null || echo 'N/A'`
28
+ result = `#{ DEFAULTS[:client] } --eval '1' 2> /dev/null || echo 'N/A'`
29
29
 
30
- if result.chomp! == "N/A"
30
+ if result.chomp! == 'N/A'
31
31
  false
32
32
  else
33
33
  true
@@ -45,7 +45,7 @@ module Guard
45
45
  # @option options [String, Integer] priority specify an int or named key (default is 0)
46
46
  #
47
47
  def notify(type, title, message, image, options = { })
48
- system(%(#{DEFAULTS[:client]} --eval "(set-face-background 'modeline \\"#{emacs_color(type)}\\")"))
48
+ system(%(#{ DEFAULTS[:client] } --eval "(set-face-background 'modeline \\"#{ emacs_color(type) }\\")"))
49
49
  end
50
50
 
51
51
  # Get the Emacs color for the notification type.
@@ -41,7 +41,7 @@ module Guard
41
41
  begin
42
42
  if ::GrowlNotify.application_name != 'Guard'
43
43
  ::GrowlNotify.config do |c|
44
- c.notifications = ['success', 'pending', 'failed', 'notify']
44
+ c.notifications = %w(success pending failed notify)
45
45
  c.default_notifications = 'notify'
46
46
  c.application_name = 'Guard'
47
47
  end
@@ -76,7 +76,7 @@ module Guard
76
76
  #
77
77
  def to_command_string(command, supported, options = {})
78
78
  options.reduce(command) do |cmd, (flag, value)|
79
- supported.include?(flag) ? cmd + " -#{flag} '#{value}'" : cmd
79
+ supported.include?(flag) ? cmd + " -#{ flag } '#{ value }'" : cmd
80
80
  end
81
81
  end
82
82
  end
@@ -0,0 +1,69 @@
1
+ module Guard
2
+ module Notifier
3
+
4
+ # Default options for Tmux
5
+
6
+ # Changes the color of the Tmux status bar
7
+ #
8
+ # @example Add the `:tmux` notifier to your `Guardfile`
9
+ # notification :tmux
10
+ #
11
+ module Tmux
12
+ extend self
13
+
14
+ DEFAULTS = {
15
+ :client => 'tmux',
16
+ :tmux_environment => 'TMUX',
17
+ :success => 'green',
18
+ :failed => 'red',
19
+ :default => 'green'
20
+ }
21
+
22
+ # Test if currently running in a Tmux session
23
+ #
24
+ # @param [Boolean] silent true if no error messages should be shown
25
+ # @return [Boolean] the availability status
26
+ #
27
+ def available?(silent = false)
28
+ if ENV[DEFAULTS[:tmux_environment]].nil?
29
+ ::Guard::UI.error 'The :tmux notifier runs only on when Guard is executed inside of a tmux session.' unless silent
30
+ false
31
+ else
32
+ true
33
+ end
34
+ end
35
+
36
+ # Show a system notification.
37
+ #
38
+ # @param [String] type the notification type. Either 'success', 'pending', 'failed' or 'notify'
39
+ # @param [String] title the notification title
40
+ # @param [String] message the notification message body
41
+ # @param [String] image the path to the notification image
42
+ # @param [Hash] options additional notification library options
43
+ # @option options [Boolean] sticky make the notification sticky
44
+ # @option options [String, Integer] priority specify an int or named key (default is 0)
45
+ #
46
+ def notify(type, title, message, image, options = { })
47
+ color = tmux_color type, options
48
+ system("#{ DEFAULTS[:client] } set -g status-left-bg #{ color }")
49
+ end
50
+
51
+ # Get the Tmux color for the notification type.
52
+ # You can configure your own color by overwriting the defaults.
53
+ #
54
+ # @param [String] type the notification type
55
+ # @return [String] the name of the emacs color
56
+ #
57
+ def tmux_color(type, options = { })
58
+ case type
59
+ when 'success'
60
+ options[:success] || DEFAULTS[:success]
61
+ when 'failed'
62
+ options[:failed] || DEFAULTS[:failed]
63
+ else
64
+ options[:default] || DEFAULTS[:default]
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
@@ -1,4 +1,4 @@
1
1
  module Guard
2
2
  # The current gem version of Guard
3
- VERSION = '1.3.3'
3
+ VERSION = '1.4.0'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.3
4
+ version: 1.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-20 00:00:00.000000000 Z
12
+ date: 2012-09-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
@@ -126,6 +126,7 @@ files:
126
126
  - lib/guard/notifiers/notifysend.rb
127
127
  - lib/guard/notifiers/rb_notifu.rb
128
128
  - lib/guard/notifiers/terminal_notifier.rb
129
+ - lib/guard/notifiers/tmux.rb
129
130
  - lib/guard/runner.rb
130
131
  - lib/guard/templates/Guardfile
131
132
  - lib/guard/ui.rb
@@ -152,7 +153,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
152
153
  version: '0'
153
154
  segments:
154
155
  - 0
155
- hash: -172955566511919154
156
+ hash: 1379407495203457243
156
157
  required_rubygems_version: !ruby/object:Gem::Requirement
157
158
  none: false
158
159
  requirements: