guard 2.8.2 → 2.9.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -1,103 +0,0 @@
1
- module Guard
2
- # Commands supported by guard
3
- module Commander
4
- # Start Guard by evaluating the `Guardfile`, initializing declared Guard
5
- # plugins and starting the available file change listener.
6
- # Main method for Guard that is called from the CLI when Guard starts.
7
- #
8
- # - Setup Guard internals
9
- # - Evaluate the `Guardfile`
10
- # - Configure Notifiers
11
- # - Initialize the declared Guard plugins
12
- # - Start the available file change listener
13
- #
14
- # @option options [Boolean] clear if auto clear the UI should be done
15
- # @option options [Boolean] notify if system notifications should be shown
16
- # @option options [Boolean] debug if debug output should be shown
17
- # @option options [Array<String>] group the list of groups to start
18
- # @option options [String] watchdir the director to watch
19
- # @option options [String] guardfile the path to the Guardfile
20
- # @see CLI#start
21
- #
22
- def start(options = {})
23
- setup(options)
24
- ::Guard::UI.debug "Guard starts all plugins"
25
- runner.run(:start)
26
- listener.start
27
- <<<<<<< HEAD
28
-
29
- watched = ::Guard.watchdirs.join("', '")
30
- ::Guard::UI.info "Guard is now watching at '#{ watched }'"
31
- =======
32
- ::Guard::UI.info "Guard is now watching at '#{ ::Guard.watchdirs.join "', '" }'"
33
- >>>>>>> origin/api_safe_refactoring
34
-
35
- _interactor_loop
36
- end
37
-
38
- # TODO: refactor (left to avoid breaking too many specs)
39
- def stop
40
- listener.stop
41
- interactor.background
42
- ::Guard::UI.debug "Guard stops all plugins"
43
- runner.run(:stop)
44
- ::Guard::Notifier.turn_off
45
- ::Guard::UI.info "Bye bye...", reset: true
46
- end
47
-
48
- # Reload Guardfile and all Guard plugins currently enabled.
49
- # If no scope is given, then the Guardfile will be re-evaluated,
50
- # which results in a stop/start, which makes the reload obsolete.
51
- #
52
- # @param [Hash] scopes hash with a Guard plugin or a group scope
53
- #
54
- def reload(scopes = {})
55
- ::Guard::UI.clear(force: true)
56
- ::Guard::UI.action_with_scopes("Reload", scopes)
57
-
58
- if scopes.empty?
59
- evaluator.reevaluate_guardfile
60
- else
61
- runner.run(:reload, scopes)
62
- end
63
- end
64
-
65
- # Trigger `run_all` on all Guard plugins currently enabled.
66
- #
67
- # @param [Hash] scopes hash with a Guard plugin or a group scope
68
- #
69
- def run_all(scopes = {})
70
- ::Guard::UI.clear(force: true)
71
- ::Guard::UI.action_with_scopes("Run", scopes)
72
- runner.run(:run_all, scopes)
73
- end
74
-
75
- # Pause Guard listening to file changes.
76
- #
77
- def pause(expected = nil)
78
- paused = listener.paused?
79
- states = { paused: true, unpaused: false, toggle: !paused }
80
- pause = states[expected || :toggle]
81
- fail ArgumentError, "invalid mode: #{expected.inspect}" if pause.nil?
82
- return if pause == paused
83
-
84
- listener.send(pause ? :pause : :unpause)
85
- UI.info "File modification listening is now #{pause.to_s.upcase}"
86
- end
87
-
88
- def show
89
- ::Guard::DslDescriber.new(::Guard.options).show
90
- end
91
-
92
- private
93
-
94
- # TODO: remove (left to avoid breaking too many specs)
95
- def _interactor_loop
96
- while interactor.foreground != :exit
97
- _process_queue while pending_changes?
98
- end
99
- rescue Interrupt
100
- stop
101
- end
102
- end
103
- end
@@ -1,36 +0,0 @@
1
- # required for async_queue_add
2
- require "pry"
3
- require "guard"
4
-
5
- module Guard
6
- module Commands
7
- class All
8
- def self.import
9
- Pry::Commands.create_command "all" do
10
- group "Guard"
11
- description "Run all plugins."
12
-
13
- banner <<-BANNER
14
- Usage: all <scope>
15
-
16
- Run the Guard plugin `run_all` action.
17
-
18
- You may want to specify an optional scope to the action,
19
- either the name of a Guard plugin or a plugin group.
20
- BANNER
21
-
22
- def process(*entries)
23
- scopes, unknown = ::Guard::Interactor.convert_scope(entries)
24
-
25
- unless unknown.empty?
26
- output.puts "Unknown scopes: #{ unknown.join(", ") }"
27
- return
28
- end
29
-
30
- ::Guard.async_queue_add([:guard_run_all, scopes])
31
- end
32
- end
33
- end
34
- end
35
- end
36
- end
@@ -1,34 +0,0 @@
1
- require "pry"
2
-
3
- module Guard
4
- module Commands
5
- class Reload
6
- def self.import
7
- Pry::Commands.create_command "reload" do
8
- group "Guard"
9
- description "Reload all plugins."
10
-
11
- banner <<-BANNER
12
- Usage: reload <scope>
13
-
14
- Run the Guard plugin `reload` action.
15
-
16
- You may want to specify an optional scope to the action,
17
- either the name of a Guard plugin or a plugin group.
18
- BANNER
19
-
20
- def process(*entries)
21
- scopes, unknown = ::Guard::Interactor.convert_scope(entries)
22
-
23
- unless unknown.empty?
24
- output.puts "Unknown scopes: #{ unknown.join(", ") }"
25
- return
26
- end
27
-
28
- ::Guard.async_queue_add([:guard_reload, scopes])
29
- end
30
- end
31
- end
32
- end
33
- end
34
- end
@@ -1,36 +0,0 @@
1
- require "pry"
2
-
3
- module Guard
4
- module Commands
5
- class Scope
6
- def self.import
7
- Pry::Commands.create_command "scope" do
8
- group "Guard"
9
- description "Scope Guard actions to groups and plugins."
10
-
11
- banner <<-BANNER
12
- Usage: scope <scope>
13
-
14
- Set the global Guard scope.
15
- BANNER
16
-
17
- def process(*entries)
18
- scope, unknown = ::Guard::Interactor.convert_scope(entries)
19
-
20
- unless unknown.empty?
21
- output.puts "Unknown scopes: #{unknown.join(",") }"
22
- return
23
- end
24
-
25
- if scope[:plugins].empty? && scope[:groups].empty?
26
- output.puts "Usage: scope <scope>"
27
- return
28
- end
29
-
30
- ::Guard.setup_scope(scope)
31
- end
32
- end
33
- end
34
- end
35
- end
36
- end
@@ -1,72 +0,0 @@
1
- module Guard
2
- module DeprecatedMethods
3
- # @deprecated Use `Guard.plugins(filter)` instead.
4
- #
5
- # @see https://github.com/guard/guard/wiki/Upgrading-to-Guard-2.0 How to
6
- # upgrade for Guard 2.0
7
- #
8
- def guards(filter = nil)
9
- ::Guard::UI.deprecation(::Guard::Deprecator::GUARDS_DEPRECATION)
10
- plugins(filter)
11
- end
12
-
13
- # @deprecated Use `Guard.add_plugin(name, options = {})` instead.
14
- #
15
- # @see https://github.com/guard/guard/wiki/Upgrading-to-Guard-2.0 How to
16
- # upgrade for Guard 2.0
17
- #
18
- def add_guard(*args)
19
- ::Guard::UI.deprecation(::Guard::Deprecator::ADD_GUARD_DEPRECATION)
20
- add_plugin(*args)
21
- end
22
-
23
- # @deprecated Use
24
- # `Guard::PluginUtil.new(name).plugin_class(fail_gracefully:
25
- # fail_gracefully)` instead.
26
- #
27
- # @see https://github.com/guard/guard/wiki/Upgrading-to-Guard-2.0 How to
28
- # upgrade for Guard 2.0
29
- #
30
- def get_guard_class(name, fail_gracefully = false)
31
- UI.deprecation(Deprecator::GET_GUARD_CLASS_DEPRECATION)
32
- PluginUtil.new(name).plugin_class(fail_gracefully: fail_gracefully)
33
- end
34
-
35
- # @deprecated Use `Guard::PluginUtil.new(name).plugin_location` instead.
36
- #
37
- # @see https://github.com/guard/guard/wiki/Upgrading-to-Guard-2.0 How to
38
- # upgrade for Guard 2.0
39
- #
40
- def locate_guard(name)
41
- UI.deprecation(Deprecator::LOCATE_GUARD_DEPRECATION)
42
- PluginUtil.new(name).plugin_location
43
- end
44
-
45
- # @deprecated Use `Guard::PluginUtil.plugin_names` instead.
46
- #
47
- # @see https://github.com/guard/guard/wiki/Upgrading-to-Guard-2.0 How to
48
- # upgrade for Guard 2.0
49
- #
50
- def guard_gem_names
51
- UI.deprecation(Deprecator::GUARD_GEM_NAMES_DEPRECATION)
52
- PluginUtil.plugin_names
53
- end
54
-
55
- def running
56
- UI.deprecation(Deprecator::GUARD_RUNNING_DEPRECATION)
57
- nil
58
- end
59
-
60
- def lock
61
- UI.deprecation(Deprecator::GUARD_LOCK_DEPRECATION)
62
- end
63
-
64
- def evaluator
65
- # TODO: probably deprecate once it isn't used internally
66
- # UI.deprecation(Deprecator::GUARD_EVALUATOR_DEPRECATION)
67
- # TODO: this will be changed to the following when scope is reworked
68
- # ::Guard.session.evaluator
69
- ::Guard.instance_variable_get(:@evaluator)
70
- end
71
- end
72
- end
@@ -1,71 +0,0 @@
1
- module Guard
2
- module DeprecatedMethods
3
- # @deprecated Use `Guard.plugins(filter)` instead.
4
- #
5
- # @see https://github.com/guard/guard/wiki/Upgrading-to-Guard-2.0 How to
6
- # upgrade for Guard 2.0
7
- #
8
- def guards(filter = nil)
9
- ::Guard::UI.deprecation(::Guard::Deprecator::GUARDS_DEPRECATION)
10
- plugins(filter)
11
- end
12
-
13
- # @deprecated Use `Guard.add_plugin(name, options = {})` instead.
14
- #
15
- # @see https://github.com/guard/guard/wiki/Upgrading-to-Guard-2.0 How to
16
- # upgrade for Guard 2.0
17
- #
18
- def add_guard(*args)
19
- ::Guard::UI.deprecation(::Guard::Deprecator::ADD_GUARD_DEPRECATION)
20
- add_plugin(*args)
21
- end
22
-
23
- # @deprecated Use
24
- # `Guard::PluginUtil.new(name).plugin_class(fail_gracefully:
25
- # fail_gracefully)` instead.
26
- #
27
- # @see https://github.com/guard/guard/wiki/Upgrading-to-Guard-2.0 How to
28
- # upgrade for Guard 2.0
29
- #
30
- def get_guard_class(name, fail_gracefully = false)
31
- UI.deprecation(Deprecator::GET_GUARD_CLASS_DEPRECATION)
32
- PluginUtil.new(name).plugin_class(fail_gracefully: fail_gracefully)
33
- end
34
-
35
- # @deprecated Use `Guard::PluginUtil.new(name).plugin_location` instead.
36
- #
37
- # @see https://github.com/guard/guard/wiki/Upgrading-to-Guard-2.0 How to
38
- # upgrade for Guard 2.0
39
- #
40
- def locate_guard(name)
41
- UI.deprecation(Deprecator::LOCATE_GUARD_DEPRECATION)
42
- PluginUtil.new(name).plugin_location
43
- end
44
-
45
- # @deprecated Use `Guard::PluginUtil.plugin_names` instead.
46
- #
47
- # @see https://github.com/guard/guard/wiki/Upgrading-to-Guard-2.0 How to
48
- # upgrade for Guard 2.0
49
- #
50
- def guard_gem_names
51
- UI.deprecation(Deprecator::GUARD_GEM_NAMES_DEPRECATION)
52
- PluginUtil.plugin_names
53
- end
54
-
55
- def running
56
- UI.deprecation(Deprecator::GUARD_RUNNING_DEPRECATION)
57
- nil
58
- end
59
-
60
- def lock
61
- UI.deprecation(Deprecator::GUARD_LOCK_DEPRECATION)
62
- end
63
-
64
- def evaluator
65
- UI.deprecation(Deprecator::GUARD_EVALUATOR_DEPRECATION)
66
- # TODO: this will be changed to the following when scope is reworked
67
- # ::Guard.session.evaluator
68
- ::Guard.instance_variable_get(:@evaluator)
69
- end
70
- end
71
- end
@@ -1,133 +0,0 @@
1
- require "guard/ui"
2
-
3
- module Guard
4
- class Deprecator
5
- UPGRADE_WIKI =
6
- "https://github.com/guard/guard/wiki" +
7
- "/Upgrade-guide-for-existing-guards-to-Guard-v1.1"
8
-
9
- MORE_INFO_ON_UPGRADING_TO_GUARD_1_1 = <<-EOS.gsub(/^\s*/, "")
10
- For more information on how to update existing Guard plugins, please head
11
- over to:
12
- #{UPGRADE_WIKI}
13
- EOS
14
-
15
- MORE_INFO_ON_UPGRADING_TO_GUARD_2 = <<-EOS.gsub(/^\s*/, "")
16
- For more information on how to upgrade for Guard 2.0, please head over
17
- to: https://github.com/guard/guard/wiki/Upgrading-to-Guard-2.0%s
18
- EOS
19
-
20
- ADD_GUARD_DEPRECATION = <<-EOS.gsub(/^\s*/, "")
21
- Starting with Guard 2.0 'Guard.add_guard(name, options = {})' is
22
- deprecated.
23
-
24
- Please use 'Guard.add_plugin(name, options = {})' instead.
25
-
26
- #{MORE_INFO_ON_UPGRADING_TO_GUARD_2 % "#deprecated-methods"}
27
- EOS
28
-
29
- GUARDS_DEPRECATION = <<-EOS.gsub(/^\s*/, "")
30
- Starting with Guard 2.0 'Guard.guards(filter)' is deprecated.
31
-
32
- Please use 'Guard.plugins(filter)' instead.
33
-
34
- #{MORE_INFO_ON_UPGRADING_TO_GUARD_2 % "#deprecated-methods"}
35
- EOS
36
-
37
- # Deprecator message for the `Guard.get_guard_class` method
38
- GET_GUARD_CLASS_DEPRECATION = <<-EOS.gsub(/^\s*/, "")
39
- Starting with Guard 2.0 'Guard.get_guard_class(name, fail_gracefully =
40
- false)' is deprecated and is now always on.
41
-
42
- Please use 'Guard::PluginUtil.new(name).plugin_class(fail_gracefully:
43
- fail_gracefully)' instead.
44
-
45
- #{MORE_INFO_ON_UPGRADING_TO_GUARD_2 % "#deprecated-methods"}
46
- EOS
47
-
48
- # Deprecator message for the `Guard.locate_guard` method
49
- LOCATE_GUARD_DEPRECATION = <<-EOS.gsub(/^\s*/, "")
50
- Starting with Guard 2.0 'Guard.locate_guard(name)' is deprecated.
51
-
52
- Please use 'Guard::PluginUtil.new(name).plugin_location' instead.
53
-
54
- #{MORE_INFO_ON_UPGRADING_TO_GUARD_2 % "#deprecated-methods"}
55
- EOS
56
-
57
- # Deprecator message for the `Guard.guard_gem_names` method
58
- GUARD_GEM_NAMES_DEPRECATION = <<-EOS.gsub(/^\s*/, "")
59
- Starting with Guard 2.0 'Guard.guard_gem_names' is deprecated.
60
-
61
- Please use 'Guard::PluginUtil.plugin_names' instead.
62
-
63
- #{MORE_INFO_ON_UPGRADING_TO_GUARD_2 % "#deprecated-methods"}
64
- EOS
65
-
66
- # Deprecator message for the `Guard::Dsl.evaluate_guardfile` method
67
- EVALUATE_GUARDFILE_DEPRECATION = <<-EOS.gsub(/^\s*/, "")
68
- Starting with Guard 2.0 'Guard::Dsl.evaluate_guardfile(options)' is
69
- deprecated.
70
-
71
- Please use 'Guard::Guardfile::Evaluator.new(options).evaluate_guardfile'
72
- instead.
73
-
74
- #{MORE_INFO_ON_UPGRADING_TO_GUARD_2 % "#deprecated-methods-1"}
75
- EOS
76
-
77
- # Deprecator message for the `Guardfile.create_guardfile` method
78
- CREATE_GUARDFILE_DEPRECATION = <<-EOS.gsub(/^\s*/, "")
79
- Starting with Guard 2.0 'Guard::Guardfile.create_guardfile(options)' is
80
- deprecated.
81
-
82
- Please use 'Guard::Guardfile::Generator.new(options).create_guardfile'
83
- instead.
84
-
85
- #{MORE_INFO_ON_UPGRADING_TO_GUARD_2 % "#deprecated-methods-2"}
86
- EOS
87
-
88
- # Deprecator message for the `Guardfile.initialize_template` method
89
- INITIALIZE_TEMPLATE_DEPRECATION = <<-EOS.gsub(/^\s*/, "")
90
- Starting with Guard 2.0
91
- 'Guard::Guardfile.initialize_template(plugin_name)' is deprecated.
92
-
93
- Please use
94
- 'Guard::Guardfile::Generator.new.initialize_template(plugin_name)'
95
- instead.
96
-
97
- #{MORE_INFO_ON_UPGRADING_TO_GUARD_2 % "#deprecated-methods-2"}
98
- EOS
99
-
100
- # Deprecator message for the `Guardfile.initialize_all_templates` method
101
- INITIALIZE_ALL_TEMPLATES_DEPRECATION = <<-EOS.gsub(/^\s*/, "")
102
- Starting with Guard 2.0 'Guard::Guardfile.initialize_all_templates' is
103
- deprecated.
104
-
105
- Please use 'Guard::Guardfile::Generator.new.initialize_all_templates'
106
- instead.
107
-
108
- #{MORE_INFO_ON_UPGRADING_TO_GUARD_2 % "#deprecated-methods-2"}
109
- EOS
110
-
111
- # Deprecator message for when a Guard plugin inherits from Guard::Guard
112
- GUARD_GUARD_DEPRECATION = <<-EOS.gsub(/^\s*/, "")
113
- Starting with Guard 2.0, Guard::%s should inherit from Guard::Plugin
114
- instead of Guard::Guard.
115
-
116
- Please note that the constructor signature has changed from
117
- Guard::Guard#initialize(watchers = [], options = {}) to
118
- Guard::Plugin#initialize(options = {}).
119
-
120
- #{MORE_INFO_ON_UPGRADING_TO_GUARD_2 % "#changes-in-guardguard"}
121
- EOS
122
-
123
- GUARD_RUNNING_DEPRECATION = <<-EOS.gsub(/^\s*/, "")
124
- Starting with Guard 2.7.1 it was discovered that Guard.running was never
125
- initialized or used internally.
126
- EOS
127
-
128
- GUARD_LOCK_DEPRECATION = <<-EOS.gsub(/^\s*/, "")
129
- Starting with Guard 2.7.1 it was discovered that this accessor was never
130
- initialized or used internally.
131
- EOS
132
- end
133
- end