guard 2.6.1 → 2.7.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -1,27 +1,26 @@
|
|
1
|
-
require
|
1
|
+
require "pry"
|
2
2
|
|
3
|
-
|
4
|
-
class Interactor
|
5
|
-
|
6
|
-
NOTIFICATION = Pry::CommandSet.new do
|
7
|
-
create_command 'notification' do
|
8
|
-
|
9
|
-
group 'Guard'
|
10
|
-
description 'Toggles the notifications.'
|
3
|
+
require "guard/notifier"
|
11
4
|
|
12
|
-
|
5
|
+
module Guard
|
6
|
+
module Commands
|
7
|
+
class Notification
|
8
|
+
def self.import
|
9
|
+
Pry::Commands.create_command "notification" do
|
10
|
+
group "Guard"
|
11
|
+
description "Toggles the notifications."
|
12
|
+
|
13
|
+
banner <<-BANNER
|
13
14
|
Usage: notification
|
14
15
|
|
15
16
|
Toggles the notifications on and off.
|
16
|
-
|
17
|
+
BANNER
|
17
18
|
|
18
|
-
|
19
|
-
|
19
|
+
def process
|
20
|
+
::Guard::Notifier.toggle
|
21
|
+
end
|
20
22
|
end
|
21
23
|
end
|
22
24
|
end
|
23
|
-
|
24
25
|
end
|
25
26
|
end
|
26
|
-
|
27
|
-
Pry.commands.import ::Guard::Interactor::NOTIFICATION
|
data/lib/guard/commands/pause.rb
CHANGED
@@ -1,28 +1,27 @@
|
|
1
|
-
|
2
|
-
class Interactor
|
3
|
-
|
4
|
-
PAUSE = Pry::CommandSet.new do
|
5
|
-
create_command 'pause' do
|
6
|
-
|
7
|
-
group 'Guard'
|
8
|
-
description 'Toggles the file listener.'
|
1
|
+
require "pry"
|
9
2
|
|
10
|
-
|
3
|
+
module Guard
|
4
|
+
module Commands
|
5
|
+
class Pause
|
6
|
+
def self.import
|
7
|
+
Pry::Commands.create_command "pause" do
|
8
|
+
group "Guard"
|
9
|
+
description "Toggles the file listener."
|
10
|
+
|
11
|
+
banner <<-BANNER
|
11
12
|
Usage: pause
|
12
13
|
|
13
14
|
Toggles the file listener on and off.
|
14
15
|
|
15
16
|
When the file listener is paused, the default Guard Pry
|
16
17
|
prompt will show the pause sign `[p]`.
|
17
|
-
|
18
|
+
BANNER
|
18
19
|
|
19
|
-
|
20
|
-
|
20
|
+
def process
|
21
|
+
::Guard.async_queue_add([:guard_pause])
|
22
|
+
end
|
21
23
|
end
|
22
24
|
end
|
23
25
|
end
|
24
|
-
|
25
26
|
end
|
26
27
|
end
|
27
|
-
|
28
|
-
Pry.commands.import ::Guard::Interactor::PAUSE
|
@@ -1,35 +1,34 @@
|
|
1
|
-
|
2
|
-
class Interactor
|
3
|
-
|
4
|
-
RELOAD = Pry::CommandSet.new do
|
5
|
-
create_command 'reload' do
|
1
|
+
require "pry"
|
6
2
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
3
|
+
module Guard
|
4
|
+
module Commands
|
5
|
+
class Reload
|
6
|
+
def self.import
|
7
|
+
Pry::Commands.create_command "reload" do
|
8
|
+
group "Guard"
|
9
|
+
description "Reload all plugins."
|
10
|
+
|
11
|
+
banner <<-BANNER
|
11
12
|
Usage: reload <scope>
|
12
13
|
|
13
14
|
Run the Guard plugin `reload` action.
|
14
15
|
|
15
16
|
You may want to specify an optional scope to the action,
|
16
17
|
either the name of a Guard plugin or a plugin group.
|
17
|
-
|
18
|
+
BANNER
|
18
19
|
|
19
|
-
|
20
|
-
|
20
|
+
def process(*entries)
|
21
|
+
scopes, unknown = ::Guard::Interactor.convert_scope(entries)
|
21
22
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
unless unknown.empty?
|
24
|
+
output.puts "Unknown scopes: #{ unknown.join(", ") }"
|
25
|
+
return
|
26
|
+
end
|
27
|
+
|
28
|
+
::Guard.async_queue_add([:guard_reload, scopes])
|
26
29
|
end
|
27
30
|
end
|
28
|
-
|
29
31
|
end
|
30
32
|
end
|
31
|
-
|
32
33
|
end
|
33
34
|
end
|
34
|
-
|
35
|
-
Pry.commands.import ::Guard::Interactor::RELOAD
|
data/lib/guard/commands/scope.rb
CHANGED
@@ -1,32 +1,36 @@
|
|
1
|
-
|
2
|
-
class Interactor
|
3
|
-
|
4
|
-
SCOPE = Pry::CommandSet.new do
|
5
|
-
create_command 'scope' do
|
6
|
-
|
7
|
-
group 'Guard'
|
8
|
-
description 'Scope Guard actions to groups and plugins.'
|
1
|
+
require "pry"
|
9
2
|
|
10
|
-
|
3
|
+
module Guard
|
4
|
+
module Commands
|
5
|
+
class Scope
|
6
|
+
def self.import
|
7
|
+
Pry::Commands.create_command "scope" do
|
8
|
+
group "Guard"
|
9
|
+
description "Scope Guard actions to groups and plugins."
|
10
|
+
|
11
|
+
banner <<-BANNER
|
11
12
|
Usage: scope <scope>
|
12
13
|
|
13
14
|
Set the global Guard scope.
|
14
|
-
|
15
|
+
BANNER
|
16
|
+
|
17
|
+
def process(*entries)
|
18
|
+
scope, unknown = ::Guard::Interactor.convert_scope(entries)
|
15
19
|
|
16
|
-
|
17
|
-
|
20
|
+
unless unknown.empty?
|
21
|
+
output.puts "Unknown scopes: #{unknown.join(",") }"
|
22
|
+
return
|
23
|
+
end
|
24
|
+
|
25
|
+
if scope[:plugins].empty? && scope[:groups].empty?
|
26
|
+
output.puts "Usage: scope <scope>"
|
27
|
+
return
|
28
|
+
end
|
18
29
|
|
19
|
-
if scope[:plugins].empty? && scope[:groups].empty?
|
20
|
-
output.puts 'Usage: scope <scope>'
|
21
|
-
else
|
22
30
|
::Guard.scope = scope
|
23
31
|
end
|
24
32
|
end
|
25
|
-
|
26
33
|
end
|
27
34
|
end
|
28
|
-
|
29
35
|
end
|
30
36
|
end
|
31
|
-
|
32
|
-
Pry.commands.import ::Guard::Interactor::SCOPE
|
data/lib/guard/commands/show.rb
CHANGED
@@ -1,27 +1,24 @@
|
|
1
|
-
require
|
1
|
+
require "pry"
|
2
2
|
|
3
3
|
module Guard
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
banner <<-BANNER
|
4
|
+
module Commands
|
5
|
+
class Show
|
6
|
+
def self.import
|
7
|
+
Pry::Commands.create_command "show" do
|
8
|
+
group "Guard"
|
9
|
+
description "Show all Guard plugins."
|
10
|
+
|
11
|
+
banner <<-BANNER
|
13
12
|
Usage: show
|
14
13
|
|
15
14
|
Show all defined Guard plugins and their options.
|
16
|
-
|
15
|
+
BANNER
|
17
16
|
|
18
|
-
|
19
|
-
|
17
|
+
def process
|
18
|
+
::Guard.async_queue_add([:guard_show])
|
19
|
+
end
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
23
|
-
|
24
23
|
end
|
25
24
|
end
|
26
|
-
|
27
|
-
Pry.commands.import ::Guard::Interactor::SHOW
|
@@ -1,7 +1,5 @@
|
|
1
1
|
module Guard
|
2
|
-
|
3
2
|
module DeprecatedMethods
|
4
|
-
|
5
3
|
# @deprecated Use `Guard.plugins(filter)` instead.
|
6
4
|
#
|
7
5
|
# @see https://github.com/guard/guard/wiki/Upgrading-to-Guard-2.0 How to
|
@@ -30,8 +28,8 @@ module Guard
|
|
30
28
|
# upgrade for Guard 2.0
|
31
29
|
#
|
32
30
|
def get_guard_class(name, fail_gracefully = false)
|
33
|
-
|
34
|
-
|
31
|
+
UI.deprecation(Deprecator::GET_GUARD_CLASS_DEPRECATION)
|
32
|
+
PluginUtil.new(name).plugin_class(fail_gracefully: fail_gracefully)
|
35
33
|
end
|
36
34
|
|
37
35
|
# @deprecated Use `Guard::PluginUtil.new(name).plugin_location` instead.
|
@@ -40,8 +38,8 @@ module Guard
|
|
40
38
|
# upgrade for Guard 2.0
|
41
39
|
#
|
42
40
|
def locate_guard(name)
|
43
|
-
|
44
|
-
|
41
|
+
UI.deprecation(Deprecator::LOCATE_GUARD_DEPRECATION)
|
42
|
+
PluginUtil.new(name).plugin_location
|
45
43
|
end
|
46
44
|
|
47
45
|
# @deprecated Use `Guard::PluginUtil.plugin_names` instead.
|
@@ -50,10 +48,8 @@ module Guard
|
|
50
48
|
# upgrade for Guard 2.0
|
51
49
|
#
|
52
50
|
def guard_gem_names
|
53
|
-
|
54
|
-
|
51
|
+
UI.deprecation(Deprecator::GUARD_GEM_NAMES_DEPRECATION)
|
52
|
+
PluginUtil.plugin_names
|
55
53
|
end
|
56
|
-
|
57
54
|
end
|
58
|
-
|
59
55
|
end
|
data/lib/guard/deprecator.rb
CHANGED
@@ -1,107 +1,122 @@
|
|
1
|
-
require
|
1
|
+
require "guard/ui"
|
2
2
|
|
3
3
|
module Guard
|
4
4
|
class Deprecator
|
5
|
+
UPGRADE_WIKI = "https://github.com/guard/guard/wiki"\
|
6
|
+
"/Upgrade-guide-for-existing-guards-to-Guard-v1.1"
|
5
7
|
|
6
|
-
MORE_INFO_ON_UPGRADING_TO_GUARD_1_1 = <<-EOS.gsub(/^\s*/,
|
7
|
-
For more information on how to update existing Guard plugins, please head
|
8
|
-
to:
|
8
|
+
MORE_INFO_ON_UPGRADING_TO_GUARD_1_1 = <<-EOS.gsub(/^\s*/, "")
|
9
|
+
For more information on how to update existing Guard plugins, please head
|
10
|
+
over to:
|
11
|
+
#{UPGRADE_WIKI}
|
9
12
|
EOS
|
10
13
|
|
11
|
-
MORE_INFO_ON_UPGRADING_TO_GUARD_2 = <<-EOS.gsub(/^\s*/,
|
14
|
+
MORE_INFO_ON_UPGRADING_TO_GUARD_2 = <<-EOS.gsub(/^\s*/, "")
|
12
15
|
For more information on how to upgrade for Guard 2.0, please head over
|
13
16
|
to: https://github.com/guard/guard/wiki/Upgrading-to-Guard-2.0%s
|
14
17
|
EOS
|
15
18
|
|
16
|
-
ADD_GUARD_DEPRECATION = <<-EOS.gsub(/^\s*/,
|
17
|
-
Starting with Guard 2.0 'Guard.add_guard(name, options = {})' is
|
19
|
+
ADD_GUARD_DEPRECATION = <<-EOS.gsub(/^\s*/, "")
|
20
|
+
Starting with Guard 2.0 'Guard.add_guard(name, options = {})' is
|
21
|
+
deprecated.
|
18
22
|
|
19
23
|
Please use 'Guard.add_plugin(name, options = {})' instead.
|
20
24
|
|
21
|
-
#{MORE_INFO_ON_UPGRADING_TO_GUARD_2 %
|
25
|
+
#{MORE_INFO_ON_UPGRADING_TO_GUARD_2 % "#deprecated-methods"}
|
22
26
|
EOS
|
23
27
|
|
24
|
-
GUARDS_DEPRECATION = <<-EOS.gsub(/^\s*/,
|
28
|
+
GUARDS_DEPRECATION = <<-EOS.gsub(/^\s*/, "")
|
25
29
|
Starting with Guard 2.0 'Guard.guards(filter)' is deprecated.
|
26
30
|
|
27
31
|
Please use 'Guard.plugins(filter)' instead.
|
28
32
|
|
29
|
-
#{MORE_INFO_ON_UPGRADING_TO_GUARD_2 %
|
33
|
+
#{MORE_INFO_ON_UPGRADING_TO_GUARD_2 % "#deprecated-methods"}
|
30
34
|
EOS
|
31
35
|
|
32
36
|
# Deprecator message for the `Guard.get_guard_class` method
|
33
|
-
GET_GUARD_CLASS_DEPRECATION = <<-EOS.gsub(/^\s*/,
|
37
|
+
GET_GUARD_CLASS_DEPRECATION = <<-EOS.gsub(/^\s*/, "")
|
34
38
|
Starting with Guard 2.0 'Guard.get_guard_class(name, fail_gracefully =
|
35
39
|
false)' is deprecated and is now always on.
|
36
40
|
|
37
41
|
Please use 'Guard::PluginUtil.new(name).plugin_class(fail_gracefully:
|
38
42
|
fail_gracefully)' instead.
|
39
43
|
|
40
|
-
#{MORE_INFO_ON_UPGRADING_TO_GUARD_2 %
|
44
|
+
#{MORE_INFO_ON_UPGRADING_TO_GUARD_2 % "#deprecated-methods"}
|
41
45
|
EOS
|
42
46
|
|
43
47
|
# Deprecator message for the `Guard.locate_guard` method
|
44
|
-
LOCATE_GUARD_DEPRECATION = <<-EOS.gsub(/^\s*/,
|
48
|
+
LOCATE_GUARD_DEPRECATION = <<-EOS.gsub(/^\s*/, "")
|
45
49
|
Starting with Guard 2.0 'Guard.locate_guard(name)' is deprecated.
|
46
50
|
|
47
51
|
Please use 'Guard::PluginUtil.new(name).plugin_location' instead.
|
48
52
|
|
49
|
-
#{MORE_INFO_ON_UPGRADING_TO_GUARD_2 %
|
53
|
+
#{MORE_INFO_ON_UPGRADING_TO_GUARD_2 % "#deprecated-methods"}
|
50
54
|
EOS
|
51
55
|
|
52
56
|
# Deprecator message for the `Guard.guard_gem_names` method
|
53
|
-
GUARD_GEM_NAMES_DEPRECATION = <<-EOS.gsub(/^\s*/,
|
57
|
+
GUARD_GEM_NAMES_DEPRECATION = <<-EOS.gsub(/^\s*/, "")
|
54
58
|
Starting with Guard 2.0 'Guard.guard_gem_names' is deprecated.
|
55
59
|
|
56
60
|
Please use 'Guard::PluginUtil.plugin_names' instead.
|
57
61
|
|
58
|
-
#{MORE_INFO_ON_UPGRADING_TO_GUARD_2 %
|
62
|
+
#{MORE_INFO_ON_UPGRADING_TO_GUARD_2 % "#deprecated-methods"}
|
59
63
|
EOS
|
60
64
|
|
61
65
|
# Deprecator message for the `Guard::Dsl.evaluate_guardfile` method
|
62
|
-
EVALUATE_GUARDFILE_DEPRECATION = <<-EOS.gsub(/^\s*/,
|
63
|
-
Starting with Guard 2.0 'Guard::Dsl.evaluate_guardfile(options)' is
|
66
|
+
EVALUATE_GUARDFILE_DEPRECATION = <<-EOS.gsub(/^\s*/, "")
|
67
|
+
Starting with Guard 2.0 'Guard::Dsl.evaluate_guardfile(options)' is
|
68
|
+
deprecated.
|
64
69
|
|
65
|
-
Please use 'Guard::Guardfile::Evaluator.new(options).evaluate_guardfile'
|
70
|
+
Please use 'Guard::Guardfile::Evaluator.new(options).evaluate_guardfile'
|
71
|
+
instead.
|
66
72
|
|
67
|
-
#{MORE_INFO_ON_UPGRADING_TO_GUARD_2 %
|
73
|
+
#{MORE_INFO_ON_UPGRADING_TO_GUARD_2 % "#deprecated-methods-1"}
|
68
74
|
EOS
|
69
75
|
|
70
76
|
# Deprecator message for the `Guardfile.create_guardfile` method
|
71
|
-
CREATE_GUARDFILE_DEPRECATION = <<-EOS.gsub(/^\s*/,
|
72
|
-
Starting with Guard 2.0 'Guard::Guardfile.create_guardfile(options)' is
|
77
|
+
CREATE_GUARDFILE_DEPRECATION = <<-EOS.gsub(/^\s*/, "")
|
78
|
+
Starting with Guard 2.0 'Guard::Guardfile.create_guardfile(options)' is
|
79
|
+
deprecated.
|
73
80
|
|
74
|
-
Please use 'Guard::Guardfile::Generator.new(options).create_guardfile'
|
81
|
+
Please use 'Guard::Guardfile::Generator.new(options).create_guardfile'
|
82
|
+
instead.
|
75
83
|
|
76
|
-
#{MORE_INFO_ON_UPGRADING_TO_GUARD_2 %
|
84
|
+
#{MORE_INFO_ON_UPGRADING_TO_GUARD_2 % "#deprecated-methods-2"}
|
77
85
|
EOS
|
78
86
|
|
79
87
|
# Deprecator message for the `Guardfile.initialize_template` method
|
80
|
-
INITIALIZE_TEMPLATE_DEPRECATION = <<-EOS.gsub(/^\s*/,
|
81
|
-
Starting with Guard 2.0
|
88
|
+
INITIALIZE_TEMPLATE_DEPRECATION = <<-EOS.gsub(/^\s*/, "")
|
89
|
+
Starting with Guard 2.0
|
90
|
+
'Guard::Guardfile.initialize_template(plugin_name)' is deprecated.
|
82
91
|
|
83
|
-
Please use
|
92
|
+
Please use
|
93
|
+
'Guard::Guardfile::Generator.new.initialize_template(plugin_name)'
|
94
|
+
instead.
|
84
95
|
|
85
|
-
#{MORE_INFO_ON_UPGRADING_TO_GUARD_2 %
|
96
|
+
#{MORE_INFO_ON_UPGRADING_TO_GUARD_2 % "#deprecated-methods-2"}
|
86
97
|
EOS
|
87
98
|
|
88
99
|
# Deprecator message for the `Guardfile.initialize_all_templates` method
|
89
|
-
INITIALIZE_ALL_TEMPLATES_DEPRECATION = <<-EOS.gsub(/^\s*/,
|
90
|
-
Starting with Guard 2.0 'Guard::Guardfile.initialize_all_templates' is
|
100
|
+
INITIALIZE_ALL_TEMPLATES_DEPRECATION = <<-EOS.gsub(/^\s*/, "")
|
101
|
+
Starting with Guard 2.0 'Guard::Guardfile.initialize_all_templates' is
|
102
|
+
deprecated.
|
91
103
|
|
92
|
-
Please use 'Guard::Guardfile::Generator.new.initialize_all_templates'
|
104
|
+
Please use 'Guard::Guardfile::Generator.new.initialize_all_templates'
|
105
|
+
instead.
|
93
106
|
|
94
|
-
#{MORE_INFO_ON_UPGRADING_TO_GUARD_2 %
|
107
|
+
#{MORE_INFO_ON_UPGRADING_TO_GUARD_2 % "#deprecated-methods-2"}
|
95
108
|
EOS
|
96
109
|
|
97
110
|
# Deprecator message for when a Guard plugin inherits from Guard::Guard
|
98
|
-
GUARD_GUARD_DEPRECATION = <<-EOS.gsub(/^\s*/,
|
99
|
-
Starting with Guard 2.0, Guard::%s should inherit from Guard::Plugin
|
111
|
+
GUARD_GUARD_DEPRECATION = <<-EOS.gsub(/^\s*/, "")
|
112
|
+
Starting with Guard 2.0, Guard::%s should inherit from Guard::Plugin
|
113
|
+
instead of Guard::Guard.
|
100
114
|
|
101
|
-
Please note that the constructor signature has changed from
|
115
|
+
Please note that the constructor signature has changed from
|
116
|
+
Guard::Guard#initialize(watchers = [], options = {}) to
|
117
|
+
Guard::Plugin#initialize(options = {}).
|
102
118
|
|
103
|
-
#{MORE_INFO_ON_UPGRADING_TO_GUARD_2 %
|
119
|
+
#{MORE_INFO_ON_UPGRADING_TO_GUARD_2 % "#changes-in-guardguard"}
|
104
120
|
EOS
|
105
|
-
|
106
121
|
end
|
107
122
|
end
|
data/lib/guard/dsl.rb
CHANGED
@@ -1,11 +1,10 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
1
|
+
require "guard/guardfile"
|
2
|
+
require "guard/interactor"
|
3
|
+
require "guard/notifier"
|
4
|
+
require "guard/ui"
|
5
|
+
require "guard/watcher"
|
6
6
|
|
7
7
|
module Guard
|
8
|
-
|
9
8
|
# The Dsl class provides the methods that are used in each `Guardfile` to
|
10
9
|
# describe the behaviour of Guard.
|
11
10
|
#
|
@@ -44,6 +43,11 @@ module Guard
|
|
44
43
|
# @see https://github.com/guard/guard/wiki/Guardfile-examples
|
45
44
|
#
|
46
45
|
class Dsl
|
46
|
+
WARN_INVALID_LOG_LEVEL = "Invalid log level `%s` ignored. "\
|
47
|
+
"Please use either :debug, :info, :warn or :error."
|
48
|
+
|
49
|
+
WARN_INVALID_LOG_OPTIONS = "You cannot specify the logger options"\
|
50
|
+
" :only and :except at the same time."
|
47
51
|
|
48
52
|
# @deprecated Use
|
49
53
|
# `Guard::Guardfile::Evaluator.new(options).evaluate_guardfile` instead.
|
@@ -52,8 +56,8 @@ module Guard
|
|
52
56
|
# upgrade for Guard 2.0
|
53
57
|
#
|
54
58
|
def self.evaluate_guardfile(options = {})
|
55
|
-
|
56
|
-
|
59
|
+
UI.deprecation(Deprecator::EVALUATE_GUARDFILE_DEPRECATION)
|
60
|
+
Guardfile::Evaluator.new(options).evaluate_guardfile
|
57
61
|
end
|
58
62
|
|
59
63
|
# Set notification options for the system notifications.
|
@@ -62,7 +66,7 @@ module Guard
|
|
62
66
|
# You can also pass `:off` as library to turn off notifications.
|
63
67
|
#
|
64
68
|
# @example Define multiple notifications
|
65
|
-
# notification :
|
69
|
+
# notification :ruby_gntp
|
66
70
|
# notification :ruby_gntp, host: '192.168.1.5'
|
67
71
|
#
|
68
72
|
# @param [Symbol, String] notifier the name of the notifier to use
|
@@ -71,7 +75,7 @@ module Guard
|
|
71
75
|
# @see Guard::Notifier for available notifier and its options.
|
72
76
|
#
|
73
77
|
def notification(notifier, options = {})
|
74
|
-
|
78
|
+
Notifier.add_notifier(notifier.to_sym, options.merge(silent: false))
|
75
79
|
end
|
76
80
|
|
77
81
|
# Sets the interactor options or disable the interactor.
|
@@ -108,7 +112,8 @@ module Guard
|
|
108
112
|
# guard :livereload
|
109
113
|
# end
|
110
114
|
#
|
111
|
-
# @param [Symbol, String, Array<Symbol, String>] name the group name called
|
115
|
+
# @param [Symbol, String, Array<Symbol, String>] name the group name called
|
116
|
+
# from the CLI
|
112
117
|
# @param [Hash] options the options accepted by the group
|
113
118
|
# @yield a block where you can declare several Guard plugins
|
114
119
|
#
|
@@ -121,7 +126,8 @@ module Guard
|
|
121
126
|
groups = args
|
122
127
|
|
123
128
|
groups.each do |group|
|
124
|
-
|
129
|
+
next unless group.to_sym == :all
|
130
|
+
fail ArgumentError, "'all' is not an allowed group name!"
|
125
131
|
end
|
126
132
|
|
127
133
|
if block_given?
|
@@ -136,7 +142,9 @@ module Guard
|
|
136
142
|
|
137
143
|
@current_groups.pop
|
138
144
|
else
|
139
|
-
::Guard::UI.error
|
145
|
+
::Guard::UI.error \
|
146
|
+
"No Guard plugins found in the group '#{ groups.join(", ") }',"\
|
147
|
+
" please add at least one."
|
140
148
|
end
|
141
149
|
end
|
142
150
|
|
@@ -169,6 +177,7 @@ module Guard
|
|
169
177
|
|
170
178
|
yield if block_given?
|
171
179
|
|
180
|
+
@current_groups ||= []
|
172
181
|
groups = @current_groups && @current_groups.last || [:default]
|
173
182
|
groups.each do |group|
|
174
183
|
::Guard.add_plugin(name, @plugin_options.merge(group: group))
|
@@ -177,22 +186,28 @@ module Guard
|
|
177
186
|
@plugin_options = nil
|
178
187
|
end
|
179
188
|
|
180
|
-
# Defines a pattern to be watched in order to run actions on file
|
189
|
+
# Defines a pattern to be watched in order to run actions on file
|
190
|
+
# modification.
|
181
191
|
#
|
182
192
|
# @example Declare watchers for a Guard
|
183
193
|
# guard :rspec do
|
184
194
|
# watch('spec/spec_helper.rb')
|
185
195
|
# watch(%r{^.+_spec.rb})
|
186
|
-
# watch(%r{^app/controllers/(.+).rb})
|
196
|
+
# watch(%r{^app/controllers/(.+).rb}) do |m|
|
197
|
+
# 'spec/acceptance/#{m[1]}s_spec.rb'
|
198
|
+
# end
|
187
199
|
# end
|
188
200
|
#
|
189
201
|
# @example Declare global watchers outside of a Guard
|
190
202
|
# watch(%r{^(.+)$}) { |m| puts "#{m[1]} changed." }
|
191
203
|
#
|
192
|
-
# @param [String, Regexp] pattern the pattern that Guard must watch for
|
204
|
+
# @param [String, Regexp] pattern the pattern that Guard must watch for
|
205
|
+
# modification
|
206
|
+
#
|
193
207
|
# @yield a block to be run when the pattern is matched
|
194
208
|
# @yieldparam [MatchData] m matches of the pattern
|
195
|
-
# @yieldreturn a directory, a filename, an array of
|
209
|
+
# @yieldreturn a directory, a filename, an array of
|
210
|
+
# directories / filenames, or nothing (can be an arbitrary command)
|
196
211
|
#
|
197
212
|
# @see Guard::Watcher
|
198
213
|
# @see #guard
|
@@ -200,6 +215,7 @@ module Guard
|
|
200
215
|
def watch(pattern, &action)
|
201
216
|
# Allow watches in the global scope (to execute arbitrary commands) by
|
202
217
|
# building a generic Guard::Plugin.
|
218
|
+
@plugin_options ||= nil
|
203
219
|
return guard(:plugin) { watch(pattern, &action) } unless @plugin_options
|
204
220
|
|
205
221
|
@plugin_options[:watchers] << ::Guard::Watcher.new(pattern, action)
|
@@ -213,8 +229,13 @@ module Guard
|
|
213
229
|
# @example Define a callback that'll be called before the `reload` action.
|
214
230
|
# callback(:reload_begin) { puts "Let's reload!" }
|
215
231
|
#
|
216
|
-
# @example Define a callback that'll be called before the `start` and
|
217
|
-
#
|
232
|
+
# @example Define a callback that'll be called before the `start` and
|
233
|
+
# `stop` actions.
|
234
|
+
#
|
235
|
+
# my_lambda = lambda do |plugin, event, *args|
|
236
|
+
# puts "Let's #{event} #{plugin} with #{args}!"
|
237
|
+
# end
|
238
|
+
#
|
218
239
|
# callback(my_lambda, [:start_begin, :start_end])
|
219
240
|
#
|
220
241
|
# @param [Array] args the callback arguments
|
@@ -223,15 +244,16 @@ module Guard
|
|
223
244
|
# @see Guard::Hooker
|
224
245
|
#
|
225
246
|
def callback(*args, &block)
|
247
|
+
@plugin_options ||= nil
|
226
248
|
fail "callback must be called within a guard block" unless @plugin_options
|
227
249
|
|
228
250
|
block, events = if args.size > 1
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
251
|
+
# block must be the first argument in that case, the
|
252
|
+
# yielded block is ignored
|
253
|
+
args
|
254
|
+
else
|
255
|
+
[block, args[0]]
|
256
|
+
end
|
235
257
|
@plugin_options[:callbacks] << { events: events, listener: block }
|
236
258
|
end
|
237
259
|
|
@@ -299,13 +321,13 @@ module Guard
|
|
299
321
|
options[:level] = options[:level].to_sym
|
300
322
|
|
301
323
|
unless [:debug, :info, :warn, :error].include? options[:level]
|
302
|
-
|
324
|
+
UI.warning WARN_INVALID_LOG_LEVEL % [options[:level]]
|
303
325
|
options.delete :level
|
304
326
|
end
|
305
327
|
end
|
306
328
|
|
307
329
|
if options[:only] && options[:except]
|
308
|
-
|
330
|
+
UI.warning WARN_INVALID_LOG_OPTIONS
|
309
331
|
|
310
332
|
options.delete :only
|
311
333
|
options.delete :except
|
@@ -313,10 +335,13 @@ module Guard
|
|
313
335
|
|
314
336
|
# Convert the :only and :except options to a regular expression
|
315
337
|
[:only, :except].each do |name|
|
316
|
-
|
317
|
-
|
318
|
-
|
338
|
+
next unless options[name]
|
339
|
+
|
340
|
+
list = [].push(options[name]).flatten.map do |plugin|
|
341
|
+
Regexp.escape(plugin.to_s)
|
319
342
|
end
|
343
|
+
|
344
|
+
options[name] = Regexp.new(list.join("|"), Regexp::IGNORECASE)
|
320
345
|
end
|
321
346
|
|
322
347
|
::Guard::UI.options.merge!(options)
|
@@ -339,10 +364,7 @@ module Guard
|
|
339
364
|
# @param [Hash] scopes the scope for the groups and plugins
|
340
365
|
#
|
341
366
|
def scope(scope = {})
|
342
|
-
scope[:plugins] = Array(scope[:plugins] || scope[:plugin] || [])
|
343
|
-
scope[:groups] = Array(scope[:groups] || scope[:group] || [])
|
344
367
|
::Guard.setup_scope(scope)
|
345
368
|
end
|
346
|
-
|
347
369
|
end
|
348
370
|
end
|