Sha256: 6c5d21b5a3f4179e78516ed8518ac14fac80e5812d605befe84c039e1b3cb707

Contents?: true

Size: 1.15 KB

Versions: 2

Compression:

Stored size: 1.15 KB

Contents

=eat

Problems with the standard <tt>open-uri</tt> library

* sometimes it returns <tt>String</tt> and sometimes <tt>StringIO</tt> (check out <tt>OpenURI::Buffer::StringMax</tt>, usually 10,240 bytes)
* sometimes you have to call <tt>gets</tt> (for example <tt>open('http://yahoo.com').gets</tt>)
* it overrides <tt>#open</tt> everywhere, which may be confusing.

Try <tt>#eat</tt>, which ALWAYS returns a <tt>String</tt>:

    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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
eat-0.1.2 README.rdoc
eat-0.1.1 README.rdoc