Clear Guard's options hash
# File lib/guard/setuper.rb, line 93 def clear_options @options = nil end
Evaluates the Guardfile content. It displays an error message if no Guard plugins are instantiated after the Guardfile evaluation.
@see Guard::Guardfile::Evaluator#evaluate_guardfile
# File lib/guard/setuper.rb, line 143 def evaluate_guardfile evaluator.evaluate_guardfile ::Guard::UI.error 'No plugins found in Guardfile, please add at least one.' if plugins.empty? end
Lazy initializer for Guardfile evaluator
# File lib/guard/setuper.rb, line 79 def evaluator @evaluator ||= ::Guard::Guardfile::Evaluator.new(@opts || {}) end
Lazy initializer the interactor unless the user has specified not to.
# File lib/guard/setuper.rb, line 85 def interactor return if options.no_interactions || !::Guard::Interactor.enabled @interactor ||= ::Guard::Interactor.new end
Lazy initializer for Guard's options hash
# File lib/guard/setuper.rb, line 73 def options @options ||= ::Guard::Options.new(@opts || {}, DEFAULT_OPTIONS) end
Initializes the groups array with the default group(s).
@see DEFAULT_GROUPS
# File lib/guard/setuper.rb, line 101 def reset_groups @groups = DEFAULT_GROUPS.map { |name| Group.new(name) } end
Initializes the plugins array to an empty array.
@see Guard.plugins
# File lib/guard/setuper.rb, line 109 def reset_plugins @plugins = [] end
Initializes the scope hash to `{ groups: [], plugins: [] }`.
@see Guard.setup_scope
# File lib/guard/setuper.rb, line 117 def reset_scope @scope = { groups: [], plugins: [] } end
Initializes the Guard singleton:
Initialize the internal Guard state;
Create the interactor when necessary for user interaction;
Select and initialize the file change listener.
@option options [Boolean] clear if auto clear the UI should be done @option options [Boolean] notify if system notifications should be shown @option options [Boolean] debug if debug output should be shown @option options [Array<String>] group the list of groups to start @option options [Array<String>] watchdir the directories to watch @option options [String] guardfile the path to the Guardfile
@return [Guard] the Guard singleton
# File lib/guard/setuper.rb, line 40 def setup(opts = {}) _reset_lazy_accessors @running = true @lock = Mutex.new @opts = opts @watchdirs = [Dir.pwd] @runner = ::Guard::Runner.new if options.watchdir # Ensure we have an array @watchdirs = Array(options.watchdir).map { |dir| File.expand_path dir } end ::Guard::UI.clear(force: true) _setup_debug if options.debug _setup_listener _setup_signal_traps reset_groups reset_plugins reset_scope evaluate_guardfile setup_scope(groups: options.group, plugins: options.plugin) _setup_notifier self end
Stores the scopes defined by the user via the `--group` / `-g` option (to run only a specific group) or the `--plugin` / `-P` option (to run only a specific plugin).
# File lib/guard/setuper.rb, line 128 def setup_scope(new_scope) if new_scope[:groups] && new_scope[:groups].any? scope[:groups] = new_scope[:groups].map { |group| ::Guard.add_group(group) } end if new_scope[:plugins] && new_scope[:plugins].any? scope[:plugins] = new_scope[:plugins].map { |plugin| ::Guard.plugin(plugin) } end end
Generated with the Darkfish Rdoc Generator 2.