guard 2.10.5 → 2.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/lib/guard.rb +0 -3
  3. data/lib/guard/aruba_adapter.rb +6 -6
  4. data/lib/guard/cli.rb +5 -0
  5. data/lib/guard/commander.rb +1 -1
  6. data/lib/guard/commands/all.rb +2 -2
  7. data/lib/guard/commands/notification.rb +1 -1
  8. data/lib/guard/commands/reload.rb +2 -2
  9. data/lib/guard/commands/show.rb +1 -1
  10. data/lib/guard/deprecated/evaluator.rb +3 -1
  11. data/lib/guard/deprecated/guard.rb +57 -2
  12. data/lib/guard/dsl.rb +2 -3
  13. data/lib/guard/dsl_describer.rb +8 -20
  14. data/lib/guard/guardfile/evaluator.rb +5 -5
  15. data/lib/guard/guardfile/generator.rb +3 -3
  16. data/lib/guard/internals/debugging.rb +5 -5
  17. data/lib/guard/internals/session.rb +19 -8
  18. data/lib/guard/internals/state.rb +0 -13
  19. data/lib/guard/jobs/pry_wrapper.rb +5 -5
  20. data/lib/guard/notifier.rb +43 -219
  21. data/lib/guard/plugin_util.rb +1 -1
  22. data/lib/guard/terminal.rb +3 -2
  23. data/lib/guard/ui.rb +7 -2
  24. data/lib/guard/version.rb +1 -1
  25. data/lib/guard/watcher.rb +3 -3
  26. metadata +30 -15
  27. data/lib/guard/notifier/detected.rb +0 -87
  28. data/lib/guard/notifiers/base.rb +0 -221
  29. data/lib/guard/notifiers/emacs.rb +0 -99
  30. data/lib/guard/notifiers/file_notifier.rb +0 -54
  31. data/lib/guard/notifiers/gntp.rb +0 -111
  32. data/lib/guard/notifiers/growl.rb +0 -104
  33. data/lib/guard/notifiers/libnotify.rb +0 -86
  34. data/lib/guard/notifiers/notifysend.rb +0 -110
  35. data/lib/guard/notifiers/rb_notifu.rb +0 -100
  36. data/lib/guard/notifiers/terminal_notifier.rb +0 -90
  37. data/lib/guard/notifiers/terminal_title.rb +0 -31
  38. data/lib/guard/notifiers/tmux.rb +0 -335
  39. data/lib/guard/sheller.rb +0 -143
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: df6dd8c3a8afddbe828bc11ed09f1586ebd6a5fa
4
- data.tar.gz: 64d5137c8119bdc11273ba20aa3592e228dbaf3b
3
+ metadata.gz: 209b3d3d20d2fda90cb9b5e5f75a2d529f48897f
4
+ data.tar.gz: 8df8704e331f6484c83e004a14c7e885bb1fadd1
5
5
  SHA512:
6
- metadata.gz: 19e7f4548e9b3d36560ce126b8bc3df6a95ac789d82a9bf811c00f88f9fae2f9b2c7dff248b73a8f70a1785471fde1dd28932486e13497cc9715270412431a25
7
- data.tar.gz: 5893cb11c600e01bb7e999255696ce081a62389abd2d20ac5031131f03aa82f7d990e837c5dd3676d699391c99e6791a2bff7f03f0c153713e1926e45ae01972
6
+ metadata.gz: 48954718bc20698fbe55d2dd994f656d358fd34268aa559044cd1e5d00257b6d2a3983ec146cb6b2f3be8e1cb0ae63fc3b9ccc37c662416687a191df39adf216
7
+ data.tar.gz: cf36a4710fbe3bc24b91f4991f6f80fb046bd143b4fa8304878da13bb979610ca9cb9d435eac945a63e37fa43acbb40bbfb3f91edad138ebb0ba21107e6ad68a
@@ -133,9 +133,6 @@ module Guard
133
133
  evaluator = Guardfile::Evaluator.new(options)
134
134
  evaluator.evaluate
135
135
 
136
- # TODO: remove this workaround when options are removed
137
- state.session.clearing(state.session.options[:clear])
138
-
139
136
  UI.reset_and_clear
