Sha256: dd8915a91300d8fa7c572e03f8e8939fc33d1bbab4539c61f91f74b125a3dcb4

Contents?: true

Size: 627 Bytes

Versions: 1

Compression:

Stored size: 627 Bytes

Contents

#! /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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cablegator-1.0.0 bin/download_cables