Module: Guard
- Extended by:
- Commander, Internals::Helpers
- Defined in:
- lib/guard.rb,
lib/guard/ui.rb,
lib/guard/cli.rb,
lib/guard/dsl.rb,
lib/guard/group.rb,
lib/guard/config.rb,
lib/guard/plugin.rb,
lib/guard/runner.rb,
lib/guard/options.rb,
lib/guard/version.rb,
lib/guard/watcher.rb,
lib/guard/notifier.rb,
lib/guard/terminal.rb,
lib/guard/commander.rb,
lib/guard/guardfile.rb,
lib/guard/jobs/base.rb,
lib/guard/rake_task.rb,
lib/guard/ui/colors.rb,
lib/guard/ui/config.rb,
lib/guard/ui/logger.rb,
lib/guard/dsl_reader.rb,
lib/guard/interactor.rb,
lib/guard/jobs/sleep.rb,
lib/guard/plugin_util.rb,
lib/guard/commands/all.rb,
lib/guard/aruba_adapter.rb,
lib/guard/commands/show.rb,
lib/guard/dsl_describer.rb,
lib/guard/commands/pause.rb,
lib/guard/commands/scope.rb,
lib/guard/deprecated/dsl.rb,
lib/guard/commands/change.rb,
lib/guard/commands/reload.rb,
lib/guard/internals/queue.rb,
lib/guard/internals/scope.rb,
lib/guard/internals/state.rb,
lib/guard/internals/traps.rb,
lib/guard/watcher/pattern.rb,
lib/guard/deprecated/guard.rb,
lib/guard/internals/groups.rb,
lib/guard/jobs/pry_wrapper.rb,
lib/guard/internals/helpers.rb,
lib/guard/internals/plugins.rb,
lib/guard/internals/session.rb,
lib/guard/internals/tracing.rb,
lib/guard/deprecated/watcher.rb,
lib/guard/guardfile/evaluator.rb,
lib/guard/guardfile/generator.rb,
lib/guard/internals/debugging.rb,
lib/guard/deprecated/evaluator.rb,
lib/guard/deprecated/guardfile.rb,
lib/guard/commands/notification.rb,
lib/guard/cli/environments/valid.rb,
lib/guard/watcher/pattern/matcher.rb,
lib/guard/cli/environments/bundler.rb,
lib/guard/watcher/pattern/simple_path.rb,
lib/guard/watcher/pattern/match_result.rb,
lib/guard/watcher/pattern/pathname_path.rb,
lib/guard/cli/environments/evaluate_only.rb,
lib/guard/watcher/pattern/deprecated_regexp.rb
Overview
TODO: remove this file in next major version
Defined Under Namespace
Modules: Cli, Commander, Commands, Deprecated, Guardfile, Internals, Jobs, UI Classes: ArubaAdapter, CLI, Config, Dsl, DslDescriber, DslReader, Group, Interactor, Notifier, Options, Plugin, PluginUtil, RakeTask, Runner, Terminal, Watcher
Constant Summary collapse
- VERSION =
"2.19.0"
- UPGRADE_WIKI_URL =
"https://github.com/guard/guard/wiki/Upgrading-to-Guard-2.0"
Class Attribute Summary collapse
-
.interactor ⇒ Object
readonly
Returns the value of attribute interactor.
-
.listener ⇒ Object
readonly
Returns the value of attribute listener.
-
.queue ⇒ Object
readonly
Returns the value of attribute queue.
-
.state ⇒ Object
readonly
Returns the value of attribute state.
Class Method Summary collapse
-
.async_queue_add(changes) ⇒ Object
Asynchronously trigger changes.
- .init(cmdline_options) ⇒ Object
-
.setup(cmdline_options = {}) ⇒ Guard
Initializes the Guard singleton:.
Methods included from Internals::Helpers
Methods included from Commander
pause, reload, run_all, show, start, stop
Class Attribute Details
.interactor ⇒ Object (readonly)
Returns the value of attribute interactor.
24 25 26 |
# File 'lib/guard.rb', line 24 def interactor @interactor end |
.listener ⇒ Object (readonly)
Returns the value of attribute listener.
23 24 25 |
# File 'lib/guard.rb', line 23 def listener @listener end |
.queue ⇒ Object (readonly)
Returns the value of attribute queue.
22 23 24 |
# File 'lib/guard.rb', line 22 def queue @queue end |
.state ⇒ Object (readonly)
Returns the value of attribute state.
21 22 23 |
# File 'lib/guard.rb', line 21 def state @state end |
Class Method Details
.async_queue_add(changes) ⇒ Object
Asynchronously trigger changes
Currently supported args:
@example Old style hash:
async_queue_add(modified: ['foo'], added: ['bar'], removed: [])
@example New style signals with args:
async_queue_add([:guard_pause, :unpaused ])
87 88 89 90 91 92 93 |
# File 'lib/guard.rb', line 87 def async_queue_add(changes) @queue << changes # Putting interactor in background puts guard into foreground # so it can handle change notifications Thread.new { interactor.background } end |
.init(cmdline_options) ⇒ Object
73 74 75 |
# File 'lib/guard.rb', line 73 def init() @state = Internals::State.new() end |
.setup(cmdline_options = {}) ⇒ Guard
Initializes the Guard singleton:
-
Initialize the internal Guard state;
-
Create the interactor
-
Select and initialize the file change listener.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/guard.rb', line 44 def setup( = {}) init() @queue = Internals::Queue.new(Guard) _evaluate(state.session.) # NOTE: this should be *after* evaluate so :directories can work # TODO: move listener setup to session? @listener = Listen.send(*state.session.listener_args, &_listener_callback) ignores = state.session.guardfile_ignore @listener.ignore(ignores) unless ignores.empty? ignores = state.session.guardfile_ignore_bang @listener.ignore!(ignores) unless ignores.empty? Notifier.connect(state.session.) traps = Internals::Traps traps.handle("USR1") { async_queue_add([:guard_pause, :paused]) } traps.handle("USR2") { async_queue_add([:guard_pause, :unpaused]) } @interactor = Interactor.new(state.session.interactor_name == :sleep) traps.handle("INT") { @interactor.handle_interrupt } self end |