Class: Fclay::RemoteStorage::SSH
- Inherits:
-
Base
- Object
- Base
- Fclay::RemoteStorage::SSH
show all
- Defined in:
- lib/fclay/remote_storage/ssh.rb
Instance Attribute Summary
Attributes inherited from Base
#name, #options, #storage, #uploading_object
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#get_storage_by_name
Constructor Details
#initialize(name, uploading_object) ⇒ SSH
5
6
7
|
# File 'lib/fclay/remote_storage/ssh.rb', line 5
def initialize(name, uploading_object)
super
end
|
Class Method Details
.url(name = nil) ⇒ Object
27
28
29
30
31
|
# File 'lib/fclay/remote_storage/ssh.rb', line 27
def self.url(name = nil)
return '' unless name
opts = Fclay.configuration.remote_storages[name]
"https://#{opts[:host]}"
end
|
Instance Method Details
#delete_files ⇒ Object
20
21
22
23
24
25
|
# File 'lib/fclay/remote_storage/ssh.rb', line 20
def delete_files
(@options[:styles].try(:keys) || [nil]).each do |style|
command = "ssh #{hosting} 'rm #{remote_file(style)}'"
system(command)
end
end
|
#hosting ⇒ Object
33
34
35
|
# File 'lib/fclay/remote_storage/ssh.rb', line 33
def hosting
"#{storage[:user]}@#{storage[:host]}"
end
|
#hosting_path ⇒ Object
37
38
39
|
# File 'lib/fclay/remote_storage/ssh.rb', line 37
def hosting_path
"#{storage[:path]}/"
end
|
#local_file(style = nil) ⇒ Object
41
42
43
|
# File 'lib/fclay/remote_storage/ssh.rb', line 41
def local_file(style = nil)
@uploading_object.local_file_path(style)
end
|
#remote_dir(style = nil) ⇒ Object
45
46
47
48
49
|
# File 'lib/fclay/remote_storage/ssh.rb', line 45
def remote_dir(style = nil)
dir = "#{hosting_path}#{@uploading_object.class.name.tableize}/"
dir += "#{style}/" if style
dir
end
|
#remote_file(style = nil) ⇒ Object
51
52
53
|
# File 'lib/fclay/remote_storage/ssh.rb', line 51
def remote_file(style = nil)
"#{hosting_path}#{@uploading_object.remote_file_path(style)}"
end
|
#upload(options = {}) ⇒ Object
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/fclay/remote_storage/ssh.rb', line 9
def upload(options = {})
(@options[:styles].try(:keys) || [nil]).each do |style|
command = "ssh #{hosting} 'mkdir -p #{remote_dir(style)}'"
system(command)
command = "scp -r #{local_file(style)} #{hosting}:#{remote_file(style)}"
system(command)
end
super unless options[:without_update]
end
|