Class: Soryo::SendCommand
Instance Attribute Summary
Attributes inherited from Command
#config
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Command
add_options, descendants, #get_settings_file
Constructor Details
#initialize(template, email, options, instructions) ⇒ SendCommand
Returns a new instance of SendCommand.
Class Method Details
.add_command(program) ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/commands/sendcommand.rb', line 29
def self.add_command(program)
program.command(:send) do |c|
c.syntax "send <template> <json> <email instructions> [options]"
c.description "Build an email using a template and send it to the world"
c.option "test_type", "--test_type", "choose the type of testing you want"
c.action do |args, options|
if args.length != 3
abort('Please enter a template, email, and instructions')
end
command = Soryo::SendCommand.new(args[0], args[1], options, args[2])
command.build
end
self.add_options(c)
end
end
|
Instance Method Details
#build ⇒ Object
12
13
14
15
16
17
|
# File 'lib/commands/sendcommand.rb', line 12
def build
template_builder = Soryo::Template.new(@template.to_s, @email.to_hash)
final_email = template_builder.compile
send final_email
end
|
#send(email) ⇒ Object
20
21
22
23
24
25
26
27
|
# File 'lib/commands/sendcommand.rb', line 20
def send(email)
Soryo::Sender.descendants.each do |c|
if c.sender_name == @config["send_type"]
sender = c.new
sender.run(email, @config)
end
end
end
|