Sha256: 398531b2061bc279820583ea50960416dbb1414ae7d429068d0f4600938f470e
Contents?: true
Size: 625 Bytes
Versions: 2
Compression:
Stored size: 625 Bytes
Contents
A pretty much line-for-line port of https://github.com/sindresorhus/file-type Many thanks to Sindre Sorhus for putting this together. The module has two methods: `detect` and `read_and_detect`. The former works on String objects (when you already read stuff), the latter works on IO objects (or anything you can #read from). file_type = File.open('suspicious_file.bin', 'rb') do |f MagicBytes.read_and_detect(f) end file_type.ext #=> 'msi', someone is uploading a Windows installer... If the file type is unknown, the last-resort variant of `bin` as extension and `binary/octet-stream` will be returned.
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
magic_bytes-1.0.2 | README.md |
magic_bytes-1.0.1 | README.md |