guard 2.10.5 → 2.11.0

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.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/lib/guard.rb +0 -3
  3. data/lib/guard/aruba_adapter.rb +6 -6
  4. data/lib/guard/cli.rb +5 -0
  5. data/lib/guard/commander.rb +1 -1
  6. data/lib/guard/commands/all.rb +2 -2
  7. data/lib/guard/commands/notification.rb +1 -1
  8. data/lib/guard/commands/reload.rb +2 -2
  9. data/lib/guard/commands/show.rb +1 -1
  10. data/lib/guard/deprecated/evaluator.rb +3 -1
  11. data/lib/guard/deprecated/guard.rb +57 -2
  12. data/lib/guard/dsl.rb +2 -3
  13. data/lib/guard/dsl_describer.rb +8 -20
  14. data/lib/guard/guardfile/evaluator.rb +5 -5
  15. data/lib/guard/guardfile/generator.rb +3 -3
  16. data/lib/guard/internals/debugging.rb +5 -5
  17. data/lib/guard/internals/session.rb +19 -8
  18. data/lib/guard/internals/state.rb +0 -13
  19. data/lib/guard/jobs/pry_wrapper.rb +5 -5
  20. data/lib/guard/notifier.rb +43 -219
  21. data/lib/guard/plugin_util.rb +1 -1
  22. data/lib/guard/terminal.rb +3 -2
  23. data/lib/guard/ui.rb +7 -2
  24. data/lib/guard/version.rb +1 -1
  25. data/lib/guard/watcher.rb +3 -3
  26. metadata +30 -15
  27. data/lib/guard/notifier/detected.rb +0 -87
  28. data/lib/guard/notifiers/base.rb +0 -221
  29. data/lib/guard/notifiers/emacs.rb +0 -99
  30. data/lib/guard/notifiers/file_notifier.rb +0 -54
  31. data/lib/guard/notifiers/gntp.rb +0 -111
  32. data/lib/guard/notifiers/growl.rb +0 -104
  33. data/lib/guard/notifiers/libnotify.rb +0 -86
  34. data/lib/guard/notifiers/notifysend.rb +0 -110
  35. data/lib/guard/notifiers/rb_notifu.rb +0 -100
  36. data/lib/guard/notifiers/terminal_notifier.rb +0 -90
  37. data/lib/guard/notifiers/terminal_title.rb +0 -31
  38. data/lib/guard/notifiers/tmux.rb +0 -335
  39. data/lib/guard/sheller.rb +0 -143
