guard 2.8.2 → 2.9.0

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.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +0 -7
  3. data/lib/guard.rb +220 -152
  4. data/lib/guard.rb.orig +213 -155
  5. data/lib/guard/aruba_adapter.rb +2 -2
  6. data/lib/guard/cli.rb +8 -13
  7. data/lib/guard/cli.rb.orig +12 -10
  8. data/lib/guard/commander.rb +15 -7
  9. data/lib/guard/commands/all.rb +3 -0
  10. data/lib/guard/commands/change.rb +3 -0
  11. data/lib/guard/commands/pause.rb +2 -0
  12. data/lib/guard/commands/reload.rb +4 -0
  13. data/lib/guard/commands/scope.rb +3 -0
  14. data/lib/guard/config.rb +24 -0
  15. data/lib/guard/deprecated/dsl.rb +45 -0
  16. data/lib/guard/deprecated/guard.rb +166 -0
  17. data/lib/guard/deprecated/guardfile.rb +84 -0
  18. data/lib/guard/dsl.rb +24 -13
  19. data/lib/guard/dsl.rb.orig +378 -0
  20. data/lib/guard/dsl_describer.rb +8 -2
  21. data/lib/guard/dsl_describer.rb.orig +11 -3
  22. data/lib/guard/guardfile.rb +32 -44
  23. data/lib/guard/guardfile/evaluator.rb +13 -6
  24. data/lib/guard/guardfile/generator.rb +4 -3
  25. data/lib/guard/interactor.rb +7 -3
  26. data/lib/guard/internals/debugging.rb +1 -0
  27. data/lib/guard/internals/environment.rb +93 -0
  28. data/lib/guard/internals/helpers.rb +13 -0
  29. data/lib/guard/internals/traps.rb +10 -0
  30. data/lib/guard/jobs/pry_wrapper.rb +4 -3
  31. data/lib/guard/jobs/sleep.rb +2 -0
  32. data/lib/guard/metadata.rb +190 -0
  33. data/lib/guard/notifier.rb +124 -99
  34. data/lib/guard/notifier.rb.orig +124 -99
  35. data/lib/guard/notifier/detected.rb +83 -0
  36. data/lib/guard/notifiers/emacs.rb +2 -1
  37. data/lib/guard/notifiers/tmux.rb +173 -177
  38. data/lib/guard/plugin/base.rb +2 -0
  39. data/lib/guard/plugin_util.rb +26 -32
  40. data/lib/guard/reevaluator.rb +3 -3
  41. data/lib/guard/reevaluator.rb.orig +22 -0
  42. data/lib/guard/runner.rb +1 -0
  43. data/lib/guard/session.rb +5 -0
  44. data/lib/guard/sheller.rb +2 -2
  45. data/lib/guard/templates/Guardfile +4 -0
  46. data/lib/guard/templates/Guardfile.orig +2 -0
  47. data/lib/guard/terminal.rb +1 -0
  48. data/lib/guard/ui.rb +4 -1
  49. data/lib/guard/version.rb +1 -1
  50. data/lib/guard/version.rb.orig +1 -1
  51. data/lib/guard/watcher.rb +3 -1
  52. data/lib/guard/watcher.rb.orig +122 -0
  53. data/man/guard.1 +1 -4
  54. data/man/guard.1.html +1 -4
  55. metadata +17 -25
  56. data/lib/guard/commander.rb.orig +0 -103
  57. data/lib/guard/commands/all.rb.orig +0 -36
  58. data/lib/guard/commands/reload.rb.orig +0 -34
  59. data/lib/guard/commands/scope.rb.orig +0 -36
  60. data/lib/guard/deprecated_methods.rb +0 -72
  61. data/lib/guard/deprecated_methods.rb.orig +0 -71
  62. data/lib/guard/deprecator.rb +0 -133
  63. data/lib/guard/deprecator.rb.orig +0 -206
  64. data/lib/guard/guard.rb +0 -100
  65. data/lib/guard/guard.rb.orig +0 -42
  66. data/lib/guard/guardfile.rb.orig +0 -43
  67. data/lib/guard/guardfile/evaluator.rb.orig +0 -275
  68. data/lib/guard/internals/debugging.rb.orig +0 -0
  69. data/lib/guard/internals/environment.rb.orig +0 -0
  70. data/lib/guard/internals/tracing.rb.orig +0 -0
  71. data/lib/guard/notifiers/base.rb.orig +0 -221
  72. data/lib/guard/notifiers/tmux.rb.orig +0 -339
  73. data/lib/guard/plugin_util.rb.orig +0 -186
  74. data/lib/guard/runner.rb.orig +0 -210
  75. data/lib/guard/setuper.rb +0 -359
  76. data/lib/guard/setuper.rb.orig +0 -395
  77. data/lib/guard/ui.rb.orig +0 -278
