guard 2.7.2 → 2.7.3
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/lib/guard.rb.orig +213 -0
- data/lib/guard/cli.rb +7 -0
- data/lib/guard/cli.rb.orig +218 -0
- data/lib/guard/commander.rb.orig +103 -0
- data/lib/guard/commands/all.rb.orig +36 -0
- data/lib/guard/commands/reload.rb.orig +34 -0
- data/lib/guard/commands/scope.rb.orig +36 -0
- data/lib/guard/deprecated_methods.rb.orig +71 -0
- data/lib/guard/deprecator.rb.orig +206 -0
- data/lib/guard/guard.rb.orig +42 -0
- data/lib/guard/guardfile.rb.orig +43 -0
- data/lib/guard/guardfile/evaluator.rb +5 -2
- data/lib/guard/guardfile/evaluator.rb.orig +275 -0
- data/lib/guard/notifiers/base.rb.orig +221 -0
- data/lib/guard/plugin_util.rb.orig +186 -0
- data/lib/guard/runner.rb.orig +210 -0
- data/lib/guard/setuper.rb.orig +395 -0
- data/lib/guard/ui.rb.orig +278 -0
- data/lib/guard/version.rb +1 -1
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7fe4d02f1b032eb80f48d28b9e2a96cedc706a8d
|
4
|
+
data.tar.gz: 8835c817d58724daa4838a98688300cbde8c6118
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 42b4e420d55c5344df40f26ca6005da64cce67014d4dc06cbb08db146231fcb56c28a2b2c8a89434c3921e83cf3e946c8dcf3c821281fc948b038c5feb2a962c
|
7
|
+
data.tar.gz: 793aa5c2052dd4d37778b6361ceddd42a1e50d8ad4cd7eac1b4434955dfc6d7afadc94cdf6f96a2e0895fd2f26b05e138ab05d25cacf83d36a664221b3469215
|
data/lib/guard.rb.orig
ADDED
@@ -0,0 +1,213 @@
|
|
1
|
+
require "rbconfig"
|
2
|
+
|
3
|
+
require "guard/commander"
|
4
|
+
require "guard/deprecated_methods"
|
5
|
+
require "guard/deprecator"
|
6
|
+
require "guard/dsl"
|
7
|
+
require "guard/group"
|
8
|
+
require "guard/guardfile"
|
9
|
+
require "guard/interactor"
|
10
|
+
require "guard/notifier"
|
11
|
+
require "guard/plugin_util"
|
12
|
+
require "guard/runner"
|
13
|
+
require "guard/setuper"
|
14
|
+
require "guard/sheller"
|
15
|
+
require "guard/ui"
|
16
|
+
require "guard/watcher"
|
17
|
+
require "guard/reevaluator"
|
18
|
+
|
19
|
+
# Guard is the main module for all Guard related modules and classes.
|
20
|
+
# Also Guard plugins should use this namespace.
|
21
|
+
#
|
22
|
+
module Guard
|
23
|
+
DEV_NULL = Gem.win_platform? ? "NUL" : "/dev/null"
|
24
|
+
|
25
|
+
extend Commander
|
26
|
+
extend DeprecatedMethods
|
27
|
+
extend Setuper
|
28
|
+
|
29
|
+
class << self
|
30
|
+
# Called by Pry scope command
|
31
|
+
|
32
|
+
def scope=(new_scope)
|
33
|
+
@scope = new_scope
|
34
|
+
@scope.dup.freeze
|
35
|
+
end
|
36
|
+
|
37
|
+
def scope
|
38
|
+
<<<<<<< HEAD
|
39
|
+
fail "::Guard.setup() not called" if @scope.nil?
|
40
|
+
=======
|
41
|
+
>>>>>>> origin/api_safe_refactoring
|
42
|
+
@scope.dup.freeze
|
43
|
+
end
|
44
|
+
attr_reader :runner, :listener
|
45
|
+
|
46
|
+
# Smart accessor for retrieving specific plugins at once.
|
47
|
+
#
|
48
|
+
# @see Guard.plugin
|
49
|
+
# @see Guard.group
|
50
|
+
# @see Guard.groups
|
51
|
+
#
|
52
|
+
# @example Filter plugins by String or Symbol
|
53
|
+
# Guard.plugins('rspec')
|
54
|
+
# Guard.plugins(:rspec)
|
55
|
+
#
|
56
|
+
# @example Filter plugins by Regexp
|
57
|
+
# Guard.plugins(/rsp.+/)
|
58
|
+
#
|
59
|
+
# @example Filter plugins by Hash
|
60
|
+
# Guard.plugins(name: 'rspec', group: 'backend')
|
61
|
+
#
|
62
|
+
# @param [String, Symbol, Regexp, Hash] filter the filter to apply to the
|
63
|
+
# plugins
|
64
|
+
# @return [Plugin, Array<Plugin>] the filtered plugin(s)
|
65
|
+
#
|
66
|
+
def plugins(filter = nil)
|
67
|
+
@plugins ||= []
|
68
|
+
|
69
|
+
return @plugins if filter.nil?
|
70
|
+
|
71
|
+
filtered_plugins = case filter
|
72
|
+
when String, Symbol
|
73
|
+
@plugins.select do |plugin|
|
74
|
+
plugin.name == filter.to_s.downcase.gsub("-", "")
|
75
|
+
end
|
76
|
+
when Regexp
|
77
|
+
@plugins.select do |plugin|
|
78
|
+
plugin.name =~ filter
|
79
|
+
end
|
80
|
+
when Hash
|
81
|
+
@plugins.select do |plugin|
|
82
|
+
filter.all? do |k, v|
|
83
|
+
case k
|
84
|
+
when :name
|
85
|
+
plugin.name == v.to_s.downcase.gsub("-", "")
|
86
|
+
when :group
|
87
|
+
plugin.group.name == v.to_sym
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
filtered_plugins
|
94
|
+
end
|
95
|
+
|
96
|
+
# Smart accessor for retrieving a specific plugin.
|
97
|
+
#
|
98
|
+
# @see Guard.plugins
|
99
|
+
# @see Guard.group
|
100
|
+
# @see Guard.groups
|
101
|
+
#
|
102
|
+
# @example Find a plugin by String or Symbol
|
103
|
+
# Guard.plugin('rspec')
|
104
|
+
# Guard.plugin(:rspec)
|
105
|
+
#
|
106
|
+
# @example Find a plugin by Regexp
|
107
|
+
# Guard.plugin(/rsp.+/)
|
108
|
+
#
|
109
|
+
# @example Find a plugin by Hash
|
110
|
+
# Guard.plugin(name: 'rspec', group: 'backend')
|
111
|
+
#
|
112
|
+
# @param [String, Symbol, Regexp, Hash] filter the filter for finding the
|
113
|
+
# plugin the Guard plugin
|
114
|
+
# @return [Plugin, nil] the plugin found, nil otherwise
|
115
|
+
#
|
116
|
+
def plugin(filter)
|
117
|
+
plugins(filter).first
|
118
|
+
end
|
119
|
+
|
120
|
+
# Smart accessor for retrieving specific groups at once.
|
121
|
+
#
|
122
|
+
# @see Guard.plugin
|
123
|
+
# @see Guard.plugins
|
124
|
+
# @see Guard.group
|
125
|
+
#
|
126
|
+
# @example Filter groups by String or Symbol
|
127
|
+
# Guard.groups('backend')
|
128
|
+
# Guard.groups(:backend)
|
129
|
+
#
|
130
|
+
# @example Filter groups by Regexp
|
131
|
+
# Guard.groups(/(back|front)end/)
|
132
|
+
#
|
133
|
+
# @param [String, Symbol, Regexp] filter the filter to apply to the Groups
|
134
|
+
# @return [Array<Group>] the filtered group(s)
|
135
|
+
#
|
136
|
+
def groups(filter = nil)
|
137
|
+
@groups ||= []
|
138
|
+
|
139
|
+
return @groups if filter.nil?
|
140
|
+
|
141
|
+
case filter
|
142
|
+
when String, Symbol
|
143
|
+
@groups.select { |group| group.name == filter.to_sym }
|
144
|
+
when Regexp
|
145
|
+
@groups.select { |group| group.name.to_s =~ filter }
|
146
|
+
else
|
147
|
+
fail "Invalid filter: #{filter.inspect}"
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
# Smart accessor for retrieving a specific group.
|
152
|
+
#
|
153
|
+
# @see Guard.plugin
|
154
|
+
# @see Guard.plugins
|
155
|
+
# @see Guard.groups
|
156
|
+
#
|
157
|
+
# @example Find a group by String or Symbol
|
158
|
+
# Guard.group('backend')
|
159
|
+
# Guard.group(:backend)
|
160
|
+
#
|
161
|
+
# @example Find a group by Regexp
|
162
|
+
# Guard.group(/(back|front)end/)
|
163
|
+
#
|
164
|
+
# @param [String, Symbol, Regexp] filter the filter for finding the group
|
165
|
+
# @return [Group] the group found, nil otherwise
|
166
|
+
#
|
167
|
+
def group(filter)
|
168
|
+
groups(filter).first
|
169
|
+
end
|
170
|
+
|
171
|
+
# Add a Guard plugin to use.
|
172
|
+
#
|
173
|
+
# @param [String] name the Guard name
|
174
|
+
# @param [Hash] options the plugin options (see Plugin documentation)
|
175
|
+
# @option options [String] group the group to which the plugin belongs
|
176
|
+
# @option options [Array<Watcher>] watchers the list of declared watchers
|
177
|
+
# @option options [Array<Hash>] callbacks the list of callbacks
|
178
|
+
# @return [Plugin] the added Guard plugin
|
179
|
+
# @see Plugin
|
180
|
+
#
|
181
|
+
def add_plugin(name, options = {})
|
182
|
+
instance = ::Guard::PluginUtil.new(name).initialize_plugin(options)
|
183
|
+
@plugins << instance
|
184
|
+
instance
|
185
|
+
end
|
186
|
+
|
187
|
+
# Used by runner to remove a failed plugin
|
188
|
+
def remove_plugin(plugin)
|
189
|
+
# TODO: coverage/aruba
|
190
|
+
@plugins.delete(plugin)
|
191
|
+
end
|
192
|
+
|
193
|
+
# Add a Guard plugin group.
|
194
|
+
#
|
195
|
+
# @param [String] name the group name
|
196
|
+
# @option options [Boolean] halt_on_fail if a task execution
|
197
|
+
# should be halted for all Guard plugins in this group if
|
198
|
+
# one Guard throws `:task_has_failed`
|
199
|
+
# @return [Group] the group added (or retrieved from the `@groups`
|
200
|
+
# variable if already present)
|
201
|
+
#
|
202
|
+
# @see Group
|
203
|
+
#
|
204
|
+
def add_group(name, options = {})
|
205
|
+
unless (group = group(name))
|
206
|
+
group = ::Guard::Group.new(name, options)
|
207
|
+
@groups << group
|
208
|
+
end
|
209
|
+
|
210
|
+
group
|
211
|
+
end
|
212
|
+
end
|
213
|
+
end
|
data/lib/guard/cli.rb
CHANGED
@@ -171,8 +171,15 @@ module Guard
|
|
171
171
|
::Guard.reset_options(options) # Since UI.deprecated uses config
|
172
172
|
::Guard.reset_evaluator(options) # for initialize_all_templates
|
173
173
|
|
174
|
+
# This is messed up (deprecated, etc) and will be fixed later
|
174
175
|
::Guard::Guardfile.create_guardfile(abort_on_existence: options[:bare])
|
175
176
|
|
177
|
+
# Note: this reset "hack" will be fixed after refactoring
|
178
|
+
::Guard.reset_plugins
|
179
|
+
|
180
|
+
# Evaluate because it might have existed and creating was skipped
|
181
|
+
::Guard.evaluator.evaluate_guardfile
|
182
|
+
|
176
183
|
return if options[:bare]
|
177
184
|
|
178
185
|
if plugin_names.empty?
|
@@ -0,0 +1,218 @@
|
|
1
|
+
require "thor"
|
2
|
+
|
3
|
+
require "guard"
|
4
|
+
require "guard/version"
|
5
|
+
require "guard/dsl_describer"
|
6
|
+
require "guard/guardfile"
|
7
|
+
|
8
|
+
module Guard
|
9
|
+
# Facade for the Guard command line interface managed by
|
10
|
+
# [Thor](https://github.com/wycats/thor).
|
11
|
+
#
|
12
|
+
# This is the main interface to Guard that is called by the Guard binary
|
13
|
+
# `bin/guard`. Do not put any logic in here, create a class and delegate
|
14
|
+
# instead.
|
15
|
+
#
|
16
|
+
class CLI < Thor
|
17
|
+
default_task :start
|
18
|
+
|
19
|
+
desc "start", "Starts Guard"
|
20
|
+
|
21
|
+
method_option :clear,
|
22
|
+
type: :boolean,
|
23
|
+
default: false,
|
24
|
+
aliases: "-c",
|
25
|
+
banner: "Auto clear shell before each action"
|
26
|
+
|
27
|
+
method_option :notify,
|
28
|
+
type: :boolean,
|
29
|
+
default: true,
|
30
|
+
aliases: "-n",
|
31
|
+
banner: "Notifications feature"
|
32
|
+
|
33
|
+
method_option :debug,
|
34
|
+
type: :boolean,
|
35
|
+
default: false,
|
36
|
+
aliases: "-d",
|
37
|
+
banner: "Show debug information"
|
38
|
+
|
39
|
+
method_option :group,
|
40
|
+
type: :array,
|
41
|
+
default: [],
|
42
|
+
aliases: "-g",
|
43
|
+
banner: "Run only the passed groups"
|
44
|
+
|
45
|
+
method_option :plugin,
|
46
|
+
type: :array,
|
47
|
+
default: [],
|
48
|
+
aliases: "-P",
|
49
|
+
banner: "Run only the passed plugins"
|
50
|
+
|
51
|
+
method_option :watchdir,
|
52
|
+
type: :array,
|
53
|
+
aliases: "-w",
|
54
|
+
banner: "Specify the directories to watch"
|
55
|
+
|
56
|
+
method_option :guardfile,
|
57
|
+
type: :string,
|
58
|
+
aliases: "-G",
|
59
|
+
banner: "Specify a Guardfile"
|
60
|
+
|
61
|
+
method_option :no_interactions,
|
62
|
+
type: :boolean,
|
63
|
+
default: false,
|
64
|
+
aliases: "-i",
|
65
|
+
banner: "Turn off completely any Guard terminal interactions"
|
66
|
+
|
67
|
+
method_option :no_bundler_warning,
|
68
|
+
type: :boolean,
|
69
|
+
default: false,
|
70
|
+
aliases: "-B",
|
71
|
+
banner: "Turn off warning when Bundler is not present"
|
72
|
+
|
73
|
+
method_option :show_deprecations,
|
74
|
+
type: :boolean,
|
75
|
+
default: false,
|
76
|
+
banner: "Turn on deprecation warnings"
|
77
|
+
|
78
|
+
# Listen options
|
79
|
+
method_option :latency,
|
80
|
+
type: :numeric,
|
81
|
+
aliases: "-l",
|
82
|
+
banner: 'Overwrite Listen\'s default latency'
|
83
|
+
|
84
|
+
method_option :force_polling,
|
85
|
+
type: :boolean,
|
86
|
+
default: false,
|
87
|
+
aliases: "-p",
|
88
|
+
banner: "Force usage of the Listen polling listener"
|
89
|
+
|
90
|
+
method_option :wait_for_delay,
|
91
|
+
type: :numeric,
|
92
|
+
aliases: "-y",
|
93
|
+
banner: 'Overwrite Listen\'s default wait_for_delay'
|
94
|
+
|
95
|
+
method_option :listen_on,
|
96
|
+
type: :string,
|
97
|
+
aliases: "-o",
|
98
|
+
default: false,
|
99
|
+
banner: "Specify a network address to Listen on for "\
|
100
|
+
"file change events (e.g. for use in VMs)"
|
101
|
+
|
102
|
+
# Start Guard by initializing the defined Guard plugins and watch the file
|
103
|
+
# system.
|
104
|
+
#
|
105
|
+
# This is the default task, so calling `guard` is the same as calling
|
106
|
+
# `guard start`.
|
107
|
+
#
|
108
|
+
# @see Guard.start
|
109
|
+
#
|
110
|
+
def start
|
111
|
+
_verify_bundler_presence unless options[:no_bundler_warning]
|
112
|
+
::Guard.start(options)
|
113
|
+
end
|
114
|
+
|
115
|
+
desc "list", "Lists Guard plugins that can be used with init"
|
116
|
+
|
117
|
+
# List the Guard plugins that are available for use in your system and
|
118
|
+
# marks those that are currently used in your `Guardfile`.
|
119
|
+
#
|
120
|
+
# @see Guard::DslDescriber.list
|
121
|
+
#
|
122
|
+
def list
|
123
|
+
::Guard::DslDescriber.new(options).list
|
124
|
+
end
|
125
|
+
|
126
|
+
desc "notifiers", "Lists notifiers and its options"
|
127
|
+
|
128
|
+
# List the Notifiers for use in your system.
|
129
|
+
#
|
130
|
+
# @see Guard::DslDescriber.notifiers
|
131
|
+
#
|
132
|
+
def notifiers
|
133
|
+
::Guard::DslDescriber.new(options).notifiers
|
134
|
+
end
|
135
|
+
|
136
|
+
desc "version", "Show the Guard version"
|
137
|
+
map %w(-v --version) => :version
|
138
|
+
|
139
|
+
# Shows the current version of Guard.
|
140
|
+
#
|
141
|
+
# @see Guard::VERSION
|
142
|
+
#
|
143
|
+
def version
|
144
|
+
$stdout.puts "Guard version #{ ::Guard::VERSION }"
|
145
|
+
end
|
146
|
+
|
147
|
+
desc "init [GUARDS]", "Generates a Guardfile at the current directory"\
|
148
|
+
" (if it is not already there) and adds all installed Guard plugins"\
|
149
|
+
" or the given GUARDS into it"
|
150
|
+
|
151
|
+
method_option :bare,
|
152
|
+
type: :boolean,
|
153
|
+
default: false,
|
154
|
+
aliases: "-b",
|
155
|
+
banner: "Generate a bare Guardfile without adding any"\
|
156
|
+
" installed plugin into it"
|
157
|
+
|
158
|
+
# Initializes the templates of all installed Guard plugins and adds them
|
159
|
+
# to the `Guardfile` when no Guard name is passed. When passing
|
160
|
+
# Guard plugin names it does the same but only for those Guard plugins.
|
161
|
+
#
|
162
|
+
# @see Guard::Guardfile.initialize_template
|
163
|
+
# @see Guard::Guardfile.initialize_all_templates
|
164
|
+
#
|
165
|
+
# @param [Array<String>] plugin_names the name of the Guard plugins to
|
166
|
+
# initialize
|
167
|
+
#
|
168
|
+
def init(*plugin_names)
|
169
|
+
_verify_bundler_presence unless options[:no_bundler_warning]
|
170
|
+
|
171
|
+
::Guard.reset_options(options) # Since UI.deprecated uses config
|
172
|
+
::Guard.reset_evaluator(options) # for initialize_all_templates
|
173
|
+
|
174
|
+
::Guard::Guardfile.create_guardfile(abort_on_existence: options[:bare])
|
175
|
+
|
176
|
+
return if options[:bare]
|
177
|
+
|
178
|
+
if plugin_names.empty?
|
179
|
+
::Guard::Guardfile.initialize_all_templates
|
180
|
+
else
|
181
|
+
plugin_names.each do |plugin_name|
|
182
|
+
::Guard::Guardfile.initialize_template(plugin_name)
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
desc "show", "Show all defined Guard plugins and their options"
|
188
|
+
map %w(-T) => :show
|
189
|
+
|
190
|
+
# Shows all Guard plugins and their options that are defined in
|
191
|
+
# the `Guardfile`
|
192
|
+
#
|
193
|
+
# @see Guard::DslDescriber.show
|
194
|
+
#
|
195
|
+
def show
|
196
|
+
::Guard::DslDescriber.new(options).show
|
197
|
+
end
|
198
|
+
|
199
|
+
private
|
200
|
+
|
201
|
+
# Verifies if Guard is run with `bundle exec` and
|
202
|
+
# shows a hint to do so if not.
|
203
|
+
#
|
204
|
+
def _verify_bundler_presence
|
205
|
+
return unless File.exist?("Gemfile")
|
206
|
+
return if ENV["BUNDLE_GEMFILE"] || ENV["RUBYGEMS_GEMDEPS"]
|
207
|
+
|
208
|
+
::Guard::UI.info <<EOF
|
209
|
+
|
210
|
+
Guard here! It looks like your project has a Gemfile, yet you are running
|
211
|
+
`guard` outside of Bundler. If this is your intent, feel free to ignore this
|
212
|
+
message. Otherwise, consider using `bundle exec guard` to ensure your
|
213
|
+
dependencies are loaded correctly.
|
214
|
+
(You can run `guard` with --no-bundler-warning to get rid of this message.)
|
215
|
+
EOF
|
216
|
+
end
|
217
|
+
end
|
218
|
+
end
|