master/lib/guard/dsl.rb

29 lines
674 B
Ruby
Raw Normal View History

2010-10-03 21:00:33 +00:00
module Guard
class Dsl
def self.evaluate_guardfile
guardfile = "#{Dir.pwd}/Guardfile"
dsl = new
dsl.instance_eval(File.read(guardfile.to_s), guardfile.to_s, 1)
rescue
UI.error "Guardfile not found or invalid"
exit 1
end
2010-10-07 20:37:30 +00:00
def self.guardfile_included?(guard_name)
File.read('Guardfile').include?("guard '#{guard_name}'")
end
2010-10-03 21:00:33 +00:00
def guard(name, options = {}, &definition)
@watchers = []
2010-10-07 20:37:30 +00:00
definition.call if definition
::Guard.add_guard(name, @watchers, options)
2010-10-03 21:00:33 +00:00
end
def watch(pattern, &action)
2010-10-07 20:37:30 +00:00
@watchers << ::Guard::Watcher.new(pattern, action)
2010-10-03 21:00:33 +00:00
end
end
end