Files

Guard::Setuper

Attributes

watchdirs[R]

Public Instance Methods

clear_options() click to toggle source

Clear Guard’s options hash

# File lib/guard/setuper.rb, line 95
def clear_options
  @options = nil
end
evaluate_guardfile() click to toggle source

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 147
def evaluate_guardfile
  evaluator.evaluate_guardfile
  ::Guard::UI.error 'No plugins found in Guardfile, please add at least one.' if plugins.empty?
end
evaluator() click to toggle source

Lazy initializer for Guardfile evaluator

# File lib/guard/setuper.rb, line 81
def evaluator
  @evaluator ||= ::Guard::Guardfile::Evaluator.new(@opts || {})
end
interactor() click to toggle source

Lazy initializer the interactor unless the user has specified not to.

# File lib/guard/setuper.rb, line 87
def interactor
  return if options[:no_interactions] || !::Guard::Interactor.enabled

  @interactor ||= ::Guard::Interactor.new
end
options() click to toggle source

Lazy initializer for Guard’s options hash

# File lib/guard/setuper.rb, line 75
def options
  @options ||= ::Guard::Options.new(@opts, DEFAULT_OPTIONS)
end
reset_groups() click to toggle source

Initializes the groups array with the default group(s).

@see DEFAULT_GROUPS

# File lib/guard/setuper.rb, line 103
def reset_groups
  @groups = DEFAULT_GROUPS.map { |name| Group.new(name) }
end
reset_plugins() click to toggle source

Initializes the plugins array to an empty array.

@see Guard.plugins

# File lib/guard/setuper.rb, line 111
def reset_plugins
  @plugins = []
end
reset_scope() click to toggle source

Initializes the scope hash to `{ groups: [], plugins: [] }`.

@see Guard.setup_scope

# File lib/guard/setuper.rb, line 119
def reset_scope
  @scope = { groups: [], plugins: [] }
end
setup(opts = {}) click to toggle source

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 42
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
setup_scope(new_scope) click to toggle source

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).

@see CLI#start @see Dsl#scope

# File lib/guard/setuper.rb, line 132
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

[Validate]

Generated with the Darkfish Rdoc Generator 2.