class Sicily::Task::Base

Public Class Methods

build_command(path) click to toggle source
# File lib/sicily/task/google_photo_task.rb, line 33
def self.build_command(path)
  "upload-gphotos \"#{path}\" -u #{id} -p #{pw}"
end
cannot_op(path_dest, path_src) click to toggle source
# File lib/sicily/task/file_task.rb, line 28
def self.cannot_op(path_dest, path_src)
  forbid_new_file_in_subfolder = Sicily.config.forbid_new_file_in_subfolder
  related = Util::FileUtil.related?(path_src, path_dest)

  forbid_new_file_in_subfolder && related
end
check_if_can_operate(path_dest, path_src) click to toggle source
# File lib/sicily/task/file_task.rb, line 19
def self.check_if_can_operate(path_dest, path_src)
  return unless cannot_op(path_dest, path_src)

  msg = [
    'Cannot do file operation to child folder', "src  : #{path_src}", "dest : #{path_dest}"
  ].join('\n')
  raise msg
end
execute_command(cmd) click to toggle source
# File lib/sicily/task/google_photo_task.rb, line 29
def self.execute_command(cmd)
  `#{cmd}`
end
google_photo(path) click to toggle source
# File lib/sicily/task/google_photo_task.rb, line 23
def self.google_photo(path)
  validate_credentials!
  cmd = build_command(path)
  execute_command(cmd)
end
id() click to toggle source
# File lib/sicily/task/google_photo_task.rb, line 41
def self.id
  Sicily.config_google.id
end
prepare_dest_path(path_src, path_dest) click to toggle source
# File lib/sicily/task/file_task.rb, line 9
def self.prepare_dest_path(path_src, path_dest)
  check_if_can_operate(path_dest, path_src)

  final_dest_path = Util::FileUtil.eval_dest_path(path_src, path_dest)
  final_dest_path = File.expand_path final_dest_path
  FileUtils.mkdir_p final_dest_path

  final_dest_path
end
pw() click to toggle source
# File lib/sicily/task/google_photo_task.rb, line 37
def self.pw
  Sicily.config_google.pw
end
validate_credentials!() click to toggle source
# File lib/sicily/task/google_photo_task.rb, line 45
def self.validate_credentials!
  raise 'no google credential' if id.to_s.empty? || pw.to_s.empty?
end