lib/flapjack/gateways/sms_messagenet.rb in flapjack-1.3.0 vs lib/flapjack/gateways/sms_messagenet.rb in flapjack-1.4.0rc1

- old
+ new

@@ -61,26 +61,21 @@ address = alert.address notification_id = alert.notification_id message_type = alert.rollup ? 'rollup' : 'alert' - my_dir = File.dirname(__FILE__) - sms_template_path = case - when @config.has_key?('templates') && @config['templates']["#{message_type}.text"] - @config['templates']["#{message_type}.text"] - else - my_dir + "/sms_messagenet/#{message_type}.text.erb" - end - sms_template = ERB.new(File.read(sms_template_path), nil, '-') + sms_template_erb, sms_template = + load_template(@config['templates'], message_type, 'text', + File.join(File.dirname(__FILE__), 'sms_messagenet')) @alert = alert bnd = binding begin - message = sms_template.result(bnd).chomp + message = sms_template_erb.result(bnd).chomp rescue => e - @logger.error "Error while excuting the ERB for an sms: " + - "ERB being executed: #{sms_template_path}" + @logger.error "Error while executing the ERB for an sms: " + + "ERB being executed: #{sms_template}" raise end if @config.nil? || (@config.respond_to?(:empty?) && @config.empty?) @logger.error "Messagenet config is missing"