This repository was archived by the owner on Jul 2, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathRakefile
More file actions
90 lines (74 loc) · 2.29 KB
/
Copy pathRakefile
File metadata and controls
90 lines (74 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
DEPLOY_DIR = '~/_Sandbox/DigitalDirect/Client/Project'
PREVIEW_DIR = 'preview'
desc "Build the email from source"
task :build do
puts "## Building email"
status = system("middleman build --clean")
puts status ? "OK" : "FAILED"
end
desc "Build from source in readable format with sample data"
task :build_preview do
puts "## Building email preview"
ENV["BUILD_TYPE"] = 'preview'
status = system("middleman build --clean")
puts status ? "OK" : "FAILED"
end
desc "Deploy email via robocopy or rsync"
task :deploy, :os do |t, args|
os = args[:os] || 'nix'
if os == 'win'
status = system("robocopy #{PREVIEW_DIR} #{DEPLOY_DIR} /Z /E")
else
status = system("sudo rsync -avz --no-perms #{PREVIEW_DIR}/ #{DEPLOY_DIR}")
end
end
task :build_all => [:build, :sandbox] do
end
desc "Run the server at http://localhost:4567"
task :server do
system("middleman server")
end
desc "Build and deploy email to the sandbox"
task :sandbox => [:build_preview, :deploy] do
end
desc "Build and deploy email to the sandbox"
task :build_images do
status = system("middleman build --glob=images/*")
end
desc "Zip up image assets"
task :zip => [:build_images] do
require 'zip'
directory = "build/images/"
zipfile_name = "build/images.zip"
Zip::File.open(zipfile_name, Zip::File::CREATE) do |zipfile|
Dir[File.join(directory, '**', '**')].each do |file|
zipfile.add(file.sub(directory, ''), file)
end
end
end
desc "Send html email from preview by filename"
# ~/.bashrc
# export TEST_SEND_EMAILS=...
# export GMAIL_USERNAME=...
# export GMAIL_PASSWORD=...
task :mail, :filename do |t, args|
require 'mail'
filename = args[:filename] || 'index.html'
sendTo = ENV["TEST_SEND_EMAILS"]
username = ENV["GMAIL_USERNAME"]
password = ENV["GMAIL_PASSWORD"]
mail = Mail.new do
from 'MM Test Email'
to sendTo
subject '-- TEST EMAIL -- [' + filename + ']'
content_type 'text/html; charset=UTF-8'
body File.read(PREVIEW_DIR + "/" + filename)
end
mail.delivery_method :smtp,
:address => "smtp.gmail.com",
:port => 587,
:user_name => username,
:password => password,
:enable_ssl => true
mail.deliver
end