Module: FtpDeploy
- Defined in:
- lib/scms/deploy-ftp.rb
Defined Under Namespace
Classes: Ftp
Class Method Summary collapse
-
.sync(website, config) ⇒ Object
host: localhost port: 21 username: exampleuser password: seCre7Squr1al passive: true directory: /htdocs.
Class Method Details
.sync(website, config) ⇒ Object
host: localhost port: 21 username: exampleuser password: seCre7Squr1al passive: true directory: /htdocs
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 |
# File 'lib/scms/deploy-ftp.rb', line 16 def FtpDeploy.sync(website, config) ftpYamlPath=File.join(config, "_ftpconfig.yml") settings = YAML.load_file(ftpYamlPath) throw "No gost defined in _ftpconfig.yml settings file" if settings['host'] == nil host = settings['host'] port = (settings['port'] || 21).to_i passive = settings['passive'] || true remote_dir = settings['directory'] || "/" ScmsUtils.boldlog("Sending site over FTP (host: #{host}, port: #{port})") begin if settings['username'].nil? print "FTP Username: " username = $stdin.gets.chomp else username = settings['username'] end if settings['password'].nil? print "FTP Password: " # We hide the entered characters before to ask for the password system "stty -echo" password = $stdin.gets.chomp system "stty echo" else password = settings['password'] end rescue NoMethodError, Interrupt # When the process is exited, we display the characters again # And we exit system "stty echo" exit end ftp = FtpDeploy::Ftp.new(host, port, {:username => username, :password => password, :passive => passive}) puts "\r\nConnected to server. Sending site" ftp.sync(website, remote_dir) puts "Successfully published site" end |