140
137
 
141
138
  msg = "No plugins found in Guardfile, please add at least one."
@@ -11,7 +11,7 @@ module Guard
11
11
  @kernel = kernel
12
12
 
13
13
  if ENV["INSIDE_ARUBA_TEST"] == "1"
14
- ::Guard::UI.options = ::Guard::UI.options.merge(flush_seconds: 0)
14
+ UI.options = UI.options.merge(flush_seconds: 0)
15
15
  end
16
16
  end
17
17
 
@@ -29,7 +29,7 @@ module Guard
29
29
  $stdout = @stdout
30
30
 
31
31
  # Run our normal Thor app the way we know and love.
32
- ::Guard::CLI.start(@argv)
32
+ CLI.start(@argv)
33
33
 
34
34
  # Thor::Base#start does not have a return value, assume
35
35
  # success if no exception is raised.
@@ -45,10 +45,10 @@ module Guard
45
45
  e.status
46
46
  ensure
47
47
  # flush the logger so the output doesn't appear in next CLI invocation
48
- ::Guard.listener.stop if ::Guard.listener
49
- ::Guard::UI.logger.flush
50
- ::Guard::UI.logger.close
51
- ::Guard::UI.reset_logger
48
+ Guard.listener.stop if Guard.listener
49
+ UI.logger.flush
50
+ UI.logger.close
51
+ UI.reset_logger
52
52
 
53
53
  # ...then we put them back.
54
54
  $stderr = STDERR
@@ -96,6 +96,11 @@ module Guard
96
96
  banner: "Specify a network address to Listen on for "\
97
97
  "file change events (e.g. for use in VMs)"
98
98
 
99
+ def self.help(shell, subcommand = false)
100
+ super
101
+ command_help(shell, default_task)
102
+ end
103
+
99
104
  # Start Guard by initializing the defined Guard plugins and watch the file
100
105
  # system.
101
106
  #
@@ -79,7 +79,7 @@ module Guard
79
79
  def run_all(scopes = {})
80
80
  UI.clear(force: true)
81
81
  UI.action_with_scopes("Run", scopes)
82
- Guard::Runner.new.run(:run_all, scopes)
82
+ Runner.new.run(:run_all, scopes)
83
83
  end
84
84
 
85
85
  # Pause Guard listening to file changes.
@@ -21,14 +21,14 @@ module Guard
21
21
  BANNER
22
22
 
23
23
  def process(*entries)
24
- scopes, unknown = ::Guard.state.session.convert_scope(entries)
24
+ scopes, unknown = Guard.state.session.convert_scope(entries)
25
25
 
26
26
  unless unknown.empty?
27
27
  output.puts "Unknown scopes: #{ unknown.join(", ") }"
28
28
  return
29
29
  end
30
30
 
31
- ::Guard.async_queue_add([:guard_run_all, scopes])
31
+ Guard.async_queue_add([:guard_run_all, scopes])
32
32
  end
33
33
  end
34
34
  end
@@ -17,7 +17,7 @@ module Guard
17
17
  BANNER
18
18
 
19
19
  def process
20
- ::Guard::Notifier.toggle
20
+ Notifier.toggle
21
21
  end
22
22
  end
23
23
  end
@@ -20,14 +20,14 @@ module Guard
20
20
  BANNER
21
21
 
22
22
  def process(*entries)
23
- scopes, unknown = ::Guard.state.session.convert_scope(entries)
23
+ scopes, unknown = Guard.state.session.convert_scope(entries)
24
24
 
25
25
  unless unknown.empty?
26
26
  output.puts "Unknown scopes: #{ unknown.join(", ") }"
27
27
  return
28
28
  end
29
29
 
30
- ::Guard.async_queue_add([:guard_reload, scopes])
30
+ Guard.async_queue_add([:guard_reload, scopes])
31
31
  end
32
32
  end
33
33
  end
@@ -15,7 +15,7 @@ module Guard
15
15
  BANNER
16
16
 
17
17
  def process
18
- ::Guard.async_queue_add([:guard_show])
18
+ Guard.async_queue_add([:guard_show])
19
19
  end