@@ -3,7 +3,8 @@ require "thor"
3
3
  require "guard"
4
4
  require "guard/version"
5
5
  require "guard/dsl_describer"
6
- require "guard/guardfile"
6
+ require "guard/guardfile/evaluator"
7
+ require "guard/guardfile/generator"
7
8
 
8
9
  module Guard
9
10
  # Facade for the Guard command line interface managed by
@@ -70,11 +71,6 @@ module Guard
70
71
  aliases: "-B",
71
72
  banner: "Turn off warning when Bundler is not present"
72
73
 
73
- method_option :show_deprecations,
74
- type: :boolean,
75
- default: false,
76
- banner: "Turn on deprecation warnings"
77
-
78
74
  # Listen options
79
75
  method_option :latency,
80
76
  type: :numeric,
@@ -169,17 +165,23 @@ module Guard
169
165
  _verify_bundler_presence unless options[:no_bundler_warning]
170
166
 
171
167
  ::Guard.reset_options(options) # Since UI.deprecated uses config
172
- ::Guard.reset_evaluator(options) # for initialize_all_templates
173
168
 
174
- ::Guard::Guardfile.create_guardfile(abort_on_existence: options[:bare])
169
+ generator = Guardfile::Generator.new(abort_on_existence: options[:bare])
170
+ generator.create_guardfile
171
+
172
+ # Note: this reset "hack" will be fixed after refactoring
173
+ ::Guard.reset_plugins
174
+
175
+ # Evaluate because it might have existed and creating was skipped
176
+ ::Guard::Guardfile::Evaluator.new(Guard.options).evaluate_guardfile
175
177
 
176
178
  return if options[:bare]
177
179
 
178
180
  if plugin_names.empty?
179
- ::Guard::Guardfile.initialize_all_templates
181
+ generator.initialize_all_templates
180
182
  else
181
183
  plugin_names.each do |plugin_name|
182
- ::Guard::Guardfile.initialize_template(plugin_name)
184
+ generator.initialize_template(plugin_name)
183
185
  end
184
186
  end
185
187
  end
@@ -1,3 +1,10 @@
1
+ require "listen"
2
+
3
+ require "guard/notifier"
4
+ require "guard/interactor"
5
+ require "guard/runner"
6
+ require "guard"
7
+
1
8
  module Guard
2
9
  # Commands supported by guard
3
10
  module Commander
@@ -22,13 +29,12 @@ module Guard
22
29
  def start(options = {})
23
30
  setup(options)
24
31
  ::Guard::UI.debug "Guard starts all plugins"
25
- runner.run(:start)
32
+ Guard::Runner.new.run(:start)
26
33
  listener.start
27
34
 
28
35
  watched = ::Guard.watchdirs.join("', '")
29
36
  ::Guard::UI.info "Guard is now watching at '#{ watched }'"
30
37
 
31
- # TODO: remove (left to avoid breaking too many specs)
32
38
  begin
33
39
  while interactor.foreground != :exit
34
40
  _process_queue while pending_changes?
@@ -44,8 +50,8 @@ module Guard
44
50
  listener.stop
45
51
  interactor.background
46
52
  ::Guard::UI.debug "Guard stops all plugins"
47
- runner.run(:stop)
48
- ::Guard::Notifier.turn_off
53
+ Guard::Runner.new.run(:stop)
54
+ ::Guard::Notifier.disconnect
49
55
  ::Guard::UI.info "Bye bye...", reset: true
50
56
  end
51
57
 
