guard 2.6.1 → 2.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +73 -58
  3. data/bin/guard +2 -2
  4. data/lib/guard.rb +64 -59
  5. data/lib/guard/cli.rb +66 -60
  6. data/lib/guard/cli.rb.orig +215 -0
  7. data/lib/guard/commander.rb +45 -69
  8. data/lib/guard/commands/all.rb +21 -19
  9. data/lib/guard/commands/change.rb +17 -22
  10. data/lib/guard/commands/notification.rb +15 -16
  11. data/lib/guard/commands/pause.rb +14 -15
  12. data/lib/guard/commands/reload.rb +19 -20
  13. data/lib/guard/commands/scope.rb +23 -19
  14. data/lib/guard/commands/show.rb +13 -16
  15. data/lib/guard/deprecated_methods.rb +6 -10
  16. data/lib/guard/deprecator.rb +52 -37
  17. data/lib/guard/dsl.rb +55 -33
  18. data/lib/guard/dsl_describer.rb +83 -31
  19. data/lib/guard/dsl_describer.rb.orig +184 -0
  20. data/lib/guard/group.rb +7 -6
  21. data/lib/guard/guard.rb +4 -4
  22. data/lib/guard/guard.rb.orig +42 -0
  23. data/lib/guard/guardfile.rb +12 -13
  24. data/lib/guard/guardfile/evaluator.rb +77 -55
  25. data/lib/guard/guardfile/evaluator.rb.orig +275 -0
  26. data/lib/guard/guardfile/generator.rb +25 -20
  27. data/lib/guard/interactor.rb +52 -293
  28. data/lib/guard/interactor.rb.orig +85 -0
  29. data/lib/guard/jobs/base.rb +21 -0
  30. data/lib/guard/jobs/pry_wrapper.rb +290 -0
  31. data/lib/guard/jobs/pry_wrapper.rb.orig +293 -0
  32. data/lib/guard/jobs/sleep.rb +25 -0
  33. data/lib/guard/notifier.rb +42 -39
  34. data/lib/guard/notifiers/base.rb +25 -24
  35. data/lib/guard/notifiers/emacs.rb +30 -24
  36. data/lib/guard/notifiers/file_notifier.rb +3 -7
  37. data/lib/guard/notifiers/gntp.rb +22 -22
  38. data/lib/guard/notifiers/growl.rb +16 -15
  39. data/lib/guard/notifiers/libnotify.rb +7 -10
  40. data/lib/guard/notifiers/notifysend.rb +15 -14
  41. data/lib/guard/notifiers/rb_notifu.rb +8 -10
  42. data/lib/guard/notifiers/terminal_notifier.rb +15 -11
  43. data/lib/guard/notifiers/terminal_title.rb +4 -8
  44. data/lib/guard/notifiers/tmux.rb +104 -71
  45. data/lib/guard/options.rb +1 -5
  46. data/lib/guard/plugin.rb +1 -3
  47. data/lib/guard/plugin/base.rb +12 -9
  48. data/lib/guard/plugin/hooker.rb +1 -5
  49. data/lib/guard/plugin_util.rb +46 -25
  50. data/lib/guard/plugin_util.rb.orig +178 -0
  51. data/lib/guard/rake_task.rb +4 -7
  52. data/lib/guard/reevaluator.rb +13 -0
  53. data/lib/guard/runner.rb +50 -78
  54. data/lib/guard/runner.rb.orig +200 -0
  55. data/lib/guard/setuper.rb +199 -130
  56. data/lib/guard/setuper.rb.orig +348 -0
  57. data/lib/guard/sheller.rb +107 -0
  58. data/lib/guard/tags +367 -0
  59. data/lib/guard/ui.rb +50 -38
  60. data/lib/guard/ui.rb.orig +254 -0
  61. data/lib/guard/ui/colors.rb +17 -21
  62. data/lib/guard/version.rb +1 -1
  63. data/lib/guard/version.rb.orig +3 -0
  64. data/lib/guard/watcher.rb +49 -62
  65. metadata +21 -4
  66. data/lib/guard/notifiers/growl_notify.rb +0 -93
@@ -1,14 +1,15 @@
1
- require 'guard/notifiers/base'
1
+ require "guard/notifiers/base"
2
2
 
3
3
  module Guard
4
4
  module Notifier
5
-
6
5
  # System notifications using the
