Module: Guard::Plugin::Base::ClassMethods

Defined in:
lib/guard/plugin/base.rb

Instance Method Summary collapse

Instance Method Details

#non_namespaced_classnameString

Returns the non-namespaced class name of the plugin

Examples:

Non-namespaced class name for Guard::RSpec

Guard::RSpec.non_namespaced_classname
#=> "RSpec"

Returns:

  • (String)


30
31
32
# File 'lib/guard/plugin/base.rb', line 30

def non_namespaced_classname
  self.to_s.sub('Guard::', '')
end

#non_namespaced_nameString

Returns the non-namespaced name of the plugin

Examples:

Non-namespaced name for Guard::RSpec

Guard::RSpec.non_namespaced_name
#=> "rspec"

Returns:

  • (String)


43
44
45
# File 'lib/guard/plugin/base.rb', line 43

def non_namespaced_name
  non_namespaced_classname.downcase
end

#template(plugin_location) ⇒ Object

Specify the source for the Guardfile template. Each Guard plugin can redefine this method to add its own logic.

Parameters:

  • plugin_location (String)

    the plugin location



52
53
54
# File 'lib/guard/plugin/base.rb', line 52

def template(plugin_location)
  File.read("#{ plugin_location }/lib/guard/#{ non_namespaced_name }/templates/Guardfile")
end