@@ -56,13 +62,14 @@ module Guard
56
62
  # @param [Hash] scopes hash with a Guard plugin or a group scope
57
63
  #
58
64
  def reload(scopes = {})
65
+ # TODO: guard reevaluator should probably handle all this
59
66
  ::Guard::UI.clear(force: true)
60
67
  ::Guard::UI.action_with_scopes("Reload", scopes)
61
68
 
62
69
  if scopes.empty?
63
- evaluator.reevaluate_guardfile
70
+ Guard::Guardfile::Evaluator.new(Guard.options).reevaluate_guardfile
64
71
  else
65
- runner.run(:reload, scopes)
72
+ Guard::Runner.new.run(:reload, scopes)
66
73
  end
67
74
  end
68
75
 
@@ -73,7 +80,7 @@ module Guard
73
80
  def run_all(scopes = {})
74
81
  ::Guard::UI.clear(force: true)
75
82
  ::Guard::UI.action_with_scopes("Run", scopes)
76
- runner.run(:run_all, scopes)
83
+ Guard::Runner.new.run(:run_all, scopes)
77
84
  end
78
85
 
79
86
  # Pause Guard listening to file changes.
@@ -93,4 +100,5 @@ module Guard
93
100
  ::Guard::DslDescriber.new(::Guard.options).show
94
101
  end
95
102
  end
103
+ extend Commander
96
104
  end
@@ -1,5 +1,8 @@
1
1
  # required for async_queue_add
2
2
  require "pry"
3
+
4
+ # TODO: remove this dependency
5
+ require "guard/interactor"
3
6
  require "guard"
4
7
 
5
8
  module Guard
@@ -1,5 +1,8 @@
1
1
  require "pry"
2
2
 
3
+ # TODO: remove
4
+ require "guard"
5
+
3
6
  module Guard
4
7
  module Commands
5
8
  class Change
@@ -1,5 +1,7 @@
1
1
  require "pry"
2
2
 
3
+ require "guard"
4
+
3
5
  module Guard
4
6
  module Commands
5
7
  class Pause
@@ -1,5 +1,9 @@
1
1
  require "pry"
2
2
 
3
+ # TODO: should not be necessary!
4
+ require "guard/interactor"
5
+ require "guard"
6
+
3
7
  module Guard
4
8
  module Commands
5
9
  class Reload
@@ -1,4 +1,6 @@
1
1
  require "pry"
2
+ require "guard/interactor"
3
+ require "guard"
2
4
 
3
5
  module Guard
4
6
  module Commands
@@ -27,6 +29,7 @@ module Guard
27
29
  return
28
30
  end
29
31
 
32
+ # TODO: provide a way for guard to know this was called from Pry
30
33
  ::Guard.setup_scope(scope)
31
34
  end
32
35
  end
