guard 2.6.1 → 2.7.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.
- checksums.yaml +4 -4
- data/README.md +73 -58
- data/bin/guard +2 -2
- data/lib/guard.rb +64 -59
- data/lib/guard/cli.rb +66 -60
- data/lib/guard/cli.rb.orig +215 -0
- data/lib/guard/commander.rb +45 -69
- data/lib/guard/commands/all.rb +21 -19
- data/lib/guard/commands/change.rb +17 -22
- data/lib/guard/commands/notification.rb +15 -16
- data/lib/guard/commands/pause.rb +14 -15
- data/lib/guard/commands/reload.rb +19 -20
- data/lib/guard/commands/scope.rb +23 -19
- data/lib/guard/commands/show.rb +13 -16
- data/lib/guard/deprecated_methods.rb +6 -10
- data/lib/guard/deprecator.rb +52 -37
- data/lib/guard/dsl.rb +55 -33
- data/lib/guard/dsl_describer.rb +83 -31
- data/lib/guard/dsl_describer.rb.orig +184 -0
- data/lib/guard/group.rb +7 -6
- data/lib/guard/guard.rb +4 -4
- data/lib/guard/guard.rb.orig +42 -0
- data/lib/guard/guardfile.rb +12 -13
- data/lib/guard/guardfile/evaluator.rb +77 -55
- data/lib/guard/guardfile/evaluator.rb.orig +275 -0
- data/lib/guard/guardfile/generator.rb +25 -20
- data/lib/guard/interactor.rb +52 -293
- data/lib/guard/interactor.rb.orig +85 -0
- data/lib/guard/jobs/base.rb +21 -0
- data/lib/guard/jobs/pry_wrapper.rb +290 -0
- data/lib/guard/jobs/pry_wrapper.rb.orig +293 -0
- data/lib/guard/jobs/sleep.rb +25 -0
- data/lib/guard/notifier.rb +42 -39
- data/lib/guard/notifiers/base.rb +25 -24
- data/lib/guard/notifiers/emacs.rb +30 -24
- data/lib/guard/notifiers/file_notifier.rb +3 -7
- data/lib/guard/notifiers/gntp.rb +22 -22
- data/lib/guard/notifiers/growl.rb +16 -15
- data/lib/guard/notifiers/libnotify.rb +7 -10
- data/lib/guard/notifiers/notifysend.rb +15 -14
- data/lib/guard/notifiers/rb_notifu.rb +8 -10
- data/lib/guard/notifiers/terminal_notifier.rb +15 -11
- data/lib/guard/notifiers/terminal_title.rb +4 -8
- data/lib/guard/notifiers/tmux.rb +104 -71
- data/lib/guard/options.rb +1 -5
- data/lib/guard/plugin.rb +1 -3
- data/lib/guard/plugin/base.rb +12 -9
- data/lib/guard/plugin/hooker.rb +1 -5
- data/lib/guard/plugin_util.rb +46 -25
- data/lib/guard/plugin_util.rb.orig +178 -0
- data/lib/guard/rake_task.rb +4 -7
- data/lib/guard/reevaluator.rb +13 -0
- data/lib/guard/runner.rb +50 -78
- data/lib/guard/runner.rb.orig +200 -0
- data/lib/guard/setuper.rb +199 -130
- data/lib/guard/setuper.rb.orig +348 -0
- data/lib/guard/sheller.rb +107 -0
- data/lib/guard/tags +367 -0
- data/lib/guard/ui.rb +50 -38
- data/lib/guard/ui.rb.orig +254 -0
- data/lib/guard/ui/colors.rb +17 -21
- data/lib/guard/version.rb +1 -1
- data/lib/guard/version.rb.orig +3 -0
- data/lib/guard/watcher.rb +49 -62
- metadata +21 -4
- data/lib/guard/notifiers/growl_notify.rb +0 -93
data/lib/guard/dsl_describer.rb
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
require
|
2
|
+
require "formatador"
|
3
3
|
|
4
|
-
require
|
5
|
-
require
|
4
|
+
require "guard/guardfile/evaluator"
|
5
|
+
require "guard/ui"
|
6
6
|
|
7
7
|
module Guard
|
8
|
-
|
9
8
|
# The DslDescriber evaluates the Guardfile and creates an internal structure
|
10
9
|
# of it that is used in some inspection utility methods like the CLI commands
|
11
10
|
# `show` and `list`.
|
@@ -14,20 +13,20 @@ module Guard
|
|
14
13
|
# @see Guard::CLI
|
15
14
|
#
|
16
15
|
class DslDescriber
|
17
|
-
|
18
|
-
attr_reader :options
|
19
|
-
|
20
16
|
# Initializes a new DslDescriber object.
|
21
17
|
#
|
22
18
|
# @option options [String] guardfile the path to a valid Guardfile
|
23
|
-
#
|
19
|
+
#
|
20
|
+
# @option options [String] guardfile_contents a string representing the
|
21
|
+
# content of a valid Guardfile
|
24
22
|
#
|
25
23
|
# @see Guard::Guardfile::Evaluator#initialize
|
26
24
|
#
|
27
25
|
def initialize(options = {})
|
28
|
-
@options = options
|
29
26
|
::Guard.reset_groups
|
30
27
|
::Guard.reset_plugins
|
28
|
+
::Guard.reset_scope
|
29
|
+
::Guard.reset_options(options)
|
31
30
|
end
|
32
31
|
|
33
32
|
# List the Guard plugins that are available for use in your system and marks
|
@@ -38,11 +37,15 @@ module Guard
|
|
38
37
|
def list
|
39
38
|
_evaluate_guardfile
|
40
39
|
|
41
|
-
|
42
|
-
|
40
|
+
names = ::Guard::PluginUtil.plugin_names.sort.uniq
|
41
|
+
final_rows = names.inject([]) do |rows, name|
|
42
|
+
rows << {
|
43
|
+
Plugin: name.capitalize,
|
44
|
+
Guardfile: ::Guard.plugins(name) ? "✔" : "✘"
|
45
|
+
}
|
43
46
|
end
|
44
47
|
|
45
|
-
Formatador.display_compact_table(
|
48
|
+
Formatador.display_compact_table(final_rows, [:Plugin, :Guardfile])
|
46
49
|
end
|
47
50
|
|
48
51
|
# Shows all Guard plugins and their options that are defined in
|
@@ -52,21 +55,42 @@ module Guard
|
|
52
55
|
#
|
53
56
|
def show
|
54
57
|
_evaluate_guardfile
|
58
|
+
groups = ::Guard.groups
|
55
59
|
|
56
|
-
|
57
|
-
|
58
|
-
|
60
|
+
final_rows = groups.each_with_object([]) do |group, rows|
|
61
|
+
|
62
|
+
plugins = Array(::Guard.plugins(group: group.name))
|
63
|
+
|
64
|
+
plugins.each do |plugin|
|
65
|
+
options = plugin.options.inject({}) do |o, (k, v)|
|
66
|
+
o.tap { |option| option[k.to_s] = v }
|
67
|
+
end.sort
|
59
68
|
|
60
69
|
if options.empty?
|
61
70
|
rows << :split
|
62
|
-
rows << {
|
71
|
+
rows << {
|
72
|
+
Group: group.title,
|
73
|
+
Plugin: plugin.title,
|
74
|
+
Option: "",
|
75
|
+
Value: ""
|
76
|
+
}
|
63
77
|
else
|
64
78
|
options.each_with_index do |(option, value), index|
|
65
79
|
if index == 0
|
66
80
|
rows << :split
|
67
|
-
rows << {
|
81
|
+
rows << {
|
82
|
+
Group: group.title,
|
83
|
+
Plugin: plugin.title,
|
84
|
+
Option: option.to_s,
|
85
|
+
Value: value.inspect
|
86
|
+
}
|
68
87
|
else
|
69
|
-
rows << {
|
88
|
+
rows << {
|
89
|
+
Group: "",
|
90
|
+
Plugin: "",
|
91
|
+
Option: option.to_s,
|
92
|
+
Value: value.inspect
|
93
|
+
}
|
70
94
|
end
|
71
95
|
end
|
72
96
|
end
|
@@ -75,7 +99,10 @@ module Guard
|
|
75
99
|
rows
|
76
100
|
end
|
77
101
|
|
78
|
-
Formatador.display_compact_table(
|
102
|
+
Formatador.display_compact_table(
|
103
|
+
final_rows.drop(1),
|
104
|
+
[:Group, :Plugin, :Option, :Value]
|
105
|
+
)
|
79
106
|
end
|
80
107
|
|
81
108
|
# Shows all notifiers and their options that are defined in
|
@@ -86,27 +113,28 @@ module Guard
|
|
86
113
|
def notifiers
|
87
114
|
_evaluate_guardfile
|
88
115
|
|
89
|
-
|
116
|
+
merged_notifiers = ::Guard::Notifier::NOTIFIERS.inject(:merge)
|
117
|
+
final_rows = merged_notifiers.each_with_object([]) do |definition, rows|
|
118
|
+
|
90
119
|
name = definition[0]
|
91
120
|
clazz = definition[1]
|
92
|
-
available = clazz.available?(silent: true) ?
|
93
|
-
notifier = ::Guard::Notifier.notifiers.
|
94
|
-
used = notifier ?
|
95
|
-
|
96
|
-
|
97
|
-
options = defaults.merge(options)
|
121
|
+
available = clazz.available?(silent: true) ? "✔" : "✘"
|
122
|
+
notifier = ::Guard::Notifier.notifiers.detect { |n| n[:name] == name }
|
123
|
+
used = notifier ? "✔" : "✘"
|
124
|
+
|
125
|
+
options = _merge_options(clazz, notifier)
|
98
126
|
options.delete(:silent)
|
99
127
|
|
100
128
|
if options.empty?
|
101
129
|
rows << :split
|
102
|
-
rows
|
130
|
+
_add_row(rows, name, available, used, "", "")
|
103
131
|
else
|
104
132
|
options.each_with_index do |(option, value), index|
|
105
133
|
if index == 0
|
106
134
|
rows << :split
|
107
|
-
rows
|
135
|
+
_add_row(rows, name, available, used, option.to_s, value.inspect)
|
108
136
|
else
|
109
|
-
rows
|
137
|
+
_add_row(rows, "", "", "", option.to_s, value.inspect)
|
110
138
|
end
|
111
139
|
end
|
112
140
|
end
|
@@ -114,7 +142,10 @@ module Guard
|
|
114
142
|
rows
|
115
143
|
end
|
116
144
|
|
117
|
-
Formatador.display_compact_table(
|
145
|
+
Formatador.display_compact_table(
|
146
|
+
final_rows.drop(1),
|
147
|
+
[:Name, :Available, :Used, :Option, :Value]
|
148
|
+
)
|
118
149
|
end
|
119
150
|
|
120
151
|
private
|
@@ -123,8 +154,29 @@ module Guard
|
|
123
154
|
# {Guard::Guardfile::Evaluator#evaluate_guardfile}.
|
124
155
|
#
|
125
156
|
def _evaluate_guardfile
|
126
|
-
::Guard
|
157
|
+
::Guard.save_scope
|
158
|
+
::Guard::Guardfile::Evaluator.new(::Guard.options).evaluate_guardfile
|
159
|
+
::Guard.restore_scope
|
160
|
+
end
|
161
|
+
|
162
|
+
def _merge_options(klass, notifier)
|
163
|
+
notify_options = notifier ? notifier[:options] : {}
|
164
|
+
|
165
|
+
if klass.const_defined?(:DEFAULTS)
|
166
|
+
klass.const_get(:DEFAULTS).merge(notify_options)
|
167
|
+
else
|
168
|
+
notify_options
|
169
|
+
end
|
127
170
|
end
|
128
171
|
|
172
|
+
def _add_row(rows, name, available, used, option, value)
|
173
|
+
rows << {
|
174
|
+
Name: name,
|
175
|
+
Available: available,
|
176
|
+
Used: used,
|
177
|
+
Option: option,
|
178
|
+
Value: value
|
179
|
+
}
|
180
|
+
end
|
129
181
|
end
|
130
182
|
end
|
@@ -0,0 +1,184 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "formatador"
|
3
|
+
|
4
|
+
require "guard/guardfile/evaluator"
|
5
|
+
require "guard/ui"
|
6
|
+
|
7
|
+
module Guard
|
8
|
+
# The DslDescriber evaluates the Guardfile and creates an internal structure
|
9
|
+
# of it that is used in some inspection utility methods like the CLI commands
|
10
|
+
# `show` and `list`.
|
11
|
+
#
|
12
|
+
# @see Guard::Dsl
|
13
|
+
# @see Guard::CLI
|
14
|
+
#
|
15
|
+
class DslDescriber
|
16
|
+
attr_reader :options
|
17
|
+
|
18
|
+
# Initializes a new DslDescriber object.
|
19
|
+
#
|
20
|
+
# @option options [String] guardfile the path to a valid Guardfile
|
21
|
+
#
|
22
|
+
# @option options [String] guardfile_contents a string representing the
|
23
|
+
# content of a valid Guardfile
|
24
|
+
#
|
25
|
+
# @see Guard::Guardfile::Evaluator#initialize
|
26
|
+
#
|
27
|
+
def initialize(options = {})
|
28
|
+
@options = options
|
29
|
+
::Guard.reset_groups
|
30
|
+
::Guard.reset_plugins
|
31
|
+
::Guard.reset_scope
|
32
|
+
end
|
33
|
+
|
34
|
+
# List the Guard plugins that are available for use in your system and marks
|
35
|
+
# those that are currently used in your `Guardfile`.
|
36
|
+
#
|
37
|
+
# @see CLI#list
|
38
|
+
#
|
39
|
+
def list
|
40
|
+
_evaluate_guardfile
|
41
|
+
|
42
|
+
names = ::Guard::PluginUtil.plugin_names.sort.uniq
|
43
|
+
final_rows = names.inject([]) do |rows, name|
|
44
|
+
rows << {
|
45
|
+
Plugin: name.capitalize,
|
46
|
+
Guardfile: ::Guard.plugins(name) ? "✔" : "✘"
|
47
|
+
}
|
48
|
+
end
|
49
|
+
|
50
|
+
Formatador.display_compact_table(final_rows, [:Plugin, :Guardfile])
|
51
|
+
end
|
52
|
+
|
53
|
+
# Shows all Guard plugins and their options that are defined in
|
54
|
+
# the `Guardfile`.
|
55
|
+
#
|
56
|
+
# @see CLI#show
|
57
|
+
#
|
58
|
+
def show
|
59
|
+
_evaluate_guardfile
|
60
|
+
groups = ::Guard.groups
|
61
|
+
|
62
|
+
final_rows = groups.each_with_object([]) do |group, rows|
|
63
|
+
|
64
|
+
plugins = Array(::Guard.plugins(group: group.name))
|
65
|
+
|
66
|
+
plugins.each do |plugin|
|
67
|
+
options = plugin.options.inject({}) do |o, (k, v)|
|
68
|
+
o.tap { |option| option[k.to_s] = v }
|
69
|
+
end.sort
|
70
|
+
|
71
|
+
if options.empty?
|
72
|
+
rows << :split
|
73
|
+
rows << {
|
74
|
+
Group: group.title,
|
75
|
+
Plugin: plugin.title,
|
76
|
+
Option: "",
|
77
|
+
Value: ""
|
78
|
+
}
|
79
|
+
else
|
80
|
+
options.each_with_index do |(option, value), index|
|
81
|
+
if index == 0
|
82
|
+
rows << :split
|
83
|
+
rows << {
|
84
|
+
Group: group.title,
|
85
|
+
Plugin: plugin.title,
|
86
|
+
Option: option.to_s,
|
87
|
+
Value: value.inspect
|
88
|
+
}
|
89
|
+
else
|
90
|
+
rows << {
|
91
|
+
Group: "",
|
92
|
+
Plugin: "",
|
93
|
+
Option: option.to_s,
|
94
|
+
Value: value.inspect
|
95
|
+
}
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
rows
|
102
|
+
end
|
103
|
+
|
104
|
+
Formatador.display_compact_table(
|
105
|
+
final_rows.drop(1),
|
106
|
+
[:Group, :Plugin, :Option, :Value]
|
107
|
+
)
|
108
|
+
end
|
109
|
+
|
110
|
+
# Shows all notifiers and their options that are defined in
|
111
|
+
# the `Guardfile`.
|
112
|
+
#
|
113
|
+
# @see CLI#show
|
114
|
+
#
|
115
|
+
def notifiers
|
116
|
+
_evaluate_guardfile
|
117
|
+
|
118
|
+
merged_notifiers = ::Guard::Notifier::NOTIFIERS.inject(:merge)
|
119
|
+
final_rows = merged_notifiers.each_with_object([]) do |definition, rows|
|
120
|
+
|
121
|
+
name = definition[0]
|
122
|
+
clazz = definition[1]
|
123
|
+
available = clazz.available?(silent: true) ? "✔" : "✘"
|
124
|
+
notifier = ::Guard::Notifier.notifiers.detect { |n| n[:name] == name }
|
125
|
+
used = notifier ? "✔" : "✘"
|
126
|
+
|
127
|
+
options = _merge_options(clazz, notifier)
|
128
|
+
options.delete(:silent)
|
129
|
+
|
130
|
+
if options.empty?
|
131
|
+
rows << :split
|
132
|
+
_add_row(rows, name, available, used, "", "")
|
133
|
+
else
|
134
|
+
options.each_with_index do |(option, value), index|
|
135
|
+
if index == 0
|
136
|
+
rows << :split
|
137
|
+
_add_row(rows, name, available, used, option.to_s, value.inspect)
|
138
|
+
else
|
139
|
+
_add_row(rows, "", "", "", option.to_s, value.inspect)
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
rows
|
145
|
+
end
|
146
|
+
|
147
|
+
Formatador.display_compact_table(
|
148
|
+
final_rows.drop(1),
|
149
|
+
[:Name, :Available, :Used, :Option, :Value]
|
150
|
+
)
|
151
|
+
end
|
152
|
+
|
153
|
+
private
|
154
|
+
|
155
|
+
# Evaluates the `Guardfile` by delegating to
|
156
|
+
# {Guard::Guardfile::Evaluator#evaluate_guardfile}.
|
157
|
+
#
|
158
|
+
def _evaluate_guardfile
|
159
|
+
::Guard.save_scope
|
160
|
+
::Guard::Guardfile::Evaluator.new(options).evaluate_guardfile
|
161
|
+
::Guard.restore_scope
|
162
|
+
end
|
163
|
+
|
164
|
+
def _merge_options(klass, notifier)
|
165
|
+
notify_options = notifier ? notifier[:options] : {}
|
166
|
+
|
167
|
+
if klass.const_defined?(:DEFAULTS)
|
168
|
+
klass.const_get(:DEFAULTS).merge(notify_options)
|
169
|
+
else
|
170
|
+
notify_options
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
def _add_row(rows, name, available, used, option, value)
|
175
|
+
rows << {
|
176
|
+
Name: name,
|
177
|
+
Available: available,
|
178
|
+
Used: used,
|
179
|
+
Option: option,
|
180
|
+
Value: value
|
181
|
+
}
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
data/lib/guard/group.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
module Guard
|
2
|
-
|
3
2
|
# A group of Guard plugins. There are two reasons why you want to group your
|
4
3
|
# Guard plugins:
|
5
4
|
#
|
@@ -11,16 +10,18 @@ module Guard
|
|
11
10
|
# @example Group that aborts on failure
|
12
11
|
#
|
13
12
|
# group :frontend, halt_on_fail: true do
|
14
|
-
# guard 'coffeescript', input: 'spec/coffeescripts',
|
13
|
+
# guard 'coffeescript', input: 'spec/coffeescripts',
|
14
|
+
# output: 'spec/javascripts'
|
15
15
|
# guard 'jasmine-headless-webkit' do
|
16
|
-
# watch(%r{^spec/javascripts/(.*)\..*})
|
16
|
+
# watch(%r{^spec/javascripts/(.*)\..*}) do |m|
|
17
|
+
# newest_js_file("spec/javascripts/#{m[1]}_spec")
|
18
|
+
# end
|
17
19
|
# end
|
18
20
|
# end
|
19
21
|
#
|
20
22
|
# @see Guard::CLI
|
21
23
|
#
|
22
24
|
class Group
|
23
|
-
|
24
25
|
attr_accessor :name, :options
|
25
26
|
|
26
27
|
# Initializes a Group.
|
@@ -28,7 +29,8 @@ module Guard
|
|
28
29
|
# @param [String] name the name of the group
|
29
30
|
# @param [Hash] options the group options
|
30
31
|
# @option options [Boolean] halt_on_fail if a task execution
|
31
|
-
# should be halted for all Guard plugins in this group if a Guard plugin
|
32
|
+
# should be halted for all Guard plugins in this group if a Guard plugin
|
33
|
+
# throws `:task_has_failed`
|
32
34
|
#
|
33
35
|
def initialize(name, options = {})
|
34
36
|
@name = name.to_sym
|
@@ -58,6 +60,5 @@ module Guard
|
|
58
60
|
def to_s
|
59
61
|
"#<#{self.class} @name=#{name} @options=#{options}>"
|
60
62
|
end
|
61
|
-
|
62
63
|
end
|
63
64
|
end
|
data/lib/guard/guard.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
|
-
require
|
1
|
+
require "guard/plugin/base"
|
2
2
|
|
3
3
|
module Guard
|
4
|
-
|
5
4
|
# @deprecated Inheriting from `Guard::Guard` is deprecated, please inherit
|
6
5
|
# from {Plugin} instead. Please note that the constructor signature has
|
7
6
|
# changed from `Guard::Guard#initialize(watchers = [], options = {})` to
|
@@ -30,13 +29,14 @@ module Guard
|
|
30
29
|
# @option options [Symbol] group the group this Guard plugin belongs to
|
31
30
|
# @option options [Boolean] any_return allow any object to be returned from
|
32
31
|
# a watcher
|
32
|
+
# @option options [Boolean] first_match stop after the first watcher that
|
33
|
+
# returns a valid result
|
33
34
|
#
|
34
35
|
def initialize(watchers = [], options = {})
|
35
|
-
|
36
|
+
UI.deprecation(Deprecator::GUARD_GUARD_DEPRECATION % title)
|
36
37
|
|
37
38
|
_set_instance_variables_from_options(options.merge(watchers: watchers))
|
38
39
|
_register_callbacks
|
39
40
|
end
|
40
|
-
|
41
41
|
end
|
42
42
|
end
|