class Serverkit::Resources::Entry
Abstract class for file and directory
Public Instance Methods
Source
# File lib/serverkit/resources/entry.rb, line 18 def apply update_entry unless has_correct_entry? update_group unless has_correct_group? update_mode unless has_correct_mode? update_owner unless has_correct_owner? end
@note Override
Source
# File lib/serverkit/resources/entry.rb, line 26 def check has_correct_entry? && has_correct_group? && has_correct_mode? && has_correct_owner? end
@note Override
Private Instance Methods
Source
# File lib/serverkit/resources/entry.rb, line 34 def destination raise NotImplementedError end
@note Override me @return [String] Path to the entry on remote side
Source
# File lib/serverkit/resources/entry.rb, line 38 def has_correct_content? content.nil? || remote_file_sha256sum == local_content_sha256sum end
Source
# File lib/serverkit/resources/entry.rb, line 43 def has_correct_entry? raise NotImplementedError end
@note Override me
Source
# File lib/serverkit/resources/entry.rb, line 47 def has_correct_group? group.nil? || check_command_from_identifier(:check_file_is_grouped, destination, group) end
Source
# File lib/serverkit/resources/entry.rb, line 51 def has_correct_mode? mode.nil? || check_command_from_identifier(:check_file_has_mode, destination, mode_in_octal_notation) end
Source
# File lib/serverkit/resources/entry.rb, line 55 def has_correct_owner? owner.nil? || check_command_from_identifier(:check_file_is_owned_by, destination, owner) end
Source
# File lib/serverkit/resources/entry.rb, line 59 def has_remote_file? check_command_from_identifier(:check_file_is_file, destination) end
Source
# File lib/serverkit/resources/entry.rb, line 64 def local_content_sha256sum ::Digest::SHA256.hexdigest(content) end
@return [String]
Source
# File lib/serverkit/resources/entry.rb, line 70 def mode_in_octal_notation if mode.is_a?(Integer) mode.to_s(8) else mode end end
@return [String] @example “755” # for 0755
Source
# File lib/serverkit/resources/entry.rb, line 79 def remote_file_sha256sum run_command_from_identifier(:get_file_sha256sum, destination).stdout.rstrip end
@return [String]
Source
# File lib/serverkit/resources/entry.rb, line 83 def send_content_to_destination ::Tempfile.open("") do |file| file.write(content || "") file.close backend.send_file(file.path, destination) end end
Source
# File lib/serverkit/resources/entry.rb, line 92 def update_entry raise NotImplementedError end
@note Override me
Source
# File lib/serverkit/resources/entry.rb, line 96 def update_group run_command_from_identifier(:change_file_group, destination, group) end
Source
# File lib/serverkit/resources/entry.rb, line 100 def update_mode run_command_from_identifier(:change_file_mode, destination, mode_in_octal_notation) end
Source
# File lib/serverkit/resources/entry.rb, line 104 def update_owner run_command_from_identifier(:change_file_owner, destination, owner) end