diff options
-rw-r--r-- | lib/mirror_toolkit.rb | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/mirror_toolkit.rb b/lib/mirror_toolkit.rb index fd854e0..8e1cde5 100644 --- a/lib/mirror_toolkit.rb +++ b/lib/mirror_toolkit.rb @@ -25,13 +25,26 @@ module MirrorToolkit end end + def curl(uri) + stdin, stdout, stderr, wait_thr = Open3.popen3('curl', uri) + stdin.close + + if wait_thr.value == 0 + return stdout.gets + else + fail "curl call unsuccessful: '#{stderr.gets.chomp}'" + end + end + # Fetches a URI from any of the Gentoo mirror types def remote_fetch(url) case url.scheme when 'rsync' rsync_cat(url.to_s) - when 'http', 'https', 'ftp' + when 'http', 'https' Net::HTTP.get(url) + when 'ftp' + curl(url.to_s) else fail 'Unknown URI scheme.' end |