Module: Html2Odt::DimensionsPatches

Defined in:
lib/html2odt/dimensions_patches.rb

Instance Method Summary collapse

Instance Method Details

#peekObject

Default implemenation of IO#peek from GEM_PATH/dimensions-1.3.0/lib/dimensions/io.rb:

def peek
  unless no_peeking?
    read(pos + 1024) while @reader.width.nil? && pos < 6144
    rewind
  end
end

It had two problems:

a) if the file is shorter than 6144 bytes, it would keep reading infinitely b) if the width can only be detected after the 6144 limit, it would not work

as expected

Now we keep reading the file, until we can determine a width or until there’s nothing left to read.



20
21
22
23
24
25
26
27
# File 'lib/html2odt/dimensions_patches.rb', line 20

def peek
  return if no_peeking?

  while read(pos + 1024) && @reader.width.nil?
  end

  rewind
end