class Bdsync::Lfs
Public Class Methods
new(params)
click to toggle source
Calls superclass method
Bdsync::Core::new
# File lib/bdsync/lfs.rb, line 6 def initialize params super params, "lfs" end
options()
click to toggle source
# File lib/bdsync/lfs.rb, line 10 def self.options Core.options end
Public Instance Methods
create_remote_file(remote_path, content)
click to toggle source
for test
# File lib/bdsync/lfs.rb, line 94 def create_remote_file remote_path, content File.write remote_path, content end
download_file(local_path, remote_path)
click to toggle source
# File lib/bdsync/lfs.rb, line 44 def download_file local_path, remote_path local_ensure_parent local_path puts "#{Utils.caller_info 1} cp #{remote_path}, #{local_path}".white FileUtils.cp remote_path, local_path end
get_remote_file_md5(path)
click to toggle source
# File lib/bdsync/lfs.rb, line 89 def get_remote_file_md5 path Utils.file_md5 path end
remote_dir_foreach(remote_path) { |open_struct name: filename, attributes: open_struct( directory?: directory?(file_path), mtime: mtime.to_i| ... }
click to toggle source
yield object like this {
name: attributes: { directory?: mtime: }
}
# File lib/bdsync/lfs.rb, line 22 def remote_dir_foreach remote_path Dir.foreach(remote_path) { |filename| file_path = "#{remote_path}/#{filename}" yield OpenStruct.new name: filename, attributes: OpenStruct.new( directory?: File.directory?(file_path), mtime: File.mtime(file_path).to_i ) } end
remote_ensure_dir(path)
click to toggle source
# File lib/bdsync/lfs.rb, line 81 def remote_ensure_dir path local_ensure_dir path end
remote_ensure_parent(path)
click to toggle source
# File lib/bdsync/lfs.rb, line 85 def remote_ensure_parent path local_ensure_parent path end
remote_get_object(remote_path)
click to toggle source
# File lib/bdsync/lfs.rb, line 33 def remote_get_object remote_path stat = File.lstat remote_path OpenStruct.new( directory?: stat.directory?, mtime: stat.mtime.to_i ) rescue Errno::ENOENT nil end
remote_mkdir(remote_path)
click to toggle source
# File lib/bdsync/lfs.rb, line 60 def remote_mkdir remote_path puts "#{Utils.caller_info 1} mkdir #{remote_path}".white FileUtils.mkdir remote_path remote_get_object remote_path end
remote_remove_dir(remote_path)
click to toggle source
# File lib/bdsync/lfs.rb, line 71 def remote_remove_dir remote_path puts "#{Utils.caller_info 1} rm_rf #{remote_path}".white FileUtils.rm_rf remote_path end
remote_remove_file(remote_path)
click to toggle source
# File lib/bdsync/lfs.rb, line 66 def remote_remove_file remote_path puts "#{Utils.caller_info 1} rm #{remote_path}".white FileUtils.rm remote_path end
remote_rename(remote_path, new_remote_path)
click to toggle source
# File lib/bdsync/lfs.rb, line 76 def remote_rename remote_path, new_remote_path puts "#{Utils.caller_info 1} mv #{remote_path} #{new_remote_path}".yellow FileUtils.mv remote_path, new_remote_path end
upload_file(local_path, remote_path)
click to toggle source
# File lib/bdsync/lfs.rb, line 51 def upload_file local_path, remote_path remote_ensure_parent remote_path puts "#{Utils.caller_info 1} cp #{local_path}, #{remote_path}".white FileUtils.cp local_path, remote_path remote_get_object remote_path end