7
6
  # [ruby_gntp](https://github.com/snaka/ruby_gntp) gem.
8
7
  #
9
8
  # This gem is available for OS X, Linux and Windows and sends system
10
9
  # notifications to the following system notification frameworks through the
11
- # [Growl Network Transport Protocol](http://www.growlforwindows.com/gfw/help/gntp.aspx):
10
+ #
11
+ # [Growl Network Transport
12
+ # Protocol](http://www.growlforwindows.com/gfw/help/gntp.aspx):
12
13
  #
13
14
  # * [Growl](http://growl.info)
14
15
  # * [Growl for Windows](http://www.growlforwindows.com)
@@ -23,11 +24,11 @@ module Guard
23
24
  # @example Add the `:gntp` notifier to your `Guardfile`
24
25
  # notification :gntp
25
26
  #
26
- # @example Add the `:gntp` notifier with configuration options to your `Guardfile`
27
- # notification :gntp, sticky: true, host: '192.168.1.5', password: 'secret'
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'
28
30
  #
29
31
  class GNTP < Base
30
-
31
32
  # Default options for the ruby gtnp notifications.
32
33
  DEFAULTS = {
33
34
  sticky: false
@@ -35,21 +36,21 @@ module Guard
35
36
 
36
37
  # Default options for the ruby gtnp client.
37
38
  CLIENT_DEFAULTS = {
38
- host: '127.0.0.1',
39
- password: '',
39
+ host: "127.0.0.1",
40
+ password: "",
40
41
  port: 23053
41
42
  }
42
43
 
43
44
  def self.supported_hosts
44
- %w[darwin linux freebsd openbsd sunos solaris mswin mingw cygwin]
45
+ %w(darwin linux freebsd openbsd sunos solaris mswin mingw cygwin)
45
46
  end
46
47
 
47
48
  def self.gem_name
48
- 'ruby_gntp'
49
+ "ruby_gntp"
49
50
  end
50
51
 
51
52
  def self.available?(opts = {})
52
- super and require_gem_safely(opts)
53
+ super && require_gem_safely(opts)
53
54
  end
54
55
 
55
56
  # Shows a system notification.
@@ -84,28 +85,27 @@ module Guard
84
85
 
85
86
  def _register!(gntp_client)
86
87
  gntp_client.register(
87
- app_icon: images_path.join('guard.png').to_s,
88
+ app_icon: images_path.join("guard.png").to_s,
88
89
  notifications: [
89
- { name: 'notify', enabled: true },
90
- { name: 'failed', enabled: true },
91
- { name: 'pending', enabled: true },
92
- { name: 'success', enabled: true }
90
+ { name: "notify", enabled: true },
91
+ { name: "failed", enabled: true },
92
+ { name: "pending", enabled: true },
93
+ { name: "success", enabled: true }
93
94
  ]
94
95
  )
95
96
  end
96
97
 
97
98
  def _client(opts = {})
98
99
  @_client ||= begin
99
- gntp = ::GNTP.new('Guard',
100
- opts.delete(:host) { CLIENT_DEFAULTS[:host] },
101
- opts.delete(:password) { CLIENT_DEFAULTS[:password] },
102
- opts.delete(:port) { CLIENT_DEFAULTS[:port] })
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] })
103
105
  _register!(gntp)
104
106
  gntp
105
107
  end
106
108
  end
107
-
108
109
  end
109
-
110
110
  end
111
111
  end
@@ -1,20 +1,20 @@
1
- require 'guard/notifiers/base'
1
+ require "guard/notifiers/base"
2
2
 
3
3
  module Guard
4
4
  module Notifier
5
-
6
- # System notifications using the [growl](https://github.com/visionmedia/growl) gem.
5
+ # System notifications using the
6
+ # [growl](https://github.com/visionmedia/growl) gem.
7
7
  #
8
8
  # This gem is available for OS X and sends system notifications to
9
- # [Growl](http://growl.info) through the [GrowlNotify](http://growl.info/downloads)
10
- # executable.
9
+ # [Growl](http://growl.info) through the
10
+ # [GrowlNotify](http://growl.info/downloads) executable.
11
11
  #
12
12
  # The `growlnotify` executable must be installed manually or by using
13
13
  # [Homebrew](http://mxcl.github.com/homebrew/).
14
14
  #
15
15
  # Sending notifications with this notifier will not show the different
