Sha256: f06143b2d27ae40b1c3f0d8581e2a4ebcb616deeba6840b42d8664e62d5abf44

Contents?: true

Size: 1.15 KB

Versions: 6

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

6 entries across 6 versions & 1 rubygems

Version Path
eat-0.1.8 README.rdoc
eat-0.1.7 README.rdoc
eat-0.1.6 README.rdoc
eat-0.1.5 README.rdoc
eat-0.1.4 README.rdoc
eat-0.1.3 README.rdoc