Object
Converts and validates a plain text scope to a valid plugin or group scope.
@param [Array<String>] entries the text scope @return [Hash, Array<String>] the plugin or group scope, the unknown entries
# File lib/guard/interactor.rb, line 81 def self.convert_scope(entries) scopes = { plugins: [], groups: [] } unknown = [] entries.each do |entry| if plugin = ::Guard.plugin(entry) scopes[:plugins] << plugin elsif group = ::Guard.group(entry) scopes[:groups] << group else unknown << entry end end [scopes, unknown] end
Is the interactor enabled?
@return [Boolean] true if enabled
# File lib/guard/interactor.rb, line 63 def self.enabled @enabled || @enabled.nil? end
Set the enabled status for the interactor
@param [Boolean] status true if enabled
# File lib/guard/interactor.rb, line 71 def self.enabled=(status) @enabled = status end
Initializes the interactor. This configures Pry and creates some custom commands and aliases for Guard.
# File lib/guard/interactor.rb, line 102 def initialize return if ENV['GUARD_ENV'] == 'test' Pry.config.should_load_rc = false Pry.config.should_load_local_rc = false Pry.config.history.file = File.expand_path(self.class.options[:history_file] || HISTORY_FILE) @stty_exists = nil _add_hooks _replace_reset_command _create_run_all_command _create_command_aliases _create_guard_commands _create_group_commands _configure_prompt end
Get the interactor options
@return [Hash] the options
# File lib/guard/interactor.rb, line 45 def self.options @options ||= {} end
Set the interactor options
@param [Hash] options the interactor options @option options [String] :guard_rc the Ruby script to configure Guard Pry @option options [String] :history_file the file to write the Pry history to
# File lib/guard/interactor.rb, line 55 def self.options=(options) @options = options end
Start the line reader in its own thread and stop Guard on Ctrl-D.
# File lib/guard/interactor.rb, line 124 def start return if ENV['GUARD_ENV'] == 'test' _store_terminal_settings if _stty_exists? unless @thread ::Guard::UI.debug 'Start interactor' @thread = Thread.new do Pry.start ::Guard.stop end end end
Kill interactor thread if not current
# File lib/guard/interactor.rb, line 141 def stop return if !@thread || ENV['GUARD_ENV'] == 'test' unless Thread.current == @thread ::Guard::UI.reset_line ::Guard::UI.debug 'Stop interactor' @thread.kill @thread = nil end _restore_terminal_settings if _stty_exists? end
Generated with the Darkfish Rdoc Generator 2.