class Soryo::BuildCommand
Public Class Methods
add_command(program)
click to toggle source
# File lib/commands/buildcommand.rb, line 25 def self.add_command(program) program.command(:build) do |c| c.syntax "build <template> <email> <json> [options]" c.description "Build an email using a template" c.action do |args, options| if args.length != 2 abort('Please enter both a template and email') end command = Soryo::BuildCommand.new(args[0], args[1], options) command.build end self.add_options(c) end end
new(template, email, options)
click to toggle source
Calls superclass method
Soryo::Command::new
# File lib/commands/buildcommand.rb, line 5 def initialize(template, email, options) super(options) @template = Soryo::FileInstance.new template @email = Soryo::FileInstance.new email end
Public Instance Methods
build()
click to toggle source
# File lib/commands/buildcommand.rb, line 11 def build template_builder = Soryo::Template.new(@template.to_s, @email.to_hash) final_email = template_builder.compile # Run the plugins save final_email end
save(email)
click to toggle source
# File lib/commands/buildcommand.rb, line 19 def save(email) filename = @email.shortname + '.html' final_email = Soryo::FileInstance.new(filename) final_email.write(email) end