Permalink
Browse files

Shorten the Guard plugin string representation.

  • Loading branch information...
1 parent 864e13c commit 7b512e527ee73c2b398fcb72f9a832ce6c83c2c9 @netzpirat netzpirat committed Dec 19, 2012
Showing with 9 additions and 8 deletions.
  1. +7 −6 lib/guard/guard.rb
  2. +2 −2 spec/guard/guard_spec.rb
View
13 lib/guard/guard.rb
@@ -60,13 +60,13 @@ def initialize(watchers = [], options = {})
# Specify the source for the Guardfile template.
# Each Guard plugin can redefine this method to add its own logic.
- #
+ #
# @param [String] The plugin name
- #
+ #
def self.template(name)
File.read("#{ ::Guard.locate_guard(name) }/lib/guard/#{ name }/templates/Guardfile")
end
-
+
# Initialize the Guard plugin. This will copy the Guardfile template inside the Guard plugin gem.
# The template Guardfile must be located within the Gem at `lib/guard/guard-name/templates/Guardfile`.
#
@@ -152,12 +152,13 @@ def self.init(name)
# @!method run_on_removals(paths)
# Convert plugin to string representation. The
- # default just uses the plugin class name.
- #
+ # default just uses the plugin class name and
+ # removes the Guard module name.
+ #
# @return [String] the string representation
#
def to_s
- self.class.to_s
+ self.class.to_s.downcase.sub('guard::', '')
end
end
View
4 spec/guard/guard_spec.rb
@@ -61,9 +61,9 @@
describe '#to_s' do
before(:all) { class Guard::Dummy < Guard::Guard; end }
- it "output Guard properly" do
+ it "output the short plugin name" do
guard = Guard::Dummy.new
- guard.to_s.should eq "Guard::Dummy"
+ guard.to_s.should eq "dummy"
end
end

0 comments on commit 7b512e5

Please sign in to comment.