Class: Snaptoken::Commands::Deploy
Constant Summary
Constants inherited
from BaseCommand
BaseCommand::ERROR_MSG
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from BaseCommand
#current_or_latest_step, #current_step, inherited, #initialize, #latest_step, #needs!, #select_step, #step_path, #steps
Class Method Details
.name ⇒ Object
2
3
4
|
# File 'lib/snaptoken/commands/deploy.rb', line 2
def self.name
"deploy"
end
|
.summary ⇒ Object
6
7
8
|
# File 'lib/snaptoken/commands/deploy.rb', line 6
def self.summary
"Pushes output files in doc/ to production server"
end
|
Instance Method Details
#run ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/snaptoken/commands/deploy.rb', line 10
def run
needs! :config, :doc, :doc_out, :ftp
only = @args.empty? ? nil : @args
FileUtils.cd(File.join(@config[:path], "doc/html_out")) do
ftp_config = YAML.load(File.read(File.join(@config[:path], "ftp.yml")))
Net::FTP.open(ftp_config[:host], ftp_config[:username], ftp_config[:password]) do |ftp|
ftp.chdir(ftp_config[:root])
Dir["**/*"].each do |f|
if only.nil? || only.any? { |o| f[o] }
puts f
if File.directory?(f)
ftp.mkdir(f) rescue Net::FTPPermError
elsif File.file?(f)
ftp.putbinaryfile(f, f)
end
end
end
end
end
end
|