Merge pull request #464 from hainesr/remove_dosequals
Replace and deprecate `Zip::DOSTime#dos_equals`.
This commit is contained in:
commit
7f3bb29487
|
@ -24,9 +24,14 @@ module Zip
|
|||
((year - 1980) << 9)
|
||||
end
|
||||
|
||||
# Dos time is only stored with two seconds accuracy
|
||||
def dos_equals(other)
|
||||
to_i / 2 == other.to_i / 2
|
||||
warn 'Zip::DOSTime#dos_equals is deprecated. Use `==` instead.'
|
||||
self == other
|
||||
end
|
||||
|
||||
# Dos time is only stored with two seconds accuracy.
|
||||
def <=>(other)
|
||||
(to_i / 2) <=> (other.to_i / 2)
|
||||
end
|
||||
|
||||
# Create a DOSTime instance from a vanilla Time instance.
|
||||
|
|
|
@ -530,10 +530,9 @@ module Zip
|
|||
return false unless other.class == self.class
|
||||
|
||||
# Compares contents of local entry and exposed fields
|
||||
keys_equal = %w[compression_method crc compressed_size size name extra filepath].all? do |k|
|
||||
%w[compression_method crc compressed_size size name extra filepath time].all? do |k|
|
||||
other.__send__(k.to_sym) == __send__(k.to_sym)
|
||||
end
|
||||
keys_equal && time.dos_equals(other.time)
|
||||
end
|
||||
|
||||
def <=>(other)
|
||||
|
|
|
@ -102,7 +102,7 @@ class ZipOutputStreamTest < MiniTest::Test
|
|||
::Zip::InputStream.open(TEST_ZIP.zip_name) do |io|
|
||||
while (entry = io.get_next_entry)
|
||||
# Compare DOS Times, since they are stored with two seconds accuracy
|
||||
assert(::Zip::DOSTime.at(file.mtime).dos_equals(::Zip::DOSTime.at(entry.mtime)))
|
||||
assert(::Zip::DOSTime.at(file.mtime) == ::Zip::DOSTime.at(entry.mtime))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue