From 1472fecc4b88a59d608664a71ffbff8d386503fe Mon Sep 17 00:00:00 2001 From: Javan Makhmali Date: Wed, 7 Jul 2010 18:55:14 -0400 Subject: [PATCH] cleaned up quote escaping a little --- lib/whenever/job.rb | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/lib/whenever/job.rb b/lib/whenever/job.rb index 5b3dfb2..5d23501 100644 --- a/lib/whenever/job.rb +++ b/lib/whenever/job.rb @@ -13,21 +13,13 @@ module Whenever end def output - template = @options[:template].dup - - template.gsub(/:\w+/) do |key| - - single_quote = "'" - double_quote = '"' - - char_before = $`[-1..-1] - char_after = $'[0..0] - + @options[:template].dup.gsub(/:\w+/) do |key| + before_and_after = [$`[-1..-1], $'[0..0]] option = @options[key.sub(':', '').to_sym] - if char_before == single_quote && char_after == single_quote + if before_and_after.all? { |c| c == "'" } escape_single_quotes(option) - elsif char_after == double_quote && char_after == double_quote + elsif before_and_after.all? { |c| c == '"' } escape_double_quotes(option) else option