20
20
  end
21
21
  end
@@ -18,6 +18,9 @@ module Guard
18
18
  REEVALUATE_GUARDFILE = <<-EOS.gsub(/^\s*/, "")
19
19
  Starting with Guard 2.8.3 'Guard::Evaluator#reevaluate_guardfile' is
20
20
  deprecated in favor of '#reevaluate'.
21
+
22
+ NOTE: this method no longer does anything since it could not be
23
+ implemented reliably.
21
24
  EOS
22
25
 
23
26
  def evaluate_guardfile
@@ -30,7 +33,6 @@ module Guard
30
33
  # guard's deprecations require us
31
34
  require "guard"
32
35
  UI.deprecation(REEVALUATE_GUARDFILE)
33
- ::Guard.state.reset_session { evaluate }
34
36
  end
35
37
  end
36
38
  end
@@ -30,7 +30,7 @@ module Guard
30
30
 
31
31
  Please use 'Guard.plugins(filter)' instead.
32
32
 
33
- #{MORE_INFO_ON_UPGRADING_TO_GUARD_2 % "#deprecated-methods"}
33
+ #{MORE_INFO_ON_UPGRADING_TO_GUARD_2 % "#deprecated-methods"}
34
34
  EOS
35
35
 
36
36
  def guards(filter = nil)
@@ -192,7 +192,62 @@ module Guard
192
192
 
193
193
  def options
194
194
  UI.deprecation(OPTIONS)
195
- ::Guard.state.session.options
195
+
196
+ Class.new(Hash) do
197
+ def initialize
198
+ super(to_hash)
199
+ end
200
+
201
+ def to_hash
202
+ session = ::Guard.state.session
203
+ {
204
+ clear: session.clearing?,
205
+ debug: session.debug?,
206
+ watchdir: Array(session.watchdirs).map(&:to_s),
207
+ notify: session.notify_options[:notify],
208
+ no_interactions: (session.interactor_name == :sleep)
209
+ }
210
+ end
211
+
212
+ def to_a
213
+ to_hash.to_a
214
+ end
215
+
216
+ def fetch(key, *args)
217
+ hash = to_hash
218
+ verify_key!(hash, key)
219
+ hash.fetch(key, *args)
220
+ end
221
+
222
+ def []=(key, value)
223
+ case key
224
+ when :clear
225
+ ::Guard.state.session.clearing(value)
226
+ else
227
+ msg = "Oops! Guard.option[%s]= is unhandled or unsupported." \
228
+ "Please file an issue if you rely on this option working."
229
+ fail NotImplementedError, format(msg, key)
230
+ end
231
+ end
232
+
233
+ def keys
234
+ to_hash.keys
235
+ end
236
+
237
+ def include?(value)
238
+ keys.include? value
239
+ end
240
+
241
+ private
242
+
243
+ def verify_key!(hash, key)
244
+ return if hash.key?(key)
245
+ msg = "Oops! Guard.option[%s] is unhandled or unsupported." \
246
+ "Please file an issue if you rely on this option working."
247
+ fail NotImplementedError, format(msg, key)
248
+ end
249
+
250
+ end.new
196
251
  end
197
252
 
198
253
  ADD_GROUP = <<-EOS.gsub(/^\s*/, "")
@@ -72,9 +72,8 @@ module Guard
72
72
  #
73
73
  # @see Guard::Notifier for available notifier and its options.
74
74
  #
75
- def notification(notifier, options = {})
76
- # TODO: remove dependency on Notifier (let session handle this)
77
- Notifier.add(notifier.to_sym, options.merge(silent: false))
75
+ def notification(notifier, opts = {})
76
+ Guard.state.session.guardfile_notification = { notifier.to_sym => opts }
78
77
  end
79
78
 
80
79
  # Sets the interactor options or disable the interactor.
@@ -107,22 +107,20 @@ module Guard
107
107
  # @see CLI#show
108
108
  #
109
109
  def notifiers
110
- supported = ::Guard::Notifier::SUPPORTED
111
- Notifier.connect(notify: false)
112
- detected = Notifier.notifiers
110
+ supported = Notifier.supported
111
+ Notifier.connect(notify: true, silent: true)
112
+ detected = Notifier.detected
113
113
  Notifier.disconnect
