Skip to content
A (better?) replacement for open-uri. Lets you open local and remote files by immediately returning their contents as a string.



Problems with the standard open-uri library

  • sometimes it returns String and sometimes StringIO (check out OpenURI::Buffer::StringMax, usually 10,240 bytes)

  • sometimes you have to call gets (for example open('').gets)

  • it overrides #open everywhere, which may be confusing.

Try #eat, which ALWAYS returns a String:

require 'eat'
eat('')                 #=> String
eat('/home/seamus/foo.txt')             #=> String
eat('file:///home/seamus/foo.txt')      #=> String


eat('', :timeout => 10)                   # timeout after 10 seconds
eat('', :limit => 1024)                   # only read the first 1024 chars
eat('', :openssl_verify_mode => 'none')  # don't bother verifying SSL certificate

Warning: DOES verify SSL certs

If you want to disable verification of SSL certificates, use

:openssl_verify_mode => 'none'

Thanks @codahale and @peterc for their suggestions.

Supported schemas

  • local filesystem

  • http

  • https

Copyright 2011 Seamus Abshere

Something went wrong with that request. Please try again.