Class: Sicily::Task::Base
- Inherits:
-
Object
- Object
- Sicily::Task::Base
- Defined in:
- lib/sicily/task/file_task.rb,
lib/sicily/task/google_photo_task.rb
Class Method Summary collapse
- .build_command(path) ⇒ Object
- .cannot_op(path_dest, path_src) ⇒ Object
- .check_if_can_operate(path_dest, path_src) ⇒ Object
- .execute_command(cmd) ⇒ Object
- .google_photo(path) ⇒ Object
- .id ⇒ Object
- .prepare_dest_path(path_src, path_dest) ⇒ Object
- .pw ⇒ Object
- .validate_credentials! ⇒ Object
Class Method Details
.build_command(path) ⇒ Object
33 34 35 |
# 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) ⇒ Object
28 29 30 31 32 33 |
# 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 = Util::FileUtil.(path_src, path_dest) forbid_new_file_in_subfolder && end |
.check_if_can_operate(path_dest, path_src) ⇒ Object
19 20 21 22 23 24 25 26 |
# 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) ⇒ Object
29 30 31 |
# File 'lib/sicily/task/google_photo_task.rb', line 29 def self.execute_command(cmd) `#{cmd}` end |
.google_photo(path) ⇒ Object
23 24 25 26 27 |
# 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 ⇒ Object
41 42 43 |
# 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) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# 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. final_dest_path FileUtils.mkdir_p final_dest_path final_dest_path end |
.pw ⇒ Object
37 38 39 |
# File 'lib/sicily/task/google_photo_task.rb', line 37 def self.pw Sicily.config_google.pw end |
.validate_credentials! ⇒ Object
45 46 47 |
# 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 |