lib/tasks/arabic_wordnet_db.rake
### Download the file at +sourceuri+ via HTTP and write it to +targetfile+.
Download the file at +sourceuri+ via HTTP and write it to +targetfile+.
Download the file at + sourceuri + via HTTP and write it to + targetfile + .
def download( sourceuri, targetfile=nil )
  oldsync = $stdout.sync
  $stdout.sync = true
  require 'open-uri'
  require 'pathname'
  targetpath = Pathname.new(targetfile)
  $stderr.puts "Downloading %s to %s" % [sourceuri, targetfile]
  $stderr.puts "  connecting..." if $trace
  ifh = open( sourceuri ) do |ifh|
    $stderr.puts "  connected..." if $trace
    targetpath.open( File::WRONLY|File::TRUNC|File::CREAT, 0644 ) do |ofh|
      $stderr.puts "Downloading..."
      buf = ''
      while ifh.read( 16384, buf )
        until buf.empty?
          bytes = ofh.write( buf )
          buf.slice!( 0, bytes )
        end
      end
      $stderr.puts "Done."
    end
  end
  return targetpath
ensure
  $stdout.sync = oldsync
end
def download ( sourceuri , targetfile = nil ) oldsync = $stdout . sync $stdout . sync = true require 'open-uri' require 'pathname' targetpath = Pathname . new ( targetfile ) $stderr . puts "Downloading %s to %s" % [ sourceuri , targetfile ] $stderr . puts "  connecting..." if $trace ifh = open ( sourceuri ) do | ifh | $stderr . puts "  connected..." if $trace targetpath . open ( File :: WRONLY | File :: TRUNC | File :: CREAT , 0644 ) do | ofh | $stderr . puts "Downloading..." buf = '' while ifh . read ( 16384 , buf ) until buf . empty? bytes = ofh . write ( buf ) buf . slice! ( 0 , bytes ) end end $stderr . puts "Done." end end return targetpath ensure $stdout . sync = oldsync end
Download the file at +sourceuri+ via HTTP and write it to +targetfile+.
Download the file at + sourceuri + via HTTP and write it to + targetfile + .
sourceuri
<not_specific>
targetfile
<not_specific>