Class: S3diff::Comparator
- Inherits:
-
Object
- Object
- S3diff::Comparator
- Defined in:
- lib/s3diff/comparator.rb
Instance Method Summary collapse
- #both_exist? ⇒ Boolean
- #diff ⇒ Object
-
#initialize(file1, file2, s3_options = {}) ⇒ Comparator
constructor
A new instance of Comparator.
- #same? ⇒ Boolean
- #same_etag? ⇒ Boolean
Constructor Details
#initialize(file1, file2, s3_options = {}) ⇒ Comparator
Returns a new instance of Comparator.
5 6 7 8 9 |
# File 'lib/s3diff/comparator.rb', line 5 def initialize(file1, file2, = {}) @s3_options = @file1 = file_object(file1) @file2 = file_object(file2) end |
Instance Method Details
#both_exist? ⇒ Boolean
11 12 13 14 15 16 17 |
# File 'lib/s3diff/comparator.rb', line 11 def both_exist? @both_exist ||= begin puts "#{@file1.original_path} is not exist." unless @file1.exist? puts "#{@file2.original_path} is not exist." unless @file2.exist? @file1.exist? && @file2.exist? end end |
#diff ⇒ Object
27 28 29 |
# File 'lib/s3diff/comparator.rb', line 27 def diff @diff ||= Diffy::Diff.new(@file1.path, @file2.path, source: "files") end |
#same? ⇒ Boolean
23 24 25 |
# File 'lib/s3diff/comparator.rb', line 23 def same? same_etag? || diff.to_s.empty? end |
#same_etag? ⇒ Boolean
19 20 21 |
# File 'lib/s3diff/comparator.rb', line 19 def same_etag? both_exist? && @file1.etag == @file2.etag end |