16
- # Guard notifications in the Growl preferences. Use the :gntp or :growl_notify
17
- # notifiers if you want to customize each notification type in Growl.
16
+ # Guard notifications in the Growl preferences. Use the :gntp notifier
17
+ # if you want to customize each notification type in Growl.
18
18
  #
19
19
  # @example Install `growlnotify` with Homebrew
20
20
  # brew install growlnotify
@@ -27,10 +27,13 @@ module Guard
27
27
  # @example Add the `:growl` notifier to your `Guardfile`
28
28
  # notification :growl
29
29
  #
30
- # @example Add the `:growl_notify` notifier with configuration options to your `Guardfile`
31
- # notification :growl, sticky: true, host: '192.168.1.5', password: 'secret'
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'
32
33
  #
33
34
  class Growl < Base
35
+ ERROR_INSTALL_GROWLNOTIFY = "Please install the 'growlnotify' executable'\
36
+ ' (available by installing the 'growl' gem)."
34
37
 
35
38
  # Default options for the growl notifications.
36
39
  DEFAULTS = {
@@ -39,11 +42,11 @@ module Guard
39
42
  }
40
43
 
41
44
  def self.supported_hosts
42
- %w[darwin]
45
+ %w(darwin)
43
46
  end
44
47
 
45
48
  def self.available?(opts = {})
46
- super and require_gem_safely(opts) and _register!(opts)
49
+ super && require_gem_safely(opts) && _register!(opts)
47
50
  end
48
51
 
49
52
  # @private
@@ -58,7 +61,7 @@ module Guard
58
61
  true
59
62
  else
60
63
  unless opts[:silent]
61
- ::Guard::UI.error "Please install the 'growlnotify' executable (available by installing the 'growl' gem)."
64
+ UI.error UI::ERROR_INSTALL_GROWLNOTIFY
62
65
  end
63
66
  false
64
67
  end
@@ -92,12 +95,10 @@ module Guard
92
95
  opts.delete(:type)
93
96
  self.class.require_gem_safely
94
97
 
95
- opts = DEFAULTS.merge(opts).merge(name: 'Guard')
98
+ opts = DEFAULTS.merge(opts).merge(name: "Guard")
96
99
 
97
100
  ::Growl.notify(message, opts)
98
101
  end
99
-
100
102
  end
101
-
102
103
  end
103
104
  end
@@ -1,8 +1,7 @@
1
- require 'guard/notifiers/base'
1
+ require "guard/notifiers/base"
2
2
 
3
3
  module Guard
4
4
  module Notifier
5
-
6
5
  # System notifications using the
7
6
  # [libnotify](https://github.com/splattael/libnotify) gem.
8
7
  #
@@ -18,11 +17,11 @@ module Guard
18
17
  # @example Add the `:libnotify` notifier to your `Guardfile`
19
18
  # notification :libnotify
20
19
  #
21
- # @example Add the `:libnotify` notifier with configuration options to your `Guardfile`
22
- # notification :libnotify, timeout: 5, transient: true, append: false, urgency: :critical
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
23
  #
24
24
  class Libnotify < Base
25
-
26
25
  # Default options for the libnotify notifications.
27
26
  DEFAULTS = {
28
27
  transient: false,
@@ -31,11 +30,11 @@ module Guard
31
30
  }
32
31
 
33
32
  def self.supported_hosts
34
- %w[linux freebsd openbsd sunos solaris]
33
+ %w(linux freebsd openbsd sunos solaris)
35
34
  end
36
35
 
37
36
  def self.available?(opts = {})
38
- super and require_gem_safely(opts)
37
+ super && require_gem_safely(opts)
39
38
  end
40
39
 
41
40
  # Shows a system notification.
@@ -76,14 +75,12 @@ module Guard
76
75
  #
77
76
  def _libnotify_urgency(type)
78
77
  case type
79
- when 'failed'
78
+ when "failed"
80
79
  :normal
81
80
  else
82
81
  :low
83
82
  end
84
83
  end
85
-
86
84
  end
87
-
88
85
  end
89
86
  end
@@ -1,8 +1,8 @@
1
- require 'guard/notifiers/base'
1
+ require "guard/notifiers/base"
2
+ require "guard/sheller"
2
3
 
3
4
  module Guard
4
5
  module Notifier
5
-
6
6
  # System notifications using notify-send, a binary that ships with
