#! /usr/bin/env ruby require 'cablegator' require 'fileutils' dir_prefix = ARGV[0] || Dir.pwd puts "Downloading cables to #{File.expand_path(dir_prefix)}" WikiLeaks.with_each_cable do |cable_url| file_location = File.expand_path(dir_prefix + cable_url) reference_id = WikiLeaks.reference_id(cable_url) if !File.exist?(file_location) FileUtils.mkdir_p(File.dirname(file_location)) STDOUT.puts "Downloading cable #{reference_id} to #{file_location}" File.open(file_location, 'w') { |f| f << WikiLeaks.get(cable_url) } else STDOUT.puts "You already have #{reference_id} in #{file_location}" end end