Module: FileCompare
- Defined in:
- lib/file_compare.rb,
lib/file_compare/version.rb
Constant Summary collapse
- VERSION =
"0.1.1"
Class Method Summary collapse
-
.compare_files(left_file_path, right_file_path) ⇒ Object
Public: Returns true/false if files match.
-
.get_fingerprint(file_path) ⇒ Object
Public: Returns SHA256 finger print of provided file.
Class Method Details
.compare_files(left_file_path, right_file_path) ⇒ Object
Public: Returns true/false if files match
left_file_path - Path to the left file right_file_path - Path to the right file
Examples
FileCompare.compare_files(left_file_path, right_file_path)
=> true/false
Returns bool
28 29 30 31 32 |
# File 'lib/file_compare.rb', line 28 def self.compare_files(left_file_path, right_file_path) left_digest = get_fingerprint(left_file_path) right_digest = get_fingerprint(right_file_path) left_digest == right_digest end |
.get_fingerprint(file_path) ⇒ Object
Public: Returns SHA256 finger print of provided file
file_path - Path to the file
Examples
FileCompare.get_fingerprint(file_path)
=> 069f850d97ac8e2d731aaad52b0d090e47c483ee
Returns string
14 15 16 |
# File 'lib/file_compare.rb', line 14 def self.get_fingerprint(file_path) Digest::SHA256.file(file_path).hexdigest end |