Skip to content

Commit

Permalink
Use warn instead of puts for messages from the library code.
Browse files Browse the repository at this point in the history
`warn` has the advantage of easily being disabled by, the `-W0` interpreter
flag or setting $VERBOSE to nil.
  • Loading branch information
hainesr committed Oct 11, 2019
1 parent 34d2074 commit 340379f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions lib/zip/entry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def next_header_offset #:nodoc:all
# is passed.
def extract(dest_path = nil, &block)
if dest_path.nil? && !name_safe?
puts "WARNING: skipped #{@name} as unsafe"
warn "WARNING: skipped #{@name} as unsafe"
return self
end

Expand Down Expand Up @@ -614,7 +614,7 @@ def create_file(dest_path, _continue_on_exists_proc = proc { Zip.continue_on_exi
if ::Zip.validate_entry_sizes
raise ::Zip::EntrySizeError, message
else
puts "WARNING: #{message}"
warn "WARNING: #{message}"
warned = true
end
end
Expand Down Expand Up @@ -642,7 +642,7 @@ def create_directory(dest_path)
def create_symlink(dest_path)
# TODO: Symlinks pose security challenges. Symlink support temporarily
# removed in view of https://github.com/rubyzip/rubyzip/issues/369 .
puts "WARNING: skipped symlink #{dest_path}"
warn "WARNING: skipped symlink #{dest_path}"
end

# apply missing data from the zip64 extra information field, if present
Expand Down
2 changes: 1 addition & 1 deletion lib/zip/extra_field/generic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def initial_parse(binstr)
# If nil, start with empty.
return false
elsif binstr[0, 2] != self.class.const_get(:HEADER_ID)
$stderr.puts 'Warning: weired extra feild header ID. skip parsing'
warn 'Warning: weired extra feild header ID. skip parsing'
return false
end
[binstr[2, 2].unpack('v')[0], binstr[4..-1]]
Expand Down
2 changes: 1 addition & 1 deletion lib/zip/input_stream.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def open(filename_or_io, offset = 0, decrypter = nil)
end

def open_buffer(filename_or_io, offset = 0)
puts 'open_buffer is deprecated!!! Use open instead!'
warn 'open_buffer is deprecated!!! Use open instead!'
open(filename_or_io, offset)
end
end
Expand Down

0 comments on commit 340379f

Please sign in to comment.