Commit 66c3c660 by Daniel Mendler

Merge pull request #14 from wbond/master

Fixed for Ruby 2.0
parents 89bb5162 29e48a84
......@@ -17,6 +17,15 @@ API
http://rdoc.info/github/minad/mimemagic/frames/file/README
Tests
=====
```
bundle install
rake test
```
Authors
=======
......
......@@ -109,12 +109,17 @@ class MimeMagic
def self.magic_match(io, matches)
matches.any? do |offset, value, children|
value = value.b if value.respond_to?(:b)
match = if Range === offset
io.seek(offset.begin)
io.read(offset.end - offset.begin + value.length).include?(value)
io_val = io.read(offset.end - offset.begin + value.length)
io_val = io_val.b if io_val.respond_to?(:b)
io_val.include?(value)
else
io.seek(offset)
value == io.read(value.length)
io_val = io.read(value.length)
io_val = io_val.b if io_val.respond_to?(:b)
value == io_val
end
match && (!children || magic_match(io, children))
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment