Permalink
Browse files

Merge pull request #369 from schmurfy/template_location

Allow Guard plugins to specify their template location
  • Loading branch information...
2 parents 07b282d + 1a5e714 commit 907e34cc56f708d4f13f82333e9417c6dbbbcdb9 @rymai rymai committed Dec 2, 2012
Showing with 10 additions and 1 deletion.
  1. +10 −1 lib/guard/guard.rb
View
11 lib/guard/guard.rb
@@ -58,6 +58,15 @@ def initialize(watchers = [], options = {})
@watchers, @options = watchers, options
end
+ # 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`.
#
@@ -68,7 +77,7 @@ def self.init(name)
::Guard::UI.info "Guardfile already includes #{ name } guard"
else
content = File.read('Guardfile')
- guard = File.read("#{ ::Guard.locate_guard(name) }/lib/guard/#{ name }/templates/Guardfile")
+ guard = template(name)
File.open('Guardfile', 'wb') do |f|
f.puts(content)

0 comments on commit 907e34c

Please sign in to comment.