Created
July 25, 2011 17:54
-
-
Save shaliko/1104710 to your computer and use it in GitHub Desktop.
convertor.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 '[email protected]' | |
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