@@ -0,0 +1,24 @@
1
+ require "guard/internals/environment"
2
+
3
+ module Guard
4
+ class Config
5
+ def strict?
6
+ _env.strict?
7
+ end
8
+
9
+ def silence_deprecations?
10
+ end
11
+
12
+ private
13
+
14
+ def _env
15
+ @env ||= _create_env
16
+ end
17
+
18
+ def _create_env
19
+ Internals::Environment.new("GUARD").tap do |env|
20
+ env.create_method(:strict?)
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,45 @@
1
+ require "guard/config"
2
+ fail "Deprecations disabled (strict mode)" if Guard::Config.new.strict?
3
+
4
+ module Guard
5
+ module Deprecated
6
+ module Dsl
7
+ def self.add_deprecated(dsl_klass)
8
+ dsl_klass.send(:extend, ClassMethods)
9
+ end
10
+
11
+ MORE_INFO_ON_UPGRADING_TO_GUARD_2 = <<-EOS.gsub(/^\s*/, "")
12
+ For more information on how to upgrade for Guard 2.0, please head over
13
+ to: https://github.com/guard/guard/wiki/Upgrading-to-Guard-2.0%s
14
+ EOS
15
+
16
+ module ClassMethods
17
+ # @deprecated Use
18
+ # `Guard::Guardfile::Evaluator.new(options).evaluate_guardfile`
19
+ # instead.
20
+ #
21
+ # @see https://github.com/guard/guard/wiki/Upgrading-to-Guard-2.0 How
22
+ # to upgrade for Guard 2.0
23
+ #
24
+ EVALUATE_GUARDFILE = <<-EOS.gsub(/^\s*/, "")
25
+ Starting with Guard 2.0 'Guard::Dsl.evaluate_guardfile(options)' is
26
+ deprecated.
27
+
28
+ Please use
29
+ 'Guard::Guardfile::Evaluator.new(options).evaluate_guardfile'
30
+ instead.
31
+
32
+ #{MORE_INFO_ON_UPGRADING_TO_GUARD_2 % "#deprecated-methods-1"}
33
+ EOS
34
+
35
+ def evaluate_guardfile(options = {})
36
+ require "guard/guardfile/evaluator"
37
+ require "guard/ui"
38
+
39
+ UI.deprecation(EVALUATE_GUARDFILE)
40
+ ::Guard::Guardfile::Evaluator.new(options).evaluate_guardfile
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,166 @@
1
+ require "guard/config"
2
+ fail "Deprecations disabled (strict mode)" if Guard::Config.new.strict?
3
+
4
+ require "guard/ui"
5
+ require "guard/plugin_util"
6
+ require "guard/guardfile/evaluator"
7
+
8
+ module Guard
9
+ # @deprecated Every method in this module is deprecated
10
+ module Deprecated
11
+ module Guard
12
+ def self.add_deprecated(klass)
13
+ klass.send(:extend, ClassMethods)
14
+ end
15
+
16
+ module ClassMethods
17
+ MORE_INFO_ON_UPGRADING_TO_GUARD_2 = <<-EOS.gsub(/^\s*/, "")
18
+ For more information on how to upgrade for Guard 2.0, please head
19
+ over to: https://github.com/guard/guard/wiki/Upgrading-to-Guard-2.0%s
20
+ EOS
21
+
22
+ # @deprecated Use `Guard.plugins(filter)` instead.
23
+ #
24
+ # @see https://github.com/guard/guard/wiki/Upgrading-to-Guard-2.0 How to
25
+ # upgrade for Guard 2.0
26
+ #
27
+ GUARDS = <<-EOS.gsub(/^\s*/, "")
28
+ Starting with Guard 2.0 'Guard.guards(filter)' is deprecated.
29
+
30
+ Please use 'Guard.plugins(filter)' instead.
31
+
32
+ #{MORE_INFO_ON_UPGRADING_TO_GUARD_2 % "#deprecated-methods"}
33
+ EOS
34
+
35
+ def guards(filter = nil)
36
+ ::Guard::UI.deprecation(GUARDS)
37
+ plugins(filter)
38
+ end
39
+
40
+ # @deprecated Use `Guard.add_plugin(name, options = {})` instead.
41
+ #
42
+ # @see https://github.com/guard/guard/wiki/Upgrading-to-Guard-2.0 How to
43
+ # upgrade for Guard 2.0
44
+ #
45
+ ADD_GUARD = <<-EOS.gsub(/^\s*/, "")
46
+ Starting with Guard 2.0 'Guard.add_guard(name, options = {})' is
47
+ deprecated.
48
+
49
+ Please use 'Guard.add_plugin(name, options = {})' instead.
50
+
51
+ #{MORE_INFO_ON_UPGRADING_TO_GUARD_2 % "#deprecated-methods"}
52
+ EOS
53
+
54
+ def add_guard(*args)
55
+ ::Guard::UI.deprecation(ADD_GUARD)
56
+ add_plugin(*args)
57
+ end
58
+
59
+ # @deprecated Use
60
+ # `Guard::PluginUtil.new(name).plugin_class(fail_gracefully:
61
+ # fail_gracefully)` instead.
62
+ #
63
+ # @see https://github.com/guard/guard/wiki/Upgrading-to-Guard-2.0 How to
64
+ # upgrade for Guard 2.0
65
+ #
66
+ GET_GUARD_CLASS = <<-EOS.gsub(/^\s*/, "")
67
+ Starting with Guard 2.0 'Guard.get_guard_class(name, fail_gracefully
68
+ = false)' is deprecated and is now always on.
69
+
70
+ Please use 'Guard::PluginUtil.new(name).plugin_class(fail_gracefully:
71
+ fail_gracefully)' instead.
72
+
73
+ #{MORE_INFO_ON_UPGRADING_TO_GUARD_2 % "#deprecated-methods"}
74
+ EOS
75
+
76
+ def get_guard_class(name, fail_gracefully = false)
77
+ UI.deprecation(GET_GUARD_CLASS)
78
+ PluginUtil.new(name).plugin_class(fail_gracefully: fail_gracefully)
79
+ end
80
+
81
+ # @deprecated Use `Guard::PluginUtil.new(name).plugin_location` instead.
82
+ #
83
+ # @see https://github.com/guard/guard/wiki/Upgrading-to-Guard-2.0 How to
84
+ # upgrade for Guard 2.0
85
+ #
86
+ LOCATE_GUARD = <<-EOS.gsub(/^\s*/, "")
87
+ Starting with Guard 2.0 'Guard.locate_guard(name)' is deprecated.
88
+
89
+ Please use 'Guard::PluginUtil.new(name).plugin_location' instead.
90
+
91
+ #{MORE_INFO_ON_UPGRADING_TO_GUARD_2 % "#deprecated-methods"}
92
+ EOS
93
+
94
+ def locate_guard(name)
95
+ UI.deprecation(LOCATE_GUARD)
96
+ PluginUtil.new(name).plugin_location
97
+ end
98
+
99
+ # @deprecated Use `Guard::PluginUtil.plugin_names` instead.
100
+ #
101
+ # @see https://github.com/guard/guard/wiki/Upgrading-to-Guard-2.0 How to
102
+ # upgrade for Guard 2.0
103
+ #
104
+ # Deprecator message for the `Guard.guard_gem_names` method
105
+ GUARD_GEM_NAMES = <<-EOS.gsub(/^\s*/, "")
106
+ Starting with Guard 2.0 'Guard.guard_gem_names' is deprecated.
107
+
108
+ Please use 'Guard::PluginUtil.plugin_names' instead.
109
+
110
+ #{MORE_INFO_ON_UPGRADING_TO_GUARD_2 % "#deprecated-methods"}
111
+ EOS
112
+
113
+ def guard_gem_names
114
+ UI.deprecation(GUARD_GEM_NAMES)
115
+ PluginUtil.plugin_names
116
+ end
117
+
118
+ RUNNING = <<-EOS.gsub(/^\s*/, "")
119
+ Starting with Guard 2.7.1 it was discovered that Guard.running was
120
+ never initialized or used internally.
121
+ EOS
122
+
123
+ def running
124
+ UI.deprecation(RUNNING)
125
+ nil
126
+ end
127
+
128
+ LOCK = <<-EOS.gsub(/^\s*/, "")
129
+ Starting with Guard 2.7.1 it was discovered that this accessor was
130
+ never initialized or used internally.
131
+ EOS
132
+ def lock
133
+ UI.deprecation(LOCK)
134
+ end
135
+
136
+ EVALUATOR = <<-EOS.gsub(/^\s*/, "")
137
+ Starting with Guard 2.8.2 this method shouldn't be used
138
+ EOS
139
+
140
+ def evaluator
141
+ # TODO: probably deprecate once it isn't used internally
142
+ # TODO: this will be changed to the following when scope is reworked
143
+ UI.deprecation(EVALUATOR)
144
+ ::Guard::Guardfile::Evaluator.new(::Guard.options)
145
+ end
146
+
147
+ RESET_EVALUATOR = <<-EOS.gsub(/^\s*/, "")
148
+ Starting with Guard 2.8.2 this method shouldn't be used
149
+ EOS
150
+
151
+ def reset_evaluator(_options)
152
+ UI.deprecation(RESET_EVALUATOR)
153
+ end
154
+
155
+ RUNNER = <<-EOS.gsub(/^\s*/, "")
156
+ Starting with Guard 2.8.2 this method shouldn't be used
157
+ EOS
158
+
159
+ def runner
160
+ UI.deprecation(RUNNER)
161
+ ::Guard::Runner.new
162
+ end
163
+ end
164
+ end
165
+ end
166
+ end
@@ -0,0 +1,84 @@
1
+ require "guard/config"
2
+ fail "Deprecations disabled (strict mode)" if Guard::Config.new.strict?
3
+
4
+ require "guard/guardfile/generator"
5
+
6
+ module Guard
7
+ module Deprecated
8
+ module Guardfile
9
+ def self.add_deprecated(dsl_klass)
10
+ dsl_klass.send(:extend, ClassMethods)
11
+ end
12
+
13
+ module ClassMethods
14
+ MORE_INFO_ON_UPGRADING_TO_GUARD_2 = <<-EOS.gsub(/^\s*/, "")
15
+ For more information on how to upgrade for Guard 2.0, please head
16
+ over to: https://github.com/guard/guard/wiki/Upgrading-to-Guard-2.0%s
17
+ EOS
18
+ # @deprecated Use {Guardfile::Generator#create_guardfile} instead.
19
+ #
20
+ # @see https://github.com/guard/guard/wiki/Upgrading-to-Guard-2.0 How to
21
+ # upgrade for Guard 2.0
22
+ #
23
+ CREATE_GUARDFILE = <<-EOS.gsub(/^\s*/, "")
24
+ Starting with Guard 2.0 'Guard::Guardfile.create_guardfile(options)'
25
+ is deprecated.
26
+
27
+ Please use 'Guard::Guardfile::Generator.new(options).create_guardfile'
28
+ instead.
29
+
30
+ #{MORE_INFO_ON_UPGRADING_TO_GUARD_2 % "#deprecated-methods-2"}
31
+ EOS
32
+
33
+ def create_guardfile(options = {})
34
+ UI.deprecation(CREATE_GUARDFILE)
35
+ ::Guard::Guardfile::Generator.new(options).create_guardfile
36
+ end
37
+
38
+ # @deprecated Use {Guardfile::Generator#initialize_template} instead.
39
+ #
40
+ # @see https://github.com/guard/guard/wiki/Upgrading-to-Guard-2.0 How to
41
+ # upgrade for Guard 2.0
42
+ #
43
+ # Deprecator message for the `Guardfile.initialize_template` method
44
+ INITIALIZE_TEMPLATE = <<-EOS.gsub(/^\s*/, "")
45
+ Starting with Guard 2.0
46
+ 'Guard::Guardfile.initialize_template(plugin_name)' is deprecated.
47
+
48
+ Please use
49
+ 'Guard::Guardfile::Generator.new.initialize_template(plugin_name)'
50
+ instead.
51
+
52
+ #{MORE_INFO_ON_UPGRADING_TO_GUARD_2 % "#deprecated-methods-2"}
53
+ EOS
54
+
55
+ def initialize_template(plugin_name)
56
+ UI.deprecation(INITIALIZE_TEMPLATE)
57
+ ::Guard::Guardfile::Generator.new.initialize_template(plugin_name)
58
+ end
59
+
60
+ # @deprecated Use {Guardfile::Generator#initialize_all_templates}
61
+ # instead.
62
+ #
63
+ # @see https://github.com/guard/guard/wiki/Upgrading-to-Guard-2.0 How to
64
+ # upgrade for Guard 2.0
65
+ #
66
+ # Deprecator message for the `Guardfile.initialize_all_templates` method
67
+ INITIALIZE_ALL_TEMPLATES = <<-EOS.gsub(/^\s*/, "")
68
+ Starting with Guard 2.0 'Guard::Guardfile.initialize_all_templates'
69
+ is deprecated.
70
+
71
+ Please use 'Guard::Guardfile::Generator.new.initialize_all_templates'
72
+ instead.
73
+
74
+ #{MORE_INFO_ON_UPGRADING_TO_GUARD_2 % "#deprecated-methods-2"}
75
+ EOS
76
+
77
+ def initialize_all_templates
78
+ UI.deprecation(INITIALIZE_ALL_TEMPLATES)
79
+ ::Guard::Guardfile::Generator.new.initialize_all_templates
80
+ end
81
+ end
82
+ end
83
+ end
84
+ end