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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ee12e6183bd7f80c82c6c173e73da077423efd8b
4
- data.tar.gz: 658e7a0eaf51b6d4ba16cf8126f1cebe9ef75e10
3
+ metadata.gz: 333a3157cb9d7213ed91accef45785924fd9db23
4
+ data.tar.gz: 8b434fd66fdc4b04d024b2acf965208ed7513ca0
5
5
  SHA512:
6
- metadata.gz: 7d40ddd8ef223df2e0bbf59791583eeaf4b460eac7a32a674e3b2d16c51ca9f8158b71b1458c605c0a3e9b078d724362443ea1f7dd73a3a85e419ff6fbc28fa8
7
- data.tar.gz: 5fb257cf77358225a124a6b659812e78f9aea514c66578993f1b8d2dd874b7f0a174e68d3d8fda209dc515674897b72e32775f6c0d8186db36dfdfedd29e7f17
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 to a prerelease version: `gem install bundler --pre` and Bundler should correctly resolve to an earlier gems for your given Ruby version).
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.png)](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)
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 1.9.3, 2.0.0, 2.1.0, JRuby & Rubinius.
38
+ * Tested against Ruby 2.2.6, 2.3.3, 2.4.0, JRuby & Rubinius.
39
39
 
40
40
  #### Screencast
41
41
 
@@ -92,7 +92,7 @@ module Guard
92
92
  method_option :listen_on,
93
93
  type: :string,
94
94
  aliases: "-o",
95
- default: false,
95
+ default: nil,
96
96
  banner: "Specify a network address to Listen on for "\
97
97
  "file change events (e.g. for use in VMs)"
98
98
 
@@ -13,5 +13,10 @@ module Guard
13
13
  def initialize(opts = {}, default_opts = {})
14
14
  super(default_opts.merge(opts || {}))
15
15
  end
16
+
17
+ # workaround for: https://github.com/erikhuda/thor/issues/504
18
+ def fetch(name)
19
+ super(name.to_s)
20
+ end
16
21
  end
17
22
  end
@@ -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
- require "guard/guardfile/evaluator"
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)
@@ -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
- begin
82
- result = plugin.send(task, *args)
83
- rescue Interrupt
84
- throw(:task_has_failed)
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
@@ -4,7 +4,7 @@ module Guard
4
4
  class Terminal
5
5
  class << self
6
6
  def clear
7
- cmd = Gem.win_platform? ? "cls" : "clear;"
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
@@ -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 ||= begin
27
- require "lumberjack"
28
- Lumberjack::Logger.new(
29
- options.fetch(:device) { $stderr },
30
- options
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 ||= Options.new(
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 = Options.new(options)
59
+ @options = Config.new(options)
65
60
  end
66
61
 
67
62
  # Assigns a log level
68
- extend Forwardable
69
- def_delegator :logger, :level=
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[:only]
180
- except = options[:except]
181
- plugin ||= calling_plugin_name
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 |plugin|
191
+ _filter(options[:plugin]) do
195
192
  reset_line if options[:reset]
196
- logger.send(method, message, plugin)
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 calling_plugin_name(depth = 2)
207
- name = %r{(guard\/[a-z_]*)(/[a-z_]*)?.rb:}i.match(caller[depth])
208
- return "Guard" unless name
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
@@ -1,3 +1,3 @@
1
1
  module Guard
2
- VERSION = "2.14.0"
2
+ VERSION = "2.14.1"
3
3
  end
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.0
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: 2016-05-19 00:00:00.000000000 Z
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.5.1
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: