Top Level Namespace

Defined Under Namespace

Classes: Jekyll

Instance Method Summary collapse

Instance Method Details

#clean_ftp(ftp) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/hyde/ftp-transfer.rb', line 29

def clean_ftp(ftp)
	ftp.nlst.each do |file|
		next if ['.', '..', 'bup', 'backup'].include? file
		if ftp_directory? ftp, file
			ftp.chdir file
			clean_ftp(ftp)
			ftp.chdir '..'
			puts "Deleting directory: " + ftp.pwd + "/" + file
			ftp.rmdir(file)
		else
			puts "Deleting: " + ftp.pwd + "/" + file
			ftp.delete file
		end
	end
end

#ftp_directory?(ftp, file_name) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
24
25
26
27
# File 'lib/hyde/ftp-transfer.rb', line 21

def ftp_directory?(ftp, file_name)
	ftp.chdir(file_name)
	ftp.chdir('..')
	true
	rescue
	false
end

#mirror(path, ftp, initial_path = nil) ⇒ Object



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/hyde/ftp-transfer.rb', line 1

def mirror(path, ftp, initial_path = nil)
	initial_path ||= path
	Dir.entries(path).each do |file|
		next if ['.', '..'].include? file

		file_path = path + '/' + file
		short_file_path = file_path[initial_path.length, file_path.length]
		if File.directory?(file_path)
			ftp.mkdir(file) unless ftp.nlst.index(file)
			ftp.chdir(file)
			mirror(file_path, ftp, initial_path)
			ftp.chdir('..')
		else
			puts "Deploying: " + short_file_path
			puts "       To: " + ftp.pwd + '/' + file
			ftp.putbinaryfile(path + '/' + file, file)
		end
	end
end