Class: Oode::Uploader
Constant Summary
collapse
- UPLOAD_FOLDER_NAME =
".oode"
Constants inherited
from Session
Session::DEFAULT_HOST, Session::SERVER
Instance Attribute Summary
Attributes inherited from Session
#user
Instance Method Summary
collapse
Methods inherited from Transferer
#initialize
Methods inherited from Session
#close, #connection, #exec!, #initialize
Instance Method Details
#clean! ⇒ Object
12
13
14
15
|
# File 'lib/oode/net/uploader.rb', line 12
def clean!
command = "rm -r #{default_upload_path}"
@session.exec!(command)
end
|
#create_upload_folder ⇒ Object
21
22
23
24
25
26
27
28
|
# File 'lib/oode/net/uploader.rb', line 21
def create_upload_folder
directories = @transfer.dir.entries(user.home)
directory_names = directories.map { |d| d.name }
unless directory_names.include? UPLOAD_FOLDER_NAME
@transfer.mkdir! default_upload_path
end
end
|
#default_upload_path ⇒ Object
17
18
19
|
# File 'lib/oode/net/uploader.rb', line 17
def default_upload_path
"#{user.home}/#{UPLOAD_FOLDER_NAME}"
end
|
#upload!(file, options = {}) ⇒ Object
5
6
7
8
9
10
|
# File 'lib/oode/net/uploader.rb', line 5
def upload!(file, options = {})
create_upload_folder
destination = options[:destination] || file.remote_path
@transfer.upload! file.path, destination
end
|