Handle passing an IO to Zip::File.new better.

This now actually extracts the path from the IO if one is passed in.
This commit is contained in:
Robert Haines 2018-04-03 23:48:54 +01:00
parent 7cd263e6a0
commit cfa9441914
1 changed files with 2 additions and 2 deletions

View File

@ -64,9 +64,9 @@ module Zip
# Opens a zip archive. Pass true as the second parameter to create
# a new archive if it doesn't exist already.
def initialize(file_name, create = false, buffer = false, options = {})
def initialize(path_or_io, create = false, buffer = false, options = {})
super()
@name = file_name
@name = path_or_io.respond_to?(:path) ? path_or_io.path : path_or_io
@comment = ''
@create = create ? true : false # allow any truthy value to mean true
if !buffer && ::File.size?(@name)