class Minarai::Actions::File
Public Instance Methods
call()
click to toggle source
Calls superclass method
Minarai::Actions::Base#call
# File lib/minarai/actions/file.rb, line 11 def call abort_with_runtime_error unless runnable? super end
run()
click to toggle source
# File lib/minarai/actions/file.rb, line 16 def run copy change_group unless has_valid_group? change_owner unless has_valid_owner? end
Private Instance Methods
abort_with_runtime_error()
click to toggle source
# File lib/minarai/actions/file.rb, line 32 def abort_with_runtime_error Minarai::Logger.errorr(runtime_error) and abort end
change_group()
click to toggle source
# File lib/minarai/actions/file.rb, line 68 def change_group run_specific_command(:change_file_group, destination, group) end
change_owner()
click to toggle source
# File lib/minarai/actions/file.rb, line 72 def change_owner run_specific_command(:change_file_owner, destination, owner) end
complete?()
click to toggle source
# File lib/minarai/actions/file.rb, line 40 def complete? existed_file? && same_content? end
copy()
click to toggle source
# File lib/minarai/actions/file.rb, line 24 def copy run_specific_command(:copy_file, source, destination) end
existed_file?()
click to toggle source
# File lib/minarai/actions/file.rb, line 48 def existed_file? check_specific_command(:check_file_is_file, destination) end
has_source?()
click to toggle source
# File lib/minarai/actions/file.rb, line 76 def has_source? !source.nil? end
has_valid_group?()
click to toggle source
# File lib/minarai/actions/file.rb, line 60 def has_valid_group? group.nil? || check_specific_command(:check_file_is_grouped, destination, group) end
has_valid_owner?()
click to toggle source
# File lib/minarai/actions/file.rb, line 64 def has_valid_owner? owner.nil? || check_specific_command(:check_file_is_owned_by, destination, owner) end
name()
click to toggle source
Calls superclass method
Minarai::Actions::Base#name
# File lib/minarai/actions/file.rb, line 80 def name super || "copy #{repository} to #{destination}" end
raeadable_source?()
click to toggle source
# File lib/minarai/actions/file.rb, line 44 def raeadable_source? !source.nil? && ::File.readable?(source) end
runnable?()
click to toggle source
# File lib/minarai/actions/file.rb, line 28 def runnable? readable_source? end
runtime_error()
click to toggle source
# File lib/minarai/actions/file.rb, line 36 def runtime_error Minarai::Errors::AttributeValidationError.new('source', 'is not readable file', name) end
same_content?()
click to toggle source
# File lib/minarai/actions/file.rb, line 52 def same_content? sha256_content(destination) == sha256_content(source) end
sha256_content(path)
click to toggle source
# File lib/minarai/actions/file.rb, line 56 def sha256_content(path) run_specific_command(:get_file_sha256sum, path).stdout.rstrip end