Skip to content

Instantly share code, notes, and snippets.

@shaliko
Created July 25, 2011 17:54
Show Gist options
  • Save shaliko/1104710 to your computer and use it in GitHub Desktop.
Save shaliko/1104710 to your computer and use it in GitHub Desktop.
convertor.rb
require 'yaml'
class Convertor
def initialize(text)
@text = text
end
def prepare
response = ""
subject = @text.scan(/subject\s+(.+)$/)[0]
to = @text.scan(/recipients\s+(.+)$/)[0]
variabels = @text.scan(/^\s*:(\w+)\s+=>\s+([\w\(\)\.]+)/)
response << variabels.map {|v| "@#{v[0]} = #{v[1]}" }.join("\n")
response << "\n\nmail(:to => #{to}, :subject => #{subject})"
response
end
end
text = "subject I18n.t('shaliko.title', :name => comment.full_name, :created => comment.date.strftime('%d.%m.%y'), :locale => recipient.locale.to_sym)
from APP_CONFIG['email']
reply_to 'shaliko@shaliko.com'
recipients recipient.email
body
:variable_1 => comment.full_name,
:variable_2 => comment.date.strftime('%d.%m.%y'),
:variable_3 => recipient.locale.to_sym"
convertor = Convertor.new text
puts convertor.prepare
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment