Module: Guard::Plugin::Base

Includes:
Hooker
Included in:
Guard, Guard::Plugin
Defined in:
lib/guard/plugin/base.rb

Overview

Colection of shared methods between `Guard::Guard` (deprecated) and `Guard::Plugin`.

Defined Under Namespace

Modules: ClassMethods

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Hooker

add_callback, callbacks, #hook, notify, reset_callbacks!

Instance Attribute Details

#callbacksObject

Returns the value of attribute callbacks



14
15
16
# File 'lib/guard/plugin/base.rb', line 14

def callbacks
  @callbacks
end

#groupObject

Returns the value of attribute group



14
15
16
# File 'lib/guard/plugin/base.rb', line 14

def group
  @group
end

#optionsObject

Returns the value of attribute options



14
15
16
# File 'lib/guard/plugin/base.rb', line 14

def options
  @options
end

#watchersObject

Returns the value of attribute watchers



14
15
16
# File 'lib/guard/plugin/base.rb', line 14

def watchers
  @watchers
end

Class Method Details

.included(base) ⇒ Object



16
17
18
# File 'lib/guard/plugin/base.rb', line 16

def self.included(base)
  base.extend(ClassMethods)
end

Instance Method Details

#nameString

Returns the plugin's name (without “guard-”).

Examples:

Name for Guard::RSpec

Guard::RSpec.new.name
#=> "rspec"

Returns:

  • (String)


131
132
133
# File 'lib/guard/plugin/base.rb', line 131

def name
  @name ||= self.class.non_namespaced_name
end

#reloadObject

Called when `reload|r|z + enter` is pressed. This method should be mainly used for “reload” (really!) actions like reloading passenger/spork/bundler/…

Returns:

  • (Object)

    the task result

Raises:

  • (:task_has_failed)

    when reload has failed



# File 'lib/guard/plugin/base.rb', line 73

#run_allObject

Called when just `enter` is pressed This method should be principally used for long action like running all specs/tests/…

Returns:

  • (Object)

    the task result

Raises:

  • (:task_has_failed)

    when run_all has failed



# File 'lib/guard/plugin/base.rb', line 82

#run_on_additions(paths) ⇒ Object

Called on file(s) additions that the Guard plugin watches.

Parameters:

  • paths (Array<String>)

    the changes files or paths

Returns:

  • (Object)

    the task result

Raises:

  • (:task_has_failed)

    when run_on_additions has failed



# File 'lib/guard/plugin/base.rb', line 99

#run_on_changes(paths) ⇒ Object

Default behaviour on file(s) changes that the Guard plugin watches.

Parameters:

  • paths (Array<String>)

    the changes files or paths

Returns:

  • (Object)

    the task result

Raises:

  • (:task_has_failed)

    when run_on_changes has failed



# File 'lib/guard/plugin/base.rb', line 91

#run_on_modifications(paths) ⇒ Object

Called on file(s) modifications that the Guard plugin watches.

Parameters:

  • paths (Array<String>)

    the changes files or paths

Returns:

  • (Object)

    the task result

Raises:

  • (:task_has_failed)

    when run_on_modifications has failed



# File 'lib/guard/plugin/base.rb', line 107

#run_on_removals(paths) ⇒ Object

Called on file(s) removals that the Guard plugin watches.

Parameters:

  • paths (Array<String>)

    the changes files or paths

Returns:

  • (Object)

    the task result

Raises:

  • (:task_has_failed)

    when run_on_removals has failed



# File 'lib/guard/plugin/base.rb', line 115

#startObject

Called once when Guard starts. Please override initialize method to init stuff.

Returns:

  • (Object)

    the task result

Raises:

  • (:task_has_failed)

    when start has failed



# File 'lib/guard/plugin/base.rb', line 57

#stopObject

Called when `stop|quit|exit|s|q|e + enter` is pressed (when Guard quits).

Returns:

  • (Object)

    the task result

Raises:

  • (:task_has_failed)

    when stop has failed



# File 'lib/guard/plugin/base.rb', line 65

#titleString

Returns the plugin's class name without the Guard

namespace.

Examples:

Title for Guard::RSpec

Guard::RSpec.new.title
#=> "RSpec"

Returns:

  • (String)


143
144
145
# File 'lib/guard/plugin/base.rb', line 143

def title
  @title ||= self.class.non_namespaced_classname
end

#to_sString

String representation of the plugin.

Examples:

String representation of an instance of the Guard::RSpec plugin

Guard::RSpec.new.title
#=> "#<Guard::RSpec @name=rspec @group=#<Guard::Group @name=default @options={}> @watchers=[] @callbacks=[] @options={all_after_pass: true}>"

Returns:

  • (String)

    the string representation



155
156
157
# File 'lib/guard/plugin/base.rb', line 155

def to_s
  "#<#{self.class} @name=#{name} @group=#{group} @watchers=#{watchers} @callbacks=#{callbacks} @options=#{options}>"
end