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
|
# File 'lib/jekyll-ftp/deploy.rb', line 6
def self.deploy(deploy_now = true)
if File.exists?("_config.yml")
$config = YAML.load_file("_config.yml")
server = $config["server_url"]
username = $config["username"]
remote_dir = $config["remote_dir"]
if server.nil? || username.nil? || remote_dir.nil?
missing = Array.new
if server.nil?
missing.push("server_url")
end
if username.nil?
missing.push("username")
end
if remote_dir.nil?
missing.push("remote_dir")
end
Jekyll_FTP::Error.config_error(missing)
end
say " FTP Server: ".blue + server
say " Username: ".blue + username
say "Remote Directory: ".blue + remote_dir
ftp = Net::FTP.new(server)
ftp.login(username, password)
ftp.chdir(remote_dir)
say "\nDeploying...".yellow unless deploy_now == false
if File.directory?("_site")
Jekyll_FTP::SubCommand.clean(ftp)
else
say "ERROR: _site directory does not exist."
abort "Have you tried `jekyll build`?".yellow
end
unless deploy_now == false
Dir.chdir("_site")
path = Dir.getwd
Jekyll_FTP::SubCommand.send(ftp, path)
end
else
Jekyll_FTP::Error.file_missing("_config.yml")
end
end
|