Permalink
Browse files

allow guards to specify their templates

  • Loading branch information...
1 parent 07b282d commit 00fbc16a96ef77135c44f0e830a7f177e6341f75 @schmurfy schmurfy committed Dec 1, 2012
Showing with 6 additions and 1 deletion.
  1. +6 −1 lib/guard/guard.rb
View
@@ -58,6 +58,11 @@ def initialize(watchers = [], options = {})
@watchers, @options = watchers, options
end
+
+ 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 +73,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 00fbc16

Please sign in to comment.