lib/epub/maker/ocf/physical_container.rb in epub-maker-0.1.4 vs lib/epub/maker/ocf/physical_container.rb in epub-maker-0.1.5
- old
+ new
@@ -11,18 +11,36 @@
module EPUB
class OCF
class PhysicalContainer
class << self
+ @@mtime = nil
+
+ def mtime
+ @@mtime
+ end
+
+ # Sets +mtime+, which is used when setting mtime of file in EPUB(ZIP) archive.
+ # Currently supported for only {ArchiveZip} adapter
+ #
+ # @example
+ # EPUB::OCF::PhysicalCotainer.adapter = :ArchiveZip
+ # EPUB::OCF::PhysicalCotainer.mtime = Time.new(2020, 1, 1)
+ #
+ # @return [Time]
+ def mtime=(time)
+ @@mtime = time
+ end
+
def write(container_path, path_name, content)
open(container_path) {|container|
- container.write(path_name, content)
+ container.write(path_name, content, mtime: mtime)
}
end
def save(container_path, path_name, content)
warn "EPUB::OCF::PhysicalContainer.#{__method__} is deprecated. Use .write instead"
- write(container_path, path_name, content)
+ write(container_path, path_name, content, mtime: mtime)
end
end
end
end
end