guard 2.8.0 → 2.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/guard/internals/debugging.rb +66 -0
- data/lib/guard/internals/debugging.rb.orig +0 -0
- data/lib/guard/internals/tracing.rb +33 -0
- data/lib/guard/internals/tracing.rb.orig +0 -0
- data/lib/guard/runner.rb +0 -1
- data/lib/guard/setuper.rb +8 -33
- data/lib/guard/ui.rb +8 -1
- data/lib/guard/version.rb +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eba722e0d98149098d042a096e5df4dc7abd495b
|
4
|
+
data.tar.gz: 76421bb7bdc9c176c22ba3207460104d37090439
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c4f95478bc1293ff711721d8d8ed42b6a81b15daf2d17a3dcffa4f72dca1e6bbdfdbdf881e5f6993b3c5955bf08a5b8d608f3985650ad39248dfd2bf28e59b2c
|
7
|
+
data.tar.gz: 7a8cdcd97b6619ddc3c9ecf219229710107bf5fb58ebccbd457888711af57053f424998a82d5ffe92de72f3c40658535edd396890c64a948ef09390ed785f833
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# Because it's used by Sheller
|
2
|
+
require "open3"
|
3
|
+
|
4
|
+
require "guard/ui"
|
5
|
+
|
6
|
+
require "guard/internals/tracing"
|
7
|
+
|
8
|
+
module Guard
|
9
|
+
# @private api
|
10
|
+
module Internals
|
11
|
+
class Debugging
|
12
|
+
class << self
|
13
|
+
TRACES = [
|
14
|
+
[Kernel, :system],
|
15
|
+
[Kernel, :`],
|
16
|
+
[Open3, :popen3]
|
17
|
+
]
|
18
|
+
|
19
|
+
# Sets up debugging:
|
20
|
+
#
|
21
|
+
# * aborts on thread exceptions
|
22
|
+
# * Set the logging level to `:debug`
|
23
|
+
# * traces execution of Kernel.system and backtick calls
|
24
|
+
def start
|
25
|
+
return if @started ||= false
|
26
|
+
@started = true
|
27
|
+
|
28
|
+
Thread.abort_on_exception = true
|
29
|
+
|
30
|
+
::Guard::UI.level = Logger::DEBUG
|
31
|
+
|
32
|
+
TRACES.each { |mod, meth| _trace(mod, meth, &method(:_notify)) }
|
33
|
+
@traced = true
|
34
|
+
end
|
35
|
+
|
36
|
+
def stop
|
37
|
+
return unless @started ||= false
|
38
|
+
::Guard::UI.level = Logger::INFO
|
39
|
+
_reset
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def _notify(*args)
|
45
|
+
::Guard::UI.debug "Command execution: #{args.join(" ")}"
|
46
|
+
end
|
47
|
+
|
48
|
+
# reset singleton - called by tests
|
49
|
+
def _reset
|
50
|
+
@started = false
|
51
|
+
return unless @traced
|
52
|
+
TRACES.each { |mod, meth| _untrace(mod, meth) }
|
53
|
+
@traced = false
|
54
|
+
end
|
55
|
+
|
56
|
+
def _trace(mod, meth, &block)
|
57
|
+
::Guard::Internals::Tracing.trace(mod, meth, &block)
|
58
|
+
end
|
59
|
+
|
60
|
+
def _untrace(mod, meth)
|
61
|
+
::Guard::Internals::Tracing.untrace(mod, meth)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
File without changes
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Guard
|
2
|
+
module Internals
|
3
|
+
module Tracing
|
4
|
+
def self.trace(mod, meth)
|
5
|
+
meta = (class << mod; self; end)
|
6
|
+
original_meth = "original_#{meth}".to_sym
|
7
|
+
|
8
|
+
if mod.respond_to?(original_meth)
|
9
|
+
fail "ALREADY TRACED: #{mod}.#{meth}"
|
10
|
+
end
|
11
|
+
|
12
|
+
meta.send(:alias_method, original_meth, meth)
|
13
|
+
meta.send(:define_method, meth) do |*args, &block|
|
14
|
+
yield(*args) if block_given?
|
15
|
+
mod.send original_meth, *args, &block
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.untrace(mod, meth)
|
20
|
+
meta = (class << mod; self; end)
|
21
|
+
original_meth = "original_#{meth}".to_sym
|
22
|
+
|
23
|
+
unless mod.respond_to?(original_meth)
|
24
|
+
fail "NOT TRACED: #{mod}.#{meth} (no method: #{original_meth})"
|
25
|
+
end
|
26
|
+
|
27
|
+
meta.send(:remove_method, meth)
|
28
|
+
meta.send(:alias_method, meth, original_meth)
|
29
|
+
meta.send(:undef_method, original_meth)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
File without changes
|
data/lib/guard/runner.rb
CHANGED
data/lib/guard/setuper.rb
CHANGED
@@ -2,6 +2,8 @@ require "thread"
|
|
2
2
|
require "listen"
|
3
3
|
require "guard/options"
|
4
4
|
|
5
|
+
require "guard/internals/debugging"
|
6
|
+
|
5
7
|
module Guard
|
6
8
|
# Sets up initial variables and options
|
7
9
|
module Setuper
|
@@ -43,16 +45,20 @@ module Guard
|
|
43
45
|
# so ideally there should be a guard "instance"
|
44
46
|
# object that can be created anew between tests
|
45
47
|
def setup(opts = {})
|
48
|
+
# NOTE: must be set before anything calls Guard.options
|
46
49
|
reset_options(opts)
|
50
|
+
|
51
|
+
# NOTE: must be set before anything calls Guard::UI.debug
|
52
|
+
::Guard::Internals::Debugging.start if options[:debug]
|
53
|
+
|
47
54
|
reset_evaluator(opts)
|
48
55
|
|
49
56
|
@queue = Queue.new
|
50
57
|
@runner = ::Guard::Runner.new
|
51
58
|
@watchdirs = _setup_watchdirs
|
52
59
|
|
53
|
-
::Guard::UI.
|
60
|
+
::Guard::UI.reset_and_clear
|
54
61
|
|
55
|
-
_setup_debug if options[:debug]
|
56
62
|
@listener = _setup_listener
|
57
63
|
_setup_signal_traps
|
58
64
|
|
@@ -174,20 +180,6 @@ module Guard
|
|
174
180
|
|
175
181
|
private
|
176
182
|
|
177
|
-
# Sets up various debug behaviors:
|
178
|
-
#
|
179
|
-
# * Abort threads on exception;
|
180
|
-
# * Set the logging level to `:debug`;
|
181
|
-
# * Modify the system and ` methods to log themselves before being executed
|
182
|
-
#
|
183
|
-
# @see #_debug_command_execution
|
184
|
-
#
|
185
|
-
def _setup_debug
|
186
|
-
Thread.abort_on_exception = true
|
187
|
-
::Guard::UI.options[:level] = :debug
|
188
|
-
_debug_command_execution
|
189
|
-
end
|
190
|
-
|
191
183
|
# Initializes the listener and registers a callback for changes.
|
192
184
|
#
|
193
185
|
def _setup_listener
|
@@ -252,23 +244,6 @@ module Guard
|
|
252
244
|
end
|
253
245
|
end
|
254
246
|
|
255
|
-
# Adds a command logger in debug mode. This wraps common command
|
256
|
-
# execution functions and logs the executed command before execution.
|
257
|
-
#
|
258
|
-
def _debug_command_execution
|
259
|
-
Kernel.send(:alias_method, :original_system, :system)
|
260
|
-
Kernel.send(:define_method, :system) do |command, *args|
|
261
|
-
::Guard::UI.debug "Command execution: #{ command } #{ args.join(" ") }"
|
262
|
-
Kernel.send :original_system, command, *args
|
263
|
-
end
|
264
|
-
|
265
|
-
Kernel.send(:alias_method, :original_backtick, :'`')
|
266
|
-
Kernel.send(:define_method, :'`') do |command|
|
267
|
-
::Guard::UI.debug "Command execution: #{ command }"
|
268
|
-
Kernel.send :original_backtick, command
|
269
|
-
end
|
270
|
-
end
|
271
|
-
|
272
247
|
# TODO: Guard::Watch or Guard::Scope should provide this
|
273
248
|
def _scoped_watchers
|
274
249
|
watchers = []
|
data/lib/guard/ui.rb
CHANGED
@@ -53,10 +53,16 @@ module Guard
|
|
53
53
|
# @option options [String] template the logger template
|
54
54
|
# @option options [String] time_format the time format
|
55
55
|
#
|
56
|
+
# TODO: deprecate?
|
56
57
|
def options=(options)
|
57
58
|
@options = ::Guard::Options.new(options)
|
58
59
|
end
|
59
60
|
|
61
|
+
# Assigns a log level
|
62
|
+
def level=(new_level)
|
63
|
+
logger.level = new_level
|
64
|
+
end
|
65
|
+
|
60
66
|
# Show an info message.
|
61
67
|
#
|
62
68
|
# @param [String] message the message to show
|
@@ -135,7 +141,8 @@ module Guard
|
|
135
141
|
end
|
136
142
|
|
137
143
|
# TODO: arguments: UI uses Guard::options anyway
|
138
|
-
|
144
|
+
# @private api
|
145
|
+
def reset_and_clear
|
139
146
|
@clearable = false
|
140
147
|
clear(force: true)
|
141
148
|
end
|
data/lib/guard/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: guard
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.8.
|
4
|
+
version: 2.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thibaud Guillaume-Gentil
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-11-
|
11
|
+
date: 2014-11-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -129,6 +129,10 @@ files:
|
|
129
129
|
- lib/guard/guardfile/evaluator.rb.orig
|
130
130
|
- lib/guard/guardfile/generator.rb
|
131
131
|
- lib/guard/interactor.rb
|
132
|
+
- lib/guard/internals/debugging.rb
|
133
|
+
- lib/guard/internals/debugging.rb.orig
|
134
|
+
- lib/guard/internals/tracing.rb
|
135
|
+
- lib/guard/internals/tracing.rb.orig
|
132
136
|
- lib/guard/jobs/base.rb
|
133
137
|
- lib/guard/jobs/pry_wrapper.rb
|
134
138
|
- lib/guard/jobs/sleep.rb
|