Class: Geminabox::Proxy::Copier

Inherits:
FileHandler show all
Defined in:
lib/geminabox/proxy/copier.rb

Instance Attribute Summary

Attributes inherited from FileHandler

#file_name

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from FileHandler

#file_exists?, #initialize, #local_content, #local_file_exists?, #local_path, #proxy_file_exists?, #proxy_folder_name, #proxy_folder_path, #proxy_path, #remote_content, #remote_url, #root_path

Constructor Details

This class inherits a constructor from Geminabox::Proxy::FileHandler

Class Method Details

.copy(file_name) ⇒ Object



7
8
9
10
11
# File 'lib/geminabox/proxy/copier.rb', line 7

def self.copy(file_name)
  copier = new(file_name)
  copier.get_file
  copier
end

Instance Method Details

#copy_localObject



19
20
21
# File 'lib/geminabox/proxy/copier.rb', line 19

def copy_local
  FileUtils.cp local_path, proxy_path
end

#get_fileObject



13
14
15
16
17
# File 'lib/geminabox/proxy/copier.rb', line 13

def get_file
  return true if proxy_file_exists?
  return copy_local if local_file_exists?
  get_remote
end

#get_remoteObject



23
24
25
# File 'lib/geminabox/proxy/copier.rb', line 23

def get_remote
  File.open(proxy_path, 'w'){|f| f.write(remote_content)}
end