114
114
 
115
- merged_notifiers = supported.inject(:merge)
116
- final_rows = merged_notifiers.each_with_object([]) do |definition, rows|
115
+ detected_names = detected.map { |item| item[:name] }
116
+
117
+ final_rows = supported.each_with_object([]) do |(name, _), rows|
118
+ available = detected_names.include?(name) ? "✔" : "✘"
117
119
 
118
- name = definition[0]
119
- clazz = definition[1]
120
- available = clazz.available?(silent: true) ? "✔" : "✘"
121
120
  notifier = detected.detect { |n| n[:name] == name }
122
121
  used = notifier ? "✔" : "✘"
123
122
 
124
- options = _merge_options(clazz, notifier)
125
- options.delete(:silent)
123
+ options = notifier ? notifier[:options] : {}
126
124
 
127
125
  if options.empty?
128
126
  rows << :split
@@ -149,16 +147,6 @@ module Guard
149
147
 
150
148
  private
151
149
 
152
- def _merge_options(klass, notifier)
153
- notify_options = notifier ? notifier[:options] : {}
154
-
155
- if klass.const_defined?(:DEFAULTS)
156
- klass.const_get(:DEFAULTS).merge(notify_options)
157
- else
158
- notify_options
159
- end
160
- end
161
-
162
150
  def _add_row(rows, name, available, used, option, value)