7
7
  # the libnotify-bin package on many Debian-based distributions.
8
8
  #
@@ -10,22 +10,21 @@ module Guard
10
10
  # notification :notifysend
11
11
  #
12
12
  class NotifySend < Base
13
-
14
13
  # Default options for the notify-send notifications.
15
14
  DEFAULTS = {
16
15
  t: 3000, # Default timeout is 3000ms
17
- h: 'int:transient:1' # Automatically close the notification
16
+ h: "int:transient:1" # Automatically close the notification
18
17
  }
19
18
 
20
19
  # Full list of options supported by notify-send.
21
20
  SUPPORTED = [:u, :t, :i, :c, :h]
22
21
 
23
22
  def self.supported_hosts
24
- %w[linux freebsd openbsd sunos solaris]
23
+ %w(linux freebsd openbsd sunos solaris)
25
24
  end
26
25
 
27
26
  def self.available?(opts = {})
28
- super and _register!(opts)
27
+ super && _register!(opts)
29
28
  end
30
29
 
31
30
  # @private
@@ -33,7 +32,7 @@ module Guard
33
32
  # @return [Boolean] whether or not the notify-send binary is available
34
33
  #
35
34
  def self._notifysend_binary_available?
36
- !`which notify-send`.empty?
35
+ !::Guard::Sheller.stdout("which notify-send").empty?
37
36
  end
38
37
 
39
38
  # @private
@@ -48,7 +47,9 @@ module Guard
48
47
  true
49
48
  else
50
49
  unless opts[:silent]
51
- ::Guard::UI.error 'The :notifysend notifier runs only on Linux, FreeBSD, OpenBSD and Solaris with the libnotify-bin package installed.'
50
+ ::Guard::UI.error "The :notifysend notifier runs only on Linux"\
51
+ ", FreeBSD, OpenBSD and Solaris with the libnotify-bin "\
52
+ "package installed."
52
53
  end
53
54
  false
54
55
  end
@@ -75,7 +76,7 @@ module Guard
75
76
  u: _notifysend_urgency(opts.delete(:type))
76
77
  ).merge(opts)
77
78
 
78
- system('notify-send', *_to_arguments(command, SUPPORTED, opts))
79
+ Sheller.run("notify-send", *_to_arguments(command, SUPPORTED, opts))
79
80
  end
80
81
 
81
82
  private
@@ -87,7 +88,7 @@ module Guard
87
88
  # @return [String] the notify-send urgency
88
89
  #
89
90
  def _notifysend_urgency(type)
90
- { failed: 'normal', pending: 'low' }.fetch(type, 'low')
91
+ { failed: "normal", pending: "low" }.fetch(type, "low")
91
92
  end
92
93
 
93
94
  # Builds a shell command out of a command string and option hash.
@@ -95,15 +96,15 @@ module Guard
95
96
  # @param [String] command the command execute
96
97
  # @param [Array] supported list of supported option flags
97
98
  # @param [Hash] opts additional command options
98
- # @return [Array<String>] the command and its options converted to a shell command.
99
+ #
100
+ # @return [Array<String>] the command and its options converted to a
101
+ # shell command.
99
102
  #
100
103
  def _to_arguments(command, supported, opts = {})
101
- opts.reduce(command) do |cmd, (flag, value)|
104
+ opts.inject(command) do |cmd, (flag, value)|
102
105
  supported.include?(flag) ? (cmd << "-#{ flag }" << value.to_s) : cmd
103
106
  end
104
107
  end
105
-
106
108
  end
107
-
108
109
  end
109
110
  end
@@ -1,8 +1,7 @@
1
- require 'guard/notifiers/base'
1
+ require "guard/notifiers/base"
2
2
 
3
3
  module Guard
4
4
  module Notifier
5
-
6
5
  # System notifications using the
7
6
  # [rb-notifu](https://github.com/stereobooster/rb-notifu) gem.
8
7
  #
@@ -17,11 +16,10 @@ module Guard
17
16
  # @example Add the `:notifu` notifier to your `Guardfile`
18
17
  # notification :notifu
19
18
  #
20
- # @example Add the `:notifu` notifier with configuration options to your `Guardfile`
21
- # notification :notifu, time: 5, nosound: true, xp: true
19
+ # @example Add the `:notifu` notifier with configuration options to your
20
+ # `Guardfile` notification :notifu, time: 5, nosound: true, xp: true
22
21
  #
