# File lib/commands/plugin/recursive_http_fetcher.rb, line 43 def download(link) puts "+ #{File.join(@cwd, File.basename(link))}" unless @quiet open(link) do |stream| File.open(File.join(@cwd, File.basename(link)), "wb") do |file| file.write(stream.read) end end end
# File lib/commands/plugin/recursive_http_fetcher.rb, line 52 def fetch(links = @urls_to_fetch) links.each do |l| (l =~ /\/$/ || links == @urls_to_fetch) ? fetch_dir(l) : download(l) end end
# File lib/commands/plugin/recursive_http_fetcher.rb, line 58 def fetch_dir(url) push_d(File.basename(url)) open(url) do |stream| contents = stream.read fetch(links(url, contents)) end pop_d end
# File lib/commands/plugin/recursive_http_fetcher.rb, line 33 def links(base_url, contents) links = [] contents.scan(/href\s*=\s*\"*[^\">]*/) do |link| link = link.sub(/href="/, "") next if link =~ /^http/ || link =~ /^\./ links << File.join(base_url, link) end links end
# File lib/commands/plugin/recursive_http_fetcher.rb, line 12 def ls @urls_to_fetch.collect do |url| if url =~ /^svn:\/\/.*/ `svn ls #{url}`.split("\n").map {|entry| "/#{entry}"} rescue nil else open(url) do |stream| links("", stream.read) end rescue nil end end.flatten end
Generated with the Darkfish Rdoc Generator 2.