# Example 1: Run a single command whenever a file is added
notifier = proc do |title, _, changes|
Guard::Notifier.notify(changes * ",", title: title )
end
guard :yield, { run_on_additions: notifier, object: “Add missing specs!” } do
watch(/^(.*)\.rb$/) { |m| "spec/#{m}_spec.rb" }
end
# Example 2: log all kinds of changes
require 'logger' yield_options = {
object: ::Logger.new(STDERR), # passed to every other call start: proc { |logger| logger.level = Logger::INFO }, stop: proc { |logger| logger.info "Guard::Yield - Done!" }, run_on_modifications: proc { |log, _, files| log.info "!! #{files * ','}" }, run_on_additions: proc { |log, _, files| log.warn "++ #{files * ','}" }, run_on_removals: proc { |log, _, files| log.error "xx #{files * ','}" },
}
guard :yield, yield_options do
watch(/^(.*)\.css$/) watch(/^(.*)\.jpg$/) watch(/^(.*)\.png$/)
end