Project

eat

0.02
No commit activity in last 3 years
No release in over 3 years
A (better?) replacement for open-uri. Gets the contents of local and remote files as a String, no questions asked.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

 Project Readme

eat¶ ↑

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('http://yahoo.com').gets)

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

Try #eat, which ALWAYS returns a String:

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

Options¶ ↑

eat('http://yahoo.com', :timeout => 10)                   # timeout after 10 seconds
eat('http://yahoo.com', :limit => 1024)                   # only read the first 1024 chars
eat('https://yahoo.com', :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