23
22
  class Notifu < Base
24
-
25
23
  # Default options for the rb-notifu notifications.
26
24
  DEFAULTS = {
27
25
  time: 3,
@@ -33,15 +31,15 @@ module Guard
33
31
  }
34
32
 
35
33
  def self.supported_hosts
36
- %w[mswin mingw]
34
+ %w(mswin mingw)
37
35
  end
38
36
 
39
37
  def self.gem_name
40
- 'rb-notifu'
38
+ "rb-notifu"
41
39
  end
42
40
 
43
41
  def self.available?(opts = {})
44
- super and require_gem_safely(opts)
42
+ super && require_gem_safely(opts)
45
43
  end
46
44
 
47
45
  # Shows a system notification.
@@ -74,7 +72,8 @@ module Guard
74
72
  message: message
75
73
  ).merge(opts)
76
74
 
77
- # The empty block is needed until https://github.com/stereobooster/rb-notifu/pull/1 is merged
75
+ # The empty block is needed until
76
+ # https://github.com/stereobooster/rb-notifu/pull/1 is merged
78
77
  ::Notifu.show(opts) {}
79
78
  end
80
79
 
@@ -96,7 +95,6 @@ module Guard
96
95
  :info
97
96
  end
98
97
  end
99
-
100
98
  end
101
99
  end
102
100
  end
@@ -1,10 +1,11 @@
1
- require 'guard/notifiers/base'
1
+ require "guard/notifiers/base"
2
2
 
3
3
  module Guard
4
4
  module Notifier
5
-
6
5
  # System notifications using the
7
- # [terminal-notifier-guard](https://github.com/Springest/terminal-notifier-guard)
6
+ #
7
+ # [terminal-notifier](https://github.com/Springest/terminal-notifier-guard)
8
+ #
8
9
  # gem.
9
10
  #
10
11
  # This gem is available for OS X 10.8 Mountain Lion and sends notifications
@@ -25,17 +26,19 @@ module Guard
25
26
  # notification :terminal_notifier, activate: "com.googlecode.iterm2"
26
27
  #
27
28
  class TerminalNotifier < Base
29
+ ERROR_TERMINAL_NOTIFIER_ONLY_OSX10 = "The :terminal_notifier only runs"\
30
+ " on Mac OS X 10.8 and later."
28
31
 
29
32
  def self.supported_hosts
30
- %w[darwin]
33
+ %w(darwin)
31
34
  end
32
35
 
33
36
  def self.gem_name
34
- 'terminal-notifier-guard'
37
+ "terminal-notifier-guard"
35
38
  end
36
39
 
37
40
  def self.available?(opts = {})
38
- super and require_gem_safely(opts) and _register!(opts)
41
+ super && require_gem_safely(opts) && _register!(opts)
39
42
  end
40
43
 
41
44
  # Shows a system notification.
@@ -57,7 +60,9 @@ module Guard
57
60
  self.class.require_gem_safely
58
61
 
59
62
  opts.delete(:image)
60
- opts[:title] = title || [opts.delete(:app_name) { 'Guard' }, opts[:type].downcase.capitalize].join(' ')
63
+ opts[:title] = title || [
64
+ opts.delete(:app_name) { "Guard" }, opts[:type].downcase.capitalize
65
+ ].join(" ")
61
66
 
62
67
  ::TerminalNotifier::Guard.execute(false, opts.merge(message: message))
63
68
  end
@@ -67,20 +72,19 @@ module Guard
67
72
  # Detects if the terminal-notifier-guard gem is available and if not,
68
73
  # displays an error message unless `opts[:silent]` is true.
69
74
  #
70
- # @return [Boolean] whether or not the terminal-notifier-guard gem is available
75
+ # @return [Boolean] whether or not the terminal-notifier-guard gem is
76
+ # available
71
77
  #
72
78
  def self._register!(opts)
73
79
  if ::TerminalNotifier::Guard.available?
74
80
  true
75
81
  else
76
82
  unless opts[:silent]
77
- ::Guard::UI.error 'The :terminal_notifier only runs on Mac OS X 10.8 and later.'
83
+ UI.error UI::ERROR_TERMINAL_NOTIFIER_ONLY_OSX10
78
84
  end
79
85
  false
80
86
  end
81
87
  end
82
-
83
88
  end
84
-
85
89
  end
86
90
  end