Class: Tane::Commands::Email
Class Method Summary collapse
- .help_text ⇒ Object
- .list_email_templates ⇒ Object
- .process(args) ⇒ Object
- .render_email(name) ⇒ Object
- .send_email(email_name) ⇒ Object
Methods inherited from Base
Methods included from Helpers
Class Method Details
.help_text ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/tane/commands/email.rb', line 37 def help_text <<-EOL Usage: tane email [email_template_name] Simulates an incoming email event in the app running locally, using the template provided. Details on how to create a template are discussed later in this document. To list email templates defined for the application, run tane email EOL end |
.list_email_templates ⇒ Object
11 12 13 14 15 |
# File 'lib/tane/commands/email.rb', line 11 def list_email_templates email_templates = Dir["#{email_templates_path}/*.yml"] term.say "#{email_templates.count} email templates found for this app:" email_templates.each { |template| term.say template } end |
.process(args) ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/tane/commands/email.rb', line 3 def process(args) if args.count == 0 list_email_templates else send_email(args.first) end end |
.render_email(name) ⇒ Object
33 34 35 |
# File 'lib/tane/commands/email.rb', line 33 def render_email(name) YAML.load(ERB.new(File.read( email_template_file_path(name) )).result) end |
.send_email(email_name) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/tane/commands/email.rb', line 17 def send_email(email_name) email = render_email(email_name) if email.nil? term.say "Couldn't find any email with the title '#{email_name}', are you sure there is a .cloudfuji/emails/#{email_name}.yml? " term.say "Here are the email templates for this app..." list_email_templates exit 1 end email = email[email_name] post(mail_url, email) end |