163
151
  rows << {
164
152
  Name: name,
@@ -141,7 +141,7 @@ module Guard
141
141
  def _instance_eval_guardfile(contents)
142
142
  Dsl.new.evaluate(contents, @guardfile_path || "", 1)
143
143
  rescue => ex
144
- ::Guard::UI.error "Invalid Guardfile, original error is:\n#{ $! }"
144
+ UI.error "Invalid Guardfile, original error is:\n#{ $! }"
145
145
  raise ex
146
146
  end
147
147
 
@@ -163,7 +163,7 @@ module Guard
163
163
  @source = :inline
164
164
  @guardfile_contents = options[:guardfile_contents]
165
165
 
166
- ::Guard::UI.info "Using inline Guardfile."
166
+ UI.info "Using inline Guardfile."
167
167
  true
168
168
  end
169
169
 
@@ -193,9 +193,9 @@ module Guard
193
193
  rescue Errno::ENOENT
194
194
  fail
195
195
  rescue SystemCallError => e
196
- ::Guard::UI.error "Error reading file #{full_path}:"
197
- ::Guard::UI.error e.inspect
198
- ::Guard::UI.error e.backtrace
196
+ UI.error "Error reading file #{full_path}:"
197
+ UI.error e.inspect
198
+ UI.error e.backtrace
199
199
  abort
200
200
  end
201
201
 
@@ -64,7 +64,7 @@ module Guard
64
64
  def initialize_template(plugin_name)
65
65
  guardfile = Pathname("Guardfile")
66
66
 
67
- plugin_util = ::Guard::PluginUtil.new(plugin_name)
67
+ plugin_util = PluginUtil.new(plugin_name)
68
68
  # TODO: change to "valid?" method
69
69
  if plugin_util.plugin_class(fail_gracefully: true)
70
70
  plugin_util.add_to_guardfile
@@ -91,13 +91,13 @@ module Guard
91
91
  # @see Guard::CLI#init
92
92
  #
93
93
  def initialize_all_templates
94
- ::Guard::PluginUtil.plugin_names.each { |g| initialize_template(g) }
94
+ PluginUtil.plugin_names.each { |g| initialize_template(g) }
95
95
  end
96
96
 
97
97
  private
98
98
 
99
99
  def _ui(*args)
100
- ::Guard::UI.send(*args)
100
+ UI.send(*args)
101
101
  end
102
102
  end
103
103
  end
@@ -28,7 +28,7 @@ module Guard
28
28
 
29
29
  Thread.abort_on_exception = true
30
30
 
31
- ::Guard::UI.level = Logger::DEBUG
31
+ UI.level = Logger::DEBUG
32
32
 
33
33
  TRACES.each { |mod, meth| _trace(mod, meth, &method(:_notify)) }
34
34
  @traced = true
@@ -36,14 +36,14 @@ module Guard
36
36
 
37
37
  def stop
38
38
  return unless @started ||= false
39
- ::Guard::UI.level = Logger::INFO
39
+ UI.level = Logger::INFO
40
40
  _reset
41
41
  end
42
42
 
43
43
  private
44
44
 
45
45
  def _notify(*args)
46
- ::Guard::UI.debug "Command execution: #{args.join(" ")}"
46
+ UI.debug "Command execution: #{args.join(" ")}"
47
47
  end
48
48
 
49
49
  # reset singleton - called by tests
@@ -55,11 +55,11 @@ module Guard
55
55
  end
56
56
 
57
57
  def _trace(mod, meth, &block)
58
- ::Guard::Internals::Tracing.trace(mod, meth, &block)
58
+ Tracing.trace(mod, meth, &block)
59
59
  end
60
60
 
61
61
  def _untrace(mod, meth)
62
- ::Guard::Internals::Tracing.untrace(mod, meth)
62
+ Tracing.untrace(mod, meth)
63
63
  end
64
64
  end
65
65
  end
@@ -9,7 +9,6 @@ module Guard
9
9
  # TODO: split into a commandline class and session (plugins, groups)
10
10
  # TODO: swap session and metadata
11
11
  class Session
12
- attr_reader :options
13
12
  attr_reader :plugins
14
13
  attr_reader :groups
15
14
 
@@ -68,6 +67,8 @@ module Guard
68
67
  @guardfile_group_scope = []
69
68
  @guardfile_ignore = []
70
69
  @guardfile_ignore_bang = []
70
+
71
+ @guardfile_notifier_options = {}
71
72
  end
72
73
 
73
74
  def guardfile_scope(scope)
@@ -120,12 +121,12 @@ module Guard
120
121
  end
121
122
 
122
123
  def listener_args
123
- if options[:listen_on]
124
- [:on, options[:listen_on]]
124
+ if @options[:listen_on]
125
+ [:on, @options[:listen_on]]
125
126
  else
126
127
  listener_options = {}
127
128
  [:latency, :force_polling, :wait_for_delay].each do |option|
128
- listener_options[option] = options[option] if options[option]
129
+ listener_options[option] = @options[option] if @options[option]
129
130
  end
130
131
  expanded_watchdirs = watchdirs.map { |dir| File.expand_path dir }
131
132
  [:to, *expanded_watchdirs, listener_options]
@@ -133,16 +134,26 @@ module Guard
133
134
  end
134
135
 
135
136
  def evaluator_options
136
- opts = { guardfile: options[:guardfile] }
137
+ opts = { guardfile: @options[:guardfile] }
137
138
  # TODO: deprecate :guardfile_contents
138
- if options[:guardfile_contents]
139
- opts[:contents] = options[:guardfile_contents]
139
+ if @options[:guardfile_contents]
140
+ opts[:contents] = @options[:guardfile_contents]
140
141
  end
141
142
  opts
142
143
  end
143
144
 
144
145
  def notify_options
145
- { notify: @options[:notify] }
146
+ names = @guardfile_notifier_options.keys
147
+ return { notify: false } if names.include?(:off)
148
+
149
+ {
150
+ notify: @options[:notify],
151
+ notifiers: @guardfile_notifier_options
152
+ }
153
+ end
154
+
155
+ def guardfile_notification=(config)
156
+ @guardfile_notifier_options.merge!(config)
146
157
  end
147
158
 
148
159
  def interactor_name
@@ -20,19 +20,6 @@ module Guard
20
20
 
21
21
  attr_reader :scope
22
22
  attr_reader :session
23
-
24
- # @private api
25
- # TODO: REMOVE!
26
- def reset_session(&block)
27
- Runner.new.run(:stop)
28
- Notifier.disconnect
29
- options = @session.options.dup
30
- @session = Session.new(options)
31
- block.call
32
- Runner.new.run(:start)
33
- ensure
34
- Notifier.connect(session.notify_options)
35
- end
36
23
  end
37
24
  end
38
25
  end