guard 2.14.0 → 2.14.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -4
- data/lib/guard/cli.rb +1 -1
- data/lib/guard/options.rb +5 -0
- data/lib/guard/plugin_util.rb +1 -1
- data/lib/guard/runner.rb +6 -4
- data/lib/guard/terminal.rb +1 -1
- data/lib/guard/ui.rb +23 -24
- data/lib/guard/ui/config.rb +70 -0
- data/lib/guard/ui/logger.rb +30 -0
- data/lib/guard/version.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 333a3157cb9d7213ed91accef45785924fd9db23
|
4
|
+
data.tar.gz: 8b434fd66fdc4b04d024b2acf965208ed7513ca0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0cda152be7d6ae11a64ff0e66c7177812ee2da867a14c591720678c03d19cd006153bfa29abed4cd2e85eb444ad55f50d274ff9bec7eaf1f938968e64284ba6e
|
7
|
+
data.tar.gz: 6194bb82b25b8b4b78cb9c14a919acee55422436a153a903e87b457d085257f442ce27b757abcef73c45a6f7f34b310d8999c9833c3b426f94c60a18ea5cba70
|
data/README.md
CHANGED
@@ -1,13 +1,13 @@
|
|
1
|
-
## IMPORTANT: [Ruby 2.1 is officially outdated and unsupported!](https://www.ruby-lang.org/en/news/2016/03/30/ruby-2-1-9-released/) Please upgrade to Ruby 2.2 before installing Guard!
|
1
|
+
## IMPORTANT: [Ruby 2.1 is officially outdated and unsupported!](https://www.ruby-lang.org/en/news/2016/03/30/ruby-2-1-9-released/) Please upgrade to Ruby >=2.3 or >=2.2.6 before installing Guard!
|
2
2
|
|
3
|
-
### (To install for older versions, update Bundler
|
3
|
+
### (To install for older versions, update Bundler at least 1.12: `gem update bundler` and Bundler should correctly resolve to earlier gems for your given Ruby version).
|
4
4
|
|
5
5
|
:exclamation: Guard is currently accepting more maintainers. Please [read this](https://github.com/guard/guard/wiki/Maintainers) if you're interested in joining the team.
|
6
6
|
|
7
7
|
Guard
|
8
8
|
=====
|
9
9
|
|
10
|
-
[![Gem Version](https://img.shields.io/gem/v/guard.svg?style=flat)](https://rubygems.org/gems/guard) [![Build Status](https://travis-ci.org/guard/guard.svg)](https://travis-ci.org/guard/guard) [![Dependency Status](https://gemnasium.com/guard/guard.
|
10
|
+
[![Gem Version](https://img.shields.io/gem/v/guard.svg?style=flat)](https://rubygems.org/gems/guard) [![Build Status](https://travis-ci.org/guard/guard.svg)](https://travis-ci.org/guard/guard) [![Dependency Status](https://gemnasium.com/guard/guard.svg)](https://gemnasium.com/guard/guard) [![Code Climate](https://codeclimate.com/github/guard/guard/badges/gpa.svg)](https://codeclimate.com/github/guard/guard) [![Test Coverage](https://codeclimate.com/github/guard/guard/badges/coverage.svg)](https://codeclimate.com/github/guard/guard) [![Inline docs](http://inch-ci.org/github/guard/guard.svg)](http://inch-ci.org/github/guard/guard)
|
11
11
|
|
12
12
|
<img src="http://f.cl.ly/items/0A0M3W2x3I1P450z341U/guard-Icon.png" alt="Guard Icon" align="right" />
|
13
13
|
Guard automates various tasks by running custom rules whenever file or directories are modified.
|
@@ -35,7 +35,7 @@ Before you file an issue, make sure you have read the _[known issues](#issues)_
|
|
35
35
|
* File system changes handled by our awesome [Listen](https://github.com/guard/listen) gem.
|
36
36
|
* Support for visual system notifications.
|
37
37
|
* Huge eco-system with [more than 220](https://rubygems.org/search?query=guard-) Guard plugins.
|
38
|
-
* Tested against Ruby
|
38
|
+
* Tested against Ruby 2.2.6, 2.3.3, 2.4.0, JRuby & Rubinius.
|
39
39
|
|
40
40
|
#### Screencast
|
41
41
|
|
data/lib/guard/cli.rb
CHANGED
data/lib/guard/options.rb
CHANGED
data/lib/guard/plugin_util.rb
CHANGED
@@ -126,7 +126,7 @@ module Guard
|
|
126
126
|
def add_to_guardfile
|
127
127
|
klass = plugin_class # call here to avoid failing later
|
128
128
|
|
129
|
-
|
129
|
+
require_relative "guardfile/evaluator"
|
130
130
|
# TODO: move this to Generator?
|
131
131
|
options = Guard.state.session.evaluator_options
|
132
132
|
evaluator = Guardfile::Evaluator.new(options)
|
data/lib/guard/runner.rb
CHANGED
@@ -78,10 +78,12 @@ module Guard
|
|
78
78
|
def _supervise(plugin, task, *args)
|
79
79
|
catch self.class.stopping_symbol_for(plugin) do
|
80
80
|
plugin.hook("#{ task }_begin", *args)
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
81
|
+
result = UI.options.with_progname(plugin.class.name) do
|
82
|
+
begin
|
83
|
+
plugin.send(task, *args)
|
84
|
+
rescue Interrupt
|
85
|
+
throw(:task_has_failed)
|
86
|
+
end
|
85
87
|
end
|
86
88
|
plugin.hook("#{ task }_end", result)
|
87
89
|
result
|
data/lib/guard/terminal.rb
CHANGED
@@ -4,7 +4,7 @@ module Guard
|
|
4
4
|
class Terminal
|
5
5
|
class << self
|
6
6
|
def clear
|
7
|
-
cmd = Gem.win_platform? ? "cls" : "
|
7
|
+
cmd = Gem.win_platform? ? "cls" : "printf '\33c\e[3J';"
|
8
8
|
exit_code, _, stderr = Shellany::Sheller.system(cmd)
|
9
9
|
fail Errno::ENOENT, stderr unless exit_code == 0
|
10
10
|
end
|
data/lib/guard/ui.rb
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
require "guard/ui/colors"
|
2
|
+
require "guard/ui/config"
|
2
3
|
|
3
4
|
require "guard/terminal"
|
4
|
-
require "guard/options"
|
5
5
|
require "forwardable"
|
6
6
|
|
7
7
|
# TODO: rework this class from the bottom-up
|
8
8
|
# - remove dependency on Session and Scope
|
9
9
|
# - extract into a separate gem
|
10
|
+
# - change UI to class
|
10
11
|
|
11
12
|
module Guard
|
12
13
|
# The UI class helps to format messages for the user. Everything that is
|
@@ -23,13 +24,11 @@ module Guard
|
|
23
24
|
# Get the Guard::UI logger instance
|
24
25
|
#
|
25
26
|
def logger
|
26
|
-
@logger ||=
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
)
|
32
|
-
end
|
27
|
+
@logger ||=
|
28
|
+
begin
|
29
|
+
require "lumberjack"
|
30
|
+
Lumberjack::Logger.new(options.device, options.logger_config)
|
31
|
+
end
|
33
32
|
end
|
34
33
|
|
35
34
|
# Since logger is global, for Aruba in-process to properly
|
@@ -45,11 +44,7 @@ module Guard
|
|
45
44
|
# @return [Hash] the logger options
|
46
45
|
#
|
47
46
|
def options
|
48
|
-
@options ||=
|
49
|
-
level: :info,
|
50
|
-
template: ":time - :severity - :message",
|
51
|
-
time_format: "%H:%M:%S"
|
52
|
-
)
|
47
|
+
@options ||= Config.new
|
53
48
|
end
|
54
49
|
|
55
50
|
# Set the logger options
|
@@ -61,12 +56,14 @@ module Guard
|
|
61
56
|
#
|
62
57
|
# TODO: deprecate?
|
63
58
|
def options=(options)
|
64
|
-
@options =
|
59
|
+
@options = Config.new(options)
|
65
60
|
end
|
66
61
|
|
67
62
|
# Assigns a log level
|
68
|
-
|
69
|
-
|
63
|
+
def level=(new_level)
|
64
|
+
options.logger_config.level = new_level
|
65
|
+
@logger.level = new_level if @logger
|
66
|
+
end
|
70
67
|
|
71
68
|
# Show an info message.
|
72
69
|
#
|
@@ -176,9 +173,9 @@ module Guard
|
|
176
173
|
# @yieldparam [String] param the calling plugin name
|
177
174
|
#
|
178
175
|
def _filter(plugin)
|
179
|
-
only = options
|
180
|
-
except = options
|
181
|
-
plugin ||=
|
176
|
+
only = options.only
|
177
|
+
except = options.except
|
178
|
+
plugin ||= _calling_plugin_name
|
182
179
|
|
183
180
|
match = !(only || except)
|
184
181
|
match ||= (only && only.match(plugin))
|
@@ -191,9 +188,9 @@ module Guard
|
|
191
188
|
def _filtered_logger_message(message, method, color_name, options = {})
|
192
189
|
message = color(message, color_name) if color_name
|
193
190
|
|
194
|
-
_filter(options[:plugin]) do
|
191
|
+
_filter(options[:plugin]) do
|
195
192
|
reset_line if options[:reset]
|
196
|
-
logger.send(method, message
|
193
|
+
logger.send(method, message)
|
197
194
|
end
|
198
195
|
end
|
199
196
|
|
@@ -203,9 +200,11 @@ module Guard
|
|
203
200
|
# @param [Integer] depth the stack depth
|
204
201
|
# @return [String] the Guard plugin name
|
205
202
|
#
|
206
|
-
def
|
207
|
-
name =
|
208
|
-
|
203
|
+
def _calling_plugin_name
|
204
|
+
name = caller.lazy.map do |line|
|
205
|
+
%r{(?<!guard\/lib)\/(guard\/[a-z_]*)(/[a-z_]*)?.rb:}i.match(line)
|
206
|
+
end.reject(&:nil?).take(1).force.first
|
207
|
+
return "Guard" unless name || (name && name[1] == "guard/lib")
|
209
208
|
name[1].split("/").map do |part|
|
210
209
|
part.split(/[^a-z0-9]/i).map(&:capitalize).join
|
211
210
|
end.join("::")
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require "guard/options"
|
2
|
+
require "guard/ui/logger"
|
3
|
+
|
4
|
+
module Guard
|
5
|
+
module UI
|
6
|
+
class Config < Guard::Options
|
7
|
+
DEFAULTS = {
|
8
|
+
only: nil,
|
9
|
+
except: nil,
|
10
|
+
|
11
|
+
# nil (will be whatever $stderr is later) or LumberJack device, e.g.
|
12
|
+
# $stderr or 'foo.log'
|
13
|
+
device: nil,
|
14
|
+
}.freeze
|
15
|
+
|
16
|
+
DEPRECATED_OPTS = %w(template time_format level progname).freeze
|
17
|
+
|
18
|
+
attr_reader :logger_config
|
19
|
+
|
20
|
+
def initialize(options = {})
|
21
|
+
opts = Guard::Options.new(options, DEFAULTS)
|
22
|
+
|
23
|
+
# migrate old options stored in UI config directly
|
24
|
+
deprecated_logger_opts = {}
|
25
|
+
DEPRECATED_OPTS.each do |option|
|
26
|
+
if opts.key?(option)
|
27
|
+
deprecated_logger_opts[option.to_sym] = opts.delete(option)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
@logger_config = Logger::Config.new(deprecated_logger_opts)
|
32
|
+
super(opts.to_hash)
|
33
|
+
end
|
34
|
+
|
35
|
+
def device
|
36
|
+
# Use strings to work around Thor's indifferent Hash's bug
|
37
|
+
fetch("device") || $stderr
|
38
|
+
end
|
39
|
+
|
40
|
+
def only
|
41
|
+
fetch("only")
|
42
|
+
end
|
43
|
+
|
44
|
+
def except
|
45
|
+
fetch("except")
|
46
|
+
end
|
47
|
+
|
48
|
+
def [](name)
|
49
|
+
name = name.to_s
|
50
|
+
|
51
|
+
# TODO: remove in Guard 3.x
|
52
|
+
return logger_config[name] if DEPRECATED_OPTS.include?(name)
|
53
|
+
return device if name == "device"
|
54
|
+
|
55
|
+
# let Thor's Hash handle anything else
|
56
|
+
super(name.to_s)
|
57
|
+
end
|
58
|
+
|
59
|
+
def with_progname(name)
|
60
|
+
if Guard::UI.logger.respond_to?(:set_progname)
|
61
|
+
Guard::UI.logger.set_progname(name) do
|
62
|
+
yield if block_given?
|
63
|
+
end
|
64
|
+
elsif block_given?
|
65
|
+
yield
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require "guard/options"
|
2
|
+
|
3
|
+
module Guard
|
4
|
+
module UI
|
5
|
+
class Logger
|
6
|
+
class Config < Guard::Options
|
7
|
+
DEFAULTS = {
|
8
|
+
progname: "Guard",
|
9
|
+
level: :info,
|
10
|
+
template: ":time - :severity - :message",
|
11
|
+
time_format: "%H:%M:%S",
|
12
|
+
flush_seconds: 0,
|
13
|
+
|
14
|
+
# Other LumberJack device-specific options
|
15
|
+
# max_size: "5M",
|
16
|
+
# buffer_size: 0,
|
17
|
+
# additional_lines: nil,
|
18
|
+
}.freeze
|
19
|
+
|
20
|
+
def initialize(options = {})
|
21
|
+
super(options, DEFAULTS)
|
22
|
+
end
|
23
|
+
|
24
|
+
def level=(value)
|
25
|
+
self["level"] = value
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
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.14.
|
4
|
+
version: 2.14.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:
|
11
|
+
date: 2017-01-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -196,6 +196,8 @@ files:
|
|
196
196
|
- lib/guard/terminal.rb
|
197
197
|
- lib/guard/ui.rb
|
198
198
|
- lib/guard/ui/colors.rb
|
199
|
+
- lib/guard/ui/config.rb
|
200
|
+
- lib/guard/ui/logger.rb
|
199
201
|
- lib/guard/version.rb
|
200
202
|
- lib/guard/watcher.rb
|
201
203
|
- lib/guard/watcher/pattern.rb
|
@@ -227,9 +229,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
227
229
|
version: '0'
|
228
230
|
requirements: []
|
229
231
|
rubyforge_project:
|
230
|
-
rubygems_version: 2.
|
232
|
+
rubygems_version: 2.6.10
|
231
233
|
signing_key:
|
232
234
|
specification_version: 4
|
233
235
|
summary: Guard keeps an eye on your file modifications
|
234
236
|
test_files: []
|
235
|
-
has_rdoc:
|