Module: WGET
- Defined in:
- lib/wget.rb
Overview
-*- Ruby -*- URLopen 1999 by yoshidam
TODO: This module should be writen by Ruby instead of wget/lynx.
Constant Summary collapse
- PARAM =
{ 'wget' => nil, 'opts' => nil, 'http_proxy' => nil, 'ftp_proxy' => nil }
Class Method Summary collapse
Class Method Details
.open(url, *rest) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/wget.rb', line 15 def open(url, *rest) raise TypeError.new("wrong argument type #{url.inspect}" + " (expected String)") if url.class != String if url =~ /^\/|^\./ || (url !~ /^http:|^ftp:/ && FileTest.exist?(url)) File::open(url, *rest) else ENV['http_proxy'] = PARAM['http_proxy'] if PARAM['http_proxy'] ENV['ftp_proxy'] = PARAM['ftp_proxy'] if PARAM['ftp_proxy'] IO::popen(PARAM['wget'] + ' ' + PARAM['opts'] + ' ' + url) end end |