@@ -1,111 +0,0 @@
1
- require "guard/notifiers/base"
2
-
3
- module Guard
4
- module Notifier
5
- # System notifications using the
6
- # [ruby_gntp](https://github.com/snaka/ruby_gntp) gem.
7
- #
8
- # This gem is available for OS X, Linux and Windows and sends system
9
- # notifications to the following system notification frameworks through the
10
- #
11
- # [Growl Network Transport
12
- # Protocol](http://www.growlforwindows.com/gfw/help/gntp.aspx):
13
- #
14
- # * [Growl](http://growl.info)
15
- # * [Growl for Windows](http://www.growlforwindows.com)
16
- # * [Growl for Linux](http://mattn.github.com/growl-for-linux)
17
- # * [Snarl](https://sites.google.com/site/snarlapp)
18
- #
19
- # @example Add the `ruby_gntp` gem to your `Gemfile`
20
- # group :development
21
- # gem 'ruby_gntp'
22
- # end
23
- #
24
- # @example Add the `:gntp` notifier to your `Guardfile`
25
- # notification :gntp
26
- #
27
- # @example Add the `:gntp` notifier with configuration options to your
28
- # `Guardfile` notification :gntp, sticky: true, host: '192.168.1.5',
29
- # password: 'secret'
30
- #
31
- class GNTP < Base
32
- # Default options for the ruby gtnp notifications.
33
- DEFAULTS = {
34
- sticky: false
35
- }
36
-
37
- # Default options for the ruby gtnp client.
38
- CLIENT_DEFAULTS = {
39
- host: "127.0.0.1",
40
- password: "",
41
- port: 23053
42
- }
43
-
44
- def self.supported_hosts
45
- %w(darwin linux freebsd openbsd sunos solaris mswin mingw cygwin)
46
- end
47
-
48
- def self.gem_name
49
- "ruby_gntp"
50
- end
51
-
52
- def self.available?(opts = {})
53
- super && require_gem_safely(opts)
54
- end
55
-
56
- # Shows a system notification.
57
- #
58
- # @param [String] message the notification message body
59
- # @param [Hash] opts additional notification library options
60
- # @option opts [String] type the notification type. Either 'success',
61
- # 'pending', 'failed' or 'notify'
62
- # @option opts [String] title the notification title
63
- # @option opts [String] image the path to the notification image
64
- # @option opts [String] host the hostname or IP address to which to send
65
- # a remote notification
66
- # @option opts [String] password the password used for remote
67
- # notifications
68
- # @option opts [Integer] port the port to send a remote notification
69
- # @option opts [Boolean] sticky make the notification sticky
70
- #
71
- def notify(message, opts = {})
72
- super
73
- self.class.require_gem_safely
74
-
75
- opts = DEFAULTS.merge(
76
- name: opts.delete(:type).to_s,
77
- text: message,
78
- icon: opts.delete(:image)
79
- ).merge(opts)
80
-
81
- _client(opts).notify(opts)
82
- end
83
-
84
- private
85
-
86
- def _register!(gntp_client)
87
- gntp_client.register(
88
- app_icon: images_path.join("guard.png").to_s,
89
- notifications: [
90
- { name: "notify", enabled: true },
91
- { name: "failed", enabled: true },
92
- { name: "pending", enabled: true },
93
- { name: "success", enabled: true }
94
- ]
95
- )
96
- end
97
-
98
- def _client(opts = {})
99
- @_client ||= begin
100
- gntp = ::GNTP.new(
101
- "Guard",
102
- opts.delete(:host) { CLIENT_DEFAULTS[:host] },
103
- opts.delete(:password) { CLIENT_DEFAULTS[:password] },
104
- opts.delete(:port) { CLIENT_DEFAULTS[:port] })
105
- _register!(gntp)
106
- gntp
107
- end
108
- end
109
- end
110
- end
111
- end
@@ -1,104 +0,0 @@
1
- require "guard/notifiers/base"
2
-
3
- module Guard
4
- module Notifier
5
- # System notifications using the
6
- # [growl](https://github.com/visionmedia/growl) gem.
7
- #
8
- # This gem is available for OS X and sends system notifications to
9
- # [Growl](http://growl.info) through the
10
- # [GrowlNotify](http://growl.info/downloads) executable.
11
- #
12
- # The `growlnotify` executable must be installed manually or by using
13
- # [Homebrew](http://mxcl.github.com/homebrew/).
14
- #
15
- # Sending notifications with this notifier will not show the different
16
- # Guard notifications in the Growl preferences. Use the :gntp notifier
17
- # if you want to customize each notification type in Growl.
18
- #
19
- # @example Install `growlnotify` with Homebrew
20
- # brew install growlnotify
21
- #
22
- # @example Add the `growl` gem to your `Gemfile`
23
- # group :development
24
- # gem 'growl'
25
- # end
26
- #
27
- # @example Add the `:growl` notifier to your `Guardfile`
28
- # notification :growl
29
- #
30
- # @example Add the `:growl_notify` notifier with configuration options to
31
- # your `Guardfile` notification :growl, sticky: true, host: '192.168.1.5',
32
- # password: 'secret'
33
- #
34
- class Growl < Base
35
- ERROR_INSTALL_GROWLNOTIFY = "Please install the 'growlnotify' executable'\
36
- ' (available by installing the 'growl' gem)."
37
-
38
- # Default options for the growl notifications.
39
- DEFAULTS = {
40
- sticky: false,
41
- priority: 0
42
- }
43
-
44
- def self.supported_hosts
45
- %w(darwin)
46
- end
47
-
48
- def self.available?(opts = {})
49
- super && require_gem_safely(opts) && _register!(opts)
50
- end
51
-
52
- # @private
53
- #
54
- # Detects if the Growl gem is available and if not, displays an
55
- # error message unless `opts[:silent]` is true.
56
- #
57
- # @return [Boolean] whether or not Growl is installed
58
- #
59
- def self._register!(opts)
60
- if ::Growl.installed?
61
- true
62
- else
63
- unless opts[:silent]
64
- UI.error UI::ERROR_INSTALL_GROWLNOTIFY
65
- end
66
- false
67
- end
68
- end
69
-
70
- # Shows a system notification.
71
- #
72
- # The documented options are for GrowlNotify 1.3, but the older options
73
- # are also supported. Please see `growlnotify --help`.
74
- #
75
- # Priority can be one of the following named keys: `Very Low`,
76
- # `Moderate`, `Normal`, `High`, `Emergency`. It can also be an integer
77
- # between -2 and 2.
78
- #
79
- # @param [String] message the notification message body
80
- # @param [Hash] opts additional notification library options
81
- # @option opts [String] type the notification type. Either 'success',
82
- # 'pending', 'failed' or 'notify'
83
- # @option opts [String] title the notification title
84
- # @option opts [String] image the path to the notification image
85
- # @option opts [Boolean] sticky make the notification sticky
86
- # @option opts [String, Integer] priority specify an int or named key
87
- # (default is 0)
88
- # @option opts [String] host the hostname or IP address to which to
89
- # send a remote notification
90
- # @option opts [String] password the password used for remote
91
- # notifications
92
- #
93
- def notify(message, opts = {})
94
- super
95
- opts.delete(:type)
96
- self.class.require_gem_safely
97
-
98
- opts = DEFAULTS.merge(opts).merge(name: "Guard")
99
-
100
- ::Growl.notify(message, opts)
101
- end
102
- end
103
- end
104
- end
@@ -1,86 +0,0 @@
1
- require "guard/notifiers/base"
2
-
3
- module Guard
4
- module Notifier
5
- # System notifications using the
6
- # [libnotify](https://github.com/splattael/libnotify) gem.
7
- #
8
- # This gem is available for Linux, FreeBSD, OpenBSD and Solaris and sends
9
- # system notifications to
10
- # Gnome [libnotify](http://developer.gnome.org/libnotify):
11
- #
12
- # @example Add the `libnotify` gem to your `Gemfile`
13
- # group :development
14
- # gem 'libnotify'
15
- # end
16
- #
17
- # @example Add the `:libnotify` notifier to your `Guardfile`
18
- # notification :libnotify
19
- #
20
- # @example Add the `:libnotify` notifier with configuration options to your
21
- # `Guardfile` notification :libnotify, timeout: 5, transient: true,
22
- # append: false, urgency: :critical
23
- #
24
- class Libnotify < Base
25
- # Default options for the libnotify notifications.
26
- DEFAULTS = {
27
- transient: false,
28
- append: true,
29
- timeout: 3
30
- }
31
-
32
- def self.supported_hosts
33
- %w(linux freebsd openbsd sunos solaris)
34
- end
35
-
36
- def self.available?(opts = {})
37
- super && require_gem_safely(opts)
38
- end
39
-
40
- # Shows a system notification.
41
- #
42
- # @param [String] message the notification message body
43
- # @param [Hash] opts additional notification library options
44
- # @option opts [String] type the notification type. Either 'success',
45
- # 'pending', 'failed' or 'notify'
46
- # @option opts [String] title the notification title
47
- # @option opts [String] image the path to the notification image
48
- # @option opts [Boolean] transient keep the notifications around after
49
- # display
50
- # @option opts [Boolean] append append onto existing notification
51
- # @option opts [Number, Boolean] timeout the number of seconds to display
52
- # (1.5 (s), 1000 (ms), false)
53
- #
54
- def notify(message, opts = {})
55
- super
56
- self.class.require_gem_safely
57
-
58
- opts = DEFAULTS.merge(
59
- summary: opts.delete(:title),
60
- icon_path: opts.delete(:image),
61
- body: message,
62
- urgency: _libnotify_urgency(opts.delete(:type))
63
- ).merge(opts)
64
-
65
- ::Libnotify.show(opts)
66
- end
67
-
68
- private
69
-
70
- # Convert Guards notification type to the best matching
71
- # libnotify urgency.
72
- #
73
- # @param [String] type the Guard notification type
74
- # @return [Symbol] the libnotify urgency
75
- #
76
- def _libnotify_urgency(type)
77
- case type
78
- when "failed"
79
- :normal
80
- else
81
- :low
82
- end
83
- end
84
- end
85
- end
86
- end
@@ -1,110 +0,0 @@
1
- require "guard/notifiers/base"
2
- require "guard/sheller"
3
-
4
- module Guard
5
- module Notifier
6
- # System notifications using notify-send, a binary that ships with
7
- # the libnotify-bin package on many Debian-based distributions.
8
- #
9
- # @example Add the `:notifysend` notifier to your `Guardfile`
10
- # notification :notifysend
11
- #
12
- class NotifySend < Base
13
- # Default options for the notify-send notifications.
14
- DEFAULTS = {
15
- t: 3000, # Default timeout is 3000ms
16
- h: "int:transient:1" # Automatically close the notification
17
- }
18
-
19
- # Full list of options supported by notify-send.
20
- SUPPORTED = [:u, :t, :i, :c, :h]
21
-
22
- def self.supported_hosts
23
- %w(linux freebsd openbsd sunos solaris)
24
- end
25
-
26
- def self.available?(opts = {})
27
- super && _register!(opts)
28
- end
29
-
30
- # @private
31
- #
32
- # @return [Boolean] whether or not the notify-send binary is available
33
- #
34
- def self._notifysend_binary_available?
35
- !::Guard::Sheller.stdout("which notify-send").empty?
36
- end
37
-
38
- # @private
39
- #
40
- # Detects if the notify-send binary is available and if not, displays an
41
- # error message unless `opts[:silent]` is true.
42
- #
43
- # @return [Boolean] whether or not the notify-send binary is available
44
- #
45
- def self._register!(opts)
46
- if _notifysend_binary_available?
47
- true
48
- else
49
- unless opts[:silent]
50
- ::Guard::UI.error "The :notifysend notifier runs only on Linux"\
51
- ", FreeBSD, OpenBSD and Solaris with the libnotify-bin "\
52
- "package installed."
53
- end
54
- false
55
- end
56
- end
57
-
58
- # Shows a system notification.
59
- #
60
- # @param [String] message the notification message body
61
- # @param [Hash] opts additional notification library options
62
- # @option opts [String] type the notification type. Either 'success',
63
- # 'pending', 'failed' or 'notify'
64
- # @option opts [String] title the notification title
65
- # @option opts [String] image the path to the notification image
66
- # @option opts [String] c the notification category
67
- # @option opts [Number] t the number of milliseconds to display (1000,
68
- # 3000)
69
- #
70
- def notify(message, opts = {})
71
- super
72
-
73
- command = [opts[:title], message]
74
- opts = DEFAULTS.merge(
75
- i: opts.delete(:image),
76
- u: _notifysend_urgency(opts.delete(:type))
77
- ).merge(opts)
78
-
79
- Sheller.run("notify-send", *_to_arguments(command, SUPPORTED, opts))
80
- end
81
-
82
- private
83
-
84
- # Converts Guards notification type to the best matching
85
- # notify-send urgency.
86
- #
87
- # @param [String] type the Guard notification type
88
- # @return [String] the notify-send urgency
89
- #
90
- def _notifysend_urgency(type)
91
- { failed: "normal", pending: "low" }.fetch(type, "low")
92
- end
93
-
94
- # Builds a shell command out of a command string and option hash.
95
- #
96
- # @param [String] command the command execute
97
- # @param [Array] supported list of supported option flags
98
- # @param [Hash] opts additional command options
99
- #
100
- # @return [Array<String>] the command and its options converted to a
101
- # shell command.
102
- #
103
- def _to_arguments(command, supported, opts = {})
104
- opts.inject(command) do |cmd, (flag, value)|
105
- supported.include?(flag) ? (cmd << "-#{ flag }" << value.to_s) : cmd
106
- end
107
- end
108
- end
109
- end
110
- end
@@ -1,100 +0,0 @@
1
- require "guard/notifiers/base"
2
-
3
- module Guard
4
- module Notifier
5
- # System notifications using the
6
- # [rb-notifu](https://github.com/stereobooster/rb-notifu) gem.
7
- #
8
- # This gem is available for Windows and sends system notifications to
9
- # [Notifu](http://www.paralint.com/projects/notifu/index.html):
10
- #
11
- # @example Add the `rb-notifu` gem to your `Gemfile`
12
- # group :development
13
- # gem 'rb-notifu'
14
- # end
15
- #
16
- # @example Add the `:notifu` notifier to your `Guardfile`
17
- # notification :notifu
18
- #
19
- # @example Add the `:notifu` notifier with configuration options to your
20
- # `Guardfile` notification :notifu, time: 5, nosound: true, xp: true
21
- #
22
- class Notifu < Base
23
- # Default options for the rb-notifu notifications.
24
- DEFAULTS = {
25
- time: 3,
26
- icon: false,
27
- baloon: false,
28
- nosound: false,
29
- noquiet: false,
30
- xp: false
31
- }
32
-
33
- def self.supported_hosts
34
- %w(mswin mingw)
35
- end
36
-
37
- def self.gem_name
38
- "rb-notifu"
39
- end
40
-
41
- def self.available?(opts = {})
42
- super && require_gem_safely(opts)
43
- end
44
-
45
- # Shows a system notification.
46
- #
47
- # @param [String] message the notification message body
48
- # @param [Hash] opts additional notification library options
49
- # @option opts [String] type the notification type. Either 'success',
50
- # 'pending', 'failed' or 'notify'
51
- # @option opts [String] title the notification title
52
- # @option opts [String] image the path to the notification image
53
- # @option opts [Number] time the number of seconds to display (0 for
54
- # infinit)
55
- # @option opts [Boolean] icon specify an icon to use ("parent" uses the
56
- # icon of the parent process)
57
- # @option opts [Boolean] baloon enable ballon tips in the registry (for
58
- # this user only)
59
- # @option opts [Boolean] nosound do not play a sound when the tooltip is
60
- # displayed
61
- # @option opts [Boolean] noquiet show the tooltip even if the user is in
62
- # the quiet period that follows his very first login (Windows 7 and up)
63
- # @option opts [Boolean] xp use IUserNotification interface event when
64
- # IUserNotification2 is available
65
- #
66
- def notify(message, opts = {})
67
- super
68
- self.class.require_gem_safely
69
-
70
- opts = DEFAULTS.merge(
71
- type: _notifu_type(opts.delete(:type)),
72
- message: message
73
- ).merge(opts)
74
-
75
- # The empty block is needed until
76
- # https://github.com/stereobooster/rb-notifu/pull/1 is merged
77
- ::Notifu.show(opts) {}
78
- end
79
-
80
- private
81
-
82
- # Converts Guards notification type to the best matching
83
- # Notifu type.
84
- #
85
- # @param [String] type the Guard notification type
86
- # @return [Symbol] the Notify notification type
87
- #
88
- def _notifu_type(type)
89
- case type.to_sym
90
- when :failed
91
- :error
92
- when :pending
93
- :warn
94
- else
95
- :info
96
- end
97
- end
98
- end
99
- end
100
- end