Class: Jekyll_FTP::SubCommand
- Inherits:
-
Object
- Object
- Jekyll_FTP::SubCommand
- Defined in:
- lib/jekyll-ftp/send.rb,
lib/jekyll-ftp/clean.rb
Class Method Summary collapse
- .clean(ftp) ⇒ Object
- .directory?(ftp, filename) ⇒ Boolean
- .send(ftp, path, init_path = nil) ⇒ Object
Class Method Details
.clean(ftp) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/jekyll-ftp/clean.rb', line 3 def self.clean(ftp) ftp.nlst.each do |file| next if ['.', '..'].include?(file) if directory?(ftp, file) ftp.chdir file clean(ftp) ftp.chdir '..' puts "Deleting directory: ".red + ftp.pwd + "/" + file + "/" ftp.rmdir(file) else puts "Deleting: ".red + ftp.pwd + "/" + file ftp.delete(file) end end end |
.directory?(ftp, filename) ⇒ Boolean
18 19 20 21 22 23 24 |
# File 'lib/jekyll-ftp/clean.rb', line 18 def self.directory?(ftp, filename) ftp.chdir(filename) ftp.chdir('..') return true rescue return false end |
.send(ftp, path, init_path = nil) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/jekyll-ftp/send.rb', line 3 def self.send(ftp, path, init_path = nil) init_path ||= path Dir.entries(path).each do |file| next if ['.', '..'].include? file file_path = path + '/' + file short_file_path = file_path[init_path.length, file_path.length] if File.directory?(file_path) ftp.mkdir(file) unless ftp.nlst.index(file) ftp.chdir(file) send(ftp, file_path, init_path) ftp.chdir('..') else puts "Deploying: ".green + short_file_path puts " To: ".yellow + ftp.pwd + '/' + file ftp.putbinaryfile(path + '/' + file, file) end end end |