guard 1.8.3 → 2.0.0.pre
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +68 -10
- data/README.md +54 -33
- data/lib/guard.rb +133 -483
- data/lib/guard/cli.rb +78 -82
- data/lib/guard/commander.rb +121 -0
- data/lib/guard/commands/all.rb +1 -1
- data/lib/guard/commands/reload.rb +1 -1
- data/lib/guard/deprecated_methods.rb +59 -0
- data/lib/guard/deprecator.rb +107 -0
- data/lib/guard/dsl.rb +143 -329
- data/lib/guard/dsl_describer.rb +101 -57
- data/lib/guard/group.rb +27 -8
- data/lib/guard/guard.rb +25 -150
- data/lib/guard/guardfile.rb +35 -85
- data/lib/guard/guardfile/evaluator.rb +245 -0
- data/lib/guard/guardfile/generator.rb +89 -0
- data/lib/guard/interactor.rb +147 -163
- data/lib/guard/notifier.rb +83 -137
- data/lib/guard/notifiers/base.rb +220 -0
- data/lib/guard/notifiers/emacs.rb +39 -37
- data/lib/guard/notifiers/file_notifier.rb +29 -25
- data/lib/guard/notifiers/gntp.rb +68 -75
- data/lib/guard/notifiers/growl.rb +49 -52
- data/lib/guard/notifiers/growl_notify.rb +51 -56
- data/lib/guard/notifiers/libnotify.rb +41 -48
- data/lib/guard/notifiers/notifysend.rb +58 -38
- data/lib/guard/notifiers/rb_notifu.rb +54 -54
- data/lib/guard/notifiers/terminal_notifier.rb +48 -36
- data/lib/guard/notifiers/terminal_title.rb +23 -19
- data/lib/guard/notifiers/tmux.rb +110 -93
- data/lib/guard/options.rb +21 -0
- data/lib/guard/plugin.rb +66 -0
- data/lib/guard/plugin/base.rb +178 -0
- data/lib/guard/plugin/hooker.rb +123 -0
- data/lib/guard/plugin_util.rb +158 -0
- data/lib/guard/rake_task.rb +47 -0
- data/lib/guard/runner.rb +62 -82
- data/lib/guard/setuper.rb +248 -0
- data/lib/guard/ui.rb +24 -80
- data/lib/guard/ui/colors.rb +60 -0
- data/lib/guard/version.rb +1 -2
- data/lib/guard/watcher.rb +30 -30
- data/man/guard.1 +4 -4
- data/man/guard.1.html +6 -4
- metadata +25 -11
- data/lib/guard/hook.rb +0 -120
@@ -1,5 +1,4 @@
|
|
1
|
-
require '
|
2
|
-
require 'guard/ui'
|
1
|
+
require 'guard/notifiers/base'
|
3
2
|
|
4
3
|
module Guard
|
5
4
|
module Notifier
|
@@ -18,76 +17,72 @@ module Guard
|
|
18
17
|
# notification :growl_notify
|
19
18
|
#
|
20
19
|
# @example Add the `:growl_notify` notifier with configuration options to your `Guardfile`
|
21
|
-
# notification :growl_notify, :
|
20
|
+
# notification :growl_notify, sticky: true
|
22
21
|
#
|
23
|
-
|
24
|
-
extend self
|
22
|
+
class GrowlNotify < Base
|
25
23
|
|
26
|
-
# Default options for growl_notify
|
24
|
+
# Default options for the growl_notify notifications.
|
27
25
|
DEFAULTS = {
|
28
|
-
:
|
29
|
-
:
|
26
|
+
sticky: false,
|
27
|
+
priority: 0
|
30
28
|
}
|
31
29
|
|
32
|
-
|
30
|
+
def self.supported_hosts
|
31
|
+
%w[darwin]
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.available?(opts = {})
|
35
|
+
super
|
36
|
+
_register!(opts) if require_gem_safely(opts)
|
37
|
+
end
|
38
|
+
|
39
|
+
# Shows a system notification.
|
33
40
|
#
|
34
|
-
# @param [
|
35
|
-
# @param [Hash]
|
36
|
-
# @
|
41
|
+
# @param [String] message the notification message body
|
42
|
+
# @param [Hash] opts additional notification library options
|
43
|
+
# @option opts [String] type the notification type. Either 'success',
|
44
|
+
# 'pending', 'failed' or 'notify'
|
45
|
+
# @option opts [String] title the notification title
|
46
|
+
# @option opts [String] image the path to the notification image
|
47
|
+
# @option opts [Boolean] sticky if the message should stick to the screen
|
48
|
+
# @option opts [Integer] priority the importance of message from -2 (very
|
49
|
+
# low) to 2 (emergency)
|
37
50
|
#
|
38
|
-
def
|
39
|
-
|
40
|
-
|
51
|
+
def notify(message, opts = {})
|
52
|
+
self.class.require_gem_safely
|
53
|
+
normalize_standard_options!(opts)
|
41
54
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
end
|
49
|
-
end
|
55
|
+
opts = DEFAULTS.merge(
|
56
|
+
application_name: 'Guard',
|
57
|
+
with_name: opts.delete(:type).to_s,
|
58
|
+
description: message,
|
59
|
+
icon: opts.delete(:image)
|
60
|
+
).merge(opts)
|
50
61
|
|
51
|
-
|
62
|
+
::GrowlNotify.send_notification(opts)
|
63
|
+
end
|
52
64
|
|
53
|
-
|
54
|
-
|
55
|
-
|
65
|
+
# @private
|
66
|
+
#
|
67
|
+
def self._register!(options)
|
68
|
+
if ::GrowlNotify.application_name != 'Guard'
|
69
|
+
::GrowlNotify.config do |c|
|
70
|
+
c.notifications = %w(success pending failed notify)
|
71
|
+
c.default_notifications = 'notify'
|
72
|
+
c.application_name = 'Guard'
|
56
73
|
end
|
57
|
-
|
58
|
-
else
|
59
|
-
::Guard::UI.error 'The :growl_notify notifier runs only on Mac OS X.' unless silent
|
60
|
-
false
|
61
74
|
end
|
62
75
|
|
63
|
-
|
64
|
-
::Guard::UI.error "Please add \"gem 'growl_notify'\" to your Gemfile and run Guard with \"bundle exec\"." unless silent
|
65
|
-
false
|
66
|
-
end
|
67
|
-
|
68
|
-
# Show a system notification.
|
69
|
-
#
|
70
|
-
# @param [String] type the notification type. Either 'success', 'pending', 'failed' or 'notify'
|
71
|
-
# @param [String] title the notification title
|
72
|
-
# @param [String] message the notification message body
|
73
|
-
# @param [String] image the path to the notification image
|
74
|
-
# @param [Hash] options additional notification library options
|
75
|
-
# @option options [Boolean] sticky if the message should stick to the screen
|
76
|
-
# @option options [Integer] priority the importance of message from -2 (very low) to 2 (emergency)
|
77
|
-
#
|
78
|
-
def notify(type, title, message, image, options = { })
|
79
|
-
require 'growl_notify'
|
76
|
+
true
|
80
77
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
:icon => image
|
87
|
-
}))
|
78
|
+
rescue ::GrowlNotify::GrowlNotFound
|
79
|
+
unless options[:silent]
|
80
|
+
::Guard::UI.error 'Please install Growl from http://growl.info'
|
81
|
+
end
|
82
|
+
false
|
88
83
|
end
|
89
84
|
|
90
85
|
end
|
86
|
+
|
91
87
|
end
|
92
88
|
end
|
93
|
-
|
@@ -1,12 +1,13 @@
|
|
1
|
-
require '
|
2
|
-
require 'guard/ui'
|
1
|
+
require 'guard/notifiers/base'
|
3
2
|
|
4
3
|
module Guard
|
5
4
|
module Notifier
|
6
5
|
|
7
|
-
# System notifications using the
|
6
|
+
# System notifications using the
|
7
|
+
# [libnotify](https://github.com/splattael/libnotify) gem.
|
8
8
|
#
|
9
|
-
# This gem is available for Linux, FreeBSD, OpenBSD and Solaris and sends
|
9
|
+
# This gem is available for Linux, FreeBSD, OpenBSD and Solaris and sends
|
10
|
+
# system notifications to
|
10
11
|
# Gnome [libnotify](http://developer.gnome.org/libnotify):
|
11
12
|
#
|
12
13
|
# @example Add the `libnotify` gem to your `Gemfile`
|
@@ -18,61 +19,52 @@ module Guard
|
|
18
19
|
# notification :libnotify
|
19
20
|
#
|
20
21
|
# @example Add the `:libnotify` notifier with configuration options to your `Guardfile`
|
21
|
-
# notification :libnotify, :
|
22
|
+
# notification :libnotify, timeout: 5, transient: true, append: false, urgency: :critical
|
22
23
|
#
|
23
|
-
|
24
|
-
extend self
|
24
|
+
class Libnotify < Base
|
25
25
|
|
26
|
-
# Default options for libnotify
|
26
|
+
# Default options for the libnotify notifications.
|
27
27
|
DEFAULTS = {
|
28
|
-
:
|
29
|
-
:
|
30
|
-
:
|
28
|
+
transient: false,
|
29
|
+
append: true,
|
30
|
+
timeout: 3
|
31
31
|
}
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
# @param [Hash] options notifier options
|
37
|
-
# @return [Boolean] the availability status
|
38
|
-
#
|
39
|
-
def available?(silent = false, options = {})
|
40
|
-
if RbConfig::CONFIG['host_os'] =~ /linux|freebsd|openbsd|sunos|solaris/
|
41
|
-
require 'libnotify'
|
42
|
-
|
43
|
-
true
|
44
|
-
|
45
|
-
else
|
46
|
-
::Guard::UI.error 'The :libnotify notifier runs only on Linux, FreeBSD, OpenBSD and Solaris.' unless silent
|
47
|
-
false
|
48
|
-
end
|
33
|
+
def self.supported_hosts
|
34
|
+
%w[linux freebsd openbsd sunos solaris]
|
35
|
+
end
|
49
36
|
|
50
|
-
|
51
|
-
|
52
|
-
|
37
|
+
def self.available?(opts = {})
|
38
|
+
super
|
39
|
+
require_gem_safely(opts)
|
53
40
|
end
|
54
41
|
|
55
|
-
#
|
42
|
+
# Shows a system notification.
|
56
43
|
#
|
57
|
-
# @param [String] type the notification type. Either 'success', 'pending', 'failed' or 'notify'
|
58
|
-
# @param [String] title the notification title
|
59
44
|
# @param [String] message the notification message body
|
60
|
-
# @param [
|
61
|
-
# @
|
62
|
-
#
|
63
|
-
# @option
|
64
|
-
# @option
|
45
|
+
# @param [Hash] opts additional notification library options
|
46
|
+
# @option opts [String] type the notification type. Either 'success',
|
47
|
+
# 'pending', 'failed' or 'notify'
|
48
|
+
# @option opts [String] title the notification title
|
49
|
+
# @option opts [String] image the path to the notification image
|
50
|
+
# @option opts [Boolean] transient keep the notifications around after
|
51
|
+
# display
|
52
|
+
# @option opts [Boolean] append append onto existing notification
|
53
|
+
# @option opts [Number, Boolean] timeout the number of seconds to display
|
54
|
+
# (1.5 (s), 1000 (ms), false)
|
65
55
|
#
|
66
|
-
def notify(
|
67
|
-
|
56
|
+
def notify(message, opts = {})
|
57
|
+
self.class.require_gem_safely
|
58
|
+
normalize_standard_options!(opts)
|
68
59
|
|
69
|
-
|
70
|
-
:
|
71
|
-
:
|
72
|
-
:
|
73
|
-
|
74
|
-
|
75
|
-
|
60
|
+
opts = DEFAULTS.merge(
|
61
|
+
summary: opts.delete(:title),
|
62
|
+
icon_path: opts.delete(:image),
|
63
|
+
body: message,
|
64
|
+
urgency: _libnotify_urgency(opts.delete(:type))
|
65
|
+
).merge(opts)
|
66
|
+
|
67
|
+
::Libnotify.show(opts)
|
76
68
|
end
|
77
69
|
|
78
70
|
private
|
@@ -83,7 +75,7 @@ module Guard
|
|
83
75
|
# @param [String] type the Guard notification type
|
84
76
|
# @return [Symbol] the libnotify urgency
|
85
77
|
#
|
86
|
-
def
|
78
|
+
def _libnotify_urgency(type)
|
87
79
|
case type
|
88
80
|
when 'failed'
|
89
81
|
:normal
|
@@ -93,5 +85,6 @@ module Guard
|
|
93
85
|
end
|
94
86
|
|
95
87
|
end
|
88
|
+
|
96
89
|
end
|
97
90
|
end
|
@@ -1,5 +1,4 @@
|
|
1
|
-
require '
|
2
|
-
require 'guard/ui'
|
1
|
+
require 'guard/notifiers/base'
|
3
2
|
|
4
3
|
module Guard
|
5
4
|
module Notifier
|
@@ -10,76 +9,97 @@ module Guard
|
|
10
9
|
# @example Add the `:notifysend` notifier to your `Guardfile`
|
11
10
|
# notification :notifysend
|
12
11
|
#
|
13
|
-
|
14
|
-
extend self
|
12
|
+
class NotifySend < Base
|
15
13
|
|
16
|
-
# Default options for the notify-send
|
14
|
+
# Default options for the notify-send notifications.
|
17
15
|
DEFAULTS = {
|
18
|
-
:
|
19
|
-
:
|
16
|
+
t: 3000, # Default timeout is 3000ms
|
17
|
+
h: 'int:transient:1' # Automatically close the notification
|
20
18
|
}
|
21
19
|
|
22
|
-
# Full list of options supported by notify-send
|
20
|
+
# Full list of options supported by notify-send.
|
23
21
|
SUPPORTED = [:u, :t, :i, :c, :h]
|
24
22
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
if (RbConfig::CONFIG['host_os'] =~ /linux|freebsd|openbsd|sunos|solaris/) and (not `which notify-send`.empty?)
|
33
|
-
true
|
34
|
-
else
|
35
|
-
::Guard::UI.error 'The :notifysend notifier runs only on Linux, FreeBSD, OpenBSD and Solaris with the libnotify-bin package installed.' unless silent
|
36
|
-
false
|
37
|
-
end
|
23
|
+
def self.supported_hosts
|
24
|
+
%w[linux freebsd openbsd sunos solaris]
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.available?(opts = {})
|
28
|
+
super
|
29
|
+
_register!(opts)
|
38
30
|
end
|
39
31
|
|
40
|
-
#
|
32
|
+
# Shows a system notification.
|
41
33
|
#
|
42
|
-
# @param [String] type the notification type. Either 'success', 'pending', 'failed' or 'notify'
|
43
|
-
# @param [String] title the notification title
|
44
34
|
# @param [String] message the notification message body
|
45
|
-
# @param [
|
46
|
-
# @
|
47
|
-
#
|
48
|
-
# @option
|
35
|
+
# @param [Hash] opts additional notification library options
|
36
|
+
# @option opts [String] type the notification type. Either 'success',
|
37
|
+
# 'pending', 'failed' or 'notify'
|
38
|
+
# @option opts [String] title the notification title
|
39
|
+
# @option opts [String] image the path to the notification image
|
40
|
+
# @option opts [String] c the notification category
|
41
|
+
# @option opts [Number] t the number of milliseconds to display (1000,
|
42
|
+
# 3000)
|
49
43
|
#
|
50
|
-
def notify(
|
44
|
+
def notify(message, opts = {})
|
45
|
+
normalize_standard_options!(opts)
|
46
|
+
|
51
47
|
command = [title, message]
|
52
|
-
|
53
|
-
:
|
54
|
-
|
55
|
-
|
56
|
-
|
48
|
+
opts = DEFAULTS.merge(
|
49
|
+
i: opts.delete(:image),
|
50
|
+
u: _notifysend_urgency(opts.delete(:type))
|
51
|
+
).merge(opts)
|
52
|
+
|
53
|
+
system('notify-send', *_to_arguments(command, SUPPORTED, opts))
|
57
54
|
end
|
58
55
|
|
59
56
|
private
|
60
57
|
|
61
|
-
#
|
58
|
+
# Converts Guards notification type to the best matching
|
62
59
|
# notify-send urgency.
|
63
60
|
#
|
64
61
|
# @param [String] type the Guard notification type
|
65
62
|
# @return [String] the notify-send urgency
|
66
63
|
#
|
67
|
-
def
|
64
|
+
def _notifysend_urgency(type)
|
68
65
|
{ 'failed' => 'normal', 'pending' => 'low' }.fetch(type, 'low')
|
69
66
|
end
|
70
67
|
|
71
|
-
#
|
68
|
+
# Builds a shell command out of a command string and option hash.
|
72
69
|
#
|
73
70
|
# @param [String] command the command execute
|
74
71
|
# @param [Array] supported list of supported option flags
|
75
72
|
# @param [Hash] options additional command options
|
76
73
|
# @return [Array<String>] the command and its options converted to a shell command.
|
77
74
|
#
|
78
|
-
def
|
75
|
+
def _to_arguments(command, supported, options = {})
|
79
76
|
options.reduce(command) do |cmd, (flag, value)|
|
80
77
|
supported.include?(flag) ? (cmd << "-#{ flag }" << value.to_s) : cmd
|
81
78
|
end
|
82
79
|
end
|
80
|
+
|
81
|
+
# @private
|
82
|
+
#
|
83
|
+
# @return [Boolean] whether or not the notify-send binary is available
|
84
|
+
#
|
85
|
+
def self._notifysend_binary_available?
|
86
|
+
!`which notify-send`.empty?
|
87
|
+
end
|
88
|
+
|
89
|
+
# @private
|
90
|
+
#
|
91
|
+
def self._register!(options)
|
92
|
+
unless _notifysend_binary_available?
|
93
|
+
unless options[:silent]
|
94
|
+
::Guard::UI.error 'The :notifysend notifier runs only on Linux, FreeBSD, OpenBSD and Solaris with the libnotify-bin package installed.'
|
95
|
+
end
|
96
|
+
false
|
97
|
+
end
|
98
|
+
|
99
|
+
true
|
100
|
+
end
|
101
|
+
|
83
102
|
end
|
103
|
+
|
84
104
|
end
|
85
105
|
end
|
@@ -1,10 +1,10 @@
|
|
1
|
-
require '
|
2
|
-
require 'guard/ui'
|
1
|
+
require 'guard/notifiers/base'
|
3
2
|
|
4
3
|
module Guard
|
5
4
|
module Notifier
|
6
5
|
|
7
|
-
# System notifications using the
|
6
|
+
# System notifications using the
|
7
|
+
# [rb-notifu](https://github.com/stereobooster/rb-notifu) gem.
|
8
8
|
#
|
9
9
|
# This gem is available for Windows and sends system notifications to
|
10
10
|
# [Notifu](http://www.paralint.com/projects/notifu/index.html):
|
@@ -18,80 +18,80 @@ module Guard
|
|
18
18
|
# notification :notifu
|
19
19
|
#
|
20
20
|
# @example Add the `:notifu` notifier with configuration options to your `Guardfile`
|
21
|
-
# notification :notifu, :
|
21
|
+
# notification :notifu, time: 5, nosound: true, xp: true
|
22
22
|
#
|
23
|
-
|
24
|
-
extend self
|
23
|
+
class Notifu < Base
|
25
24
|
|
26
|
-
# Default options for rb-notifu
|
25
|
+
# Default options for the rb-notifu notifications.
|
27
26
|
DEFAULTS = {
|
28
|
-
:
|
29
|
-
:
|
30
|
-
:
|
31
|
-
:
|
32
|
-
:
|
33
|
-
:
|
27
|
+
time: 3,
|
28
|
+
icon: false,
|
29
|
+
baloon: false,
|
30
|
+
nosound: false,
|
31
|
+
noquiet: false,
|
32
|
+
xp: false
|
34
33
|
}
|
35
34
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
# @param [Hash] options notifier options
|
40
|
-
# @return [Boolean] the availability status
|
41
|
-
#
|
42
|
-
def available?(silent = false, options = {})
|
43
|
-
if RbConfig::CONFIG['host_os'] =~ /mswin|mingw/
|
44
|
-
require 'rb-notifu'
|
45
|
-
|
46
|
-
true
|
35
|
+
def self.supported_hosts
|
36
|
+
%w[mswin mingw]
|
37
|
+
end
|
47
38
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
end
|
39
|
+
def self.gem_name
|
40
|
+
'rb-notifu'
|
41
|
+
end
|
52
42
|
|
53
|
-
|
54
|
-
|
55
|
-
|
43
|
+
def self.available?(opts = {})
|
44
|
+
super
|
45
|
+
require_gem_safely(opts)
|
56
46
|
end
|
57
47
|
|
58
|
-
#
|
48
|
+
# Shows a system notification.
|
59
49
|
#
|
60
|
-
# @param [String] type the notification type. Either 'success', 'pending', 'failed' or 'notify'
|
61
|
-
# @param [String] title the notification title
|
62
50
|
# @param [String] message the notification message body
|
63
|
-
# @param [
|
64
|
-
# @
|
65
|
-
#
|
66
|
-
# @option
|
67
|
-
# @option
|
68
|
-
# @option
|
69
|
-
#
|
70
|
-
# @option
|
51
|
+
# @param [Hash] opts additional notification library options
|
52
|
+
# @option opts [String] type the notification type. Either 'success',
|
53
|
+
# 'pending', 'failed' or 'notify'
|
54
|
+
# @option opts [String] title the notification title
|
55
|
+
# @option opts [String] image the path to the notification image
|
56
|
+
# @option opts [Number] time the number of seconds to display (0 for
|
57
|
+
# infinit)
|
58
|
+
# @option opts [Boolean] icon specify an icon to use ("parent" uses the
|
59
|
+
# icon of the parent process)
|
60
|
+
# @option opts [Boolean] baloon enable ballon tips in the registry (for
|
61
|
+
# this user only)
|
62
|
+
# @option opts [Boolean] nosound do not play a sound when the tooltip is
|
63
|
+
# displayed
|
64
|
+
# @option opts [Boolean] noquiet show the tooltip even if the user is in
|
65
|
+
# the quiet period that follows his very first login (Windows 7 and up)
|
66
|
+
# @option opts [Boolean] xp use IUserNotification interface event when
|
67
|
+
# IUserNotification2 is available
|
71
68
|
#
|
72
|
-
def notify(
|
73
|
-
|
69
|
+
def notify(message, opts = {})
|
70
|
+
self.class.require_gem_safely
|
71
|
+
normalize_standard_options!(opts)
|
72
|
+
|
73
|
+
opts = DEFAULTS.merge(
|
74
|
+
type: _notifu_type(opts.delete(:type)),
|
75
|
+
message: message
|
76
|
+
).merge(opts)
|
74
77
|
|
75
|
-
|
76
|
-
|
77
|
-
:title => title,
|
78
|
-
:message => message
|
79
|
-
}))
|
78
|
+
# The empty block is needed until https://github.com/stereobooster/rb-notifu/pull/1 is merged
|
79
|
+
::Notifu.show(opts) {}
|
80
80
|
end
|
81
81
|
|
82
82
|
private
|
83
83
|
|
84
|
-
#
|
84
|
+
# Converts Guards notification type to the best matching
|
85
85
|
# Notifu type.
|
86
86
|
#
|
87
87
|
# @param [String] type the Guard notification type
|
88
88
|
# @return [Symbol] the Notify notification type
|
89
89
|
#
|
90
|
-
def
|
91
|
-
case type
|
92
|
-
when
|
90
|
+
def _notifu_type(type)
|
91
|
+
case type.to_sym
|
92
|
+
when :failed
|
93
93
|
:error
|
94
|
-
when
|
94
|
+
when :pending
|
95
95
|
:warn
|
96
96
|
else
|
97
97
|
:info
|