def action_delete
if @cron_exists
crontab = String.new
cron_found = false
read_crontab.each_line do |line|
case line.chomp
when "# Chef Name: #{@new_resource.name}"
cron_found = true
next
when ENV_PATTERN
next if cron_found
when CRON_PATTERN
if cron_found
cron_found = false
next
end
else
cron_found = false
end
crontab << line
end
description = cron_found ? "remove #{@new_resource.name} from crontab" :
"save unmodified crontab"
converge_by(description) do
write_crontab crontab
Chef::Log.info("#{@new_resource} deleted crontab entry")
end
end
end