Sha256: b9e3f59d0c2513199a9b1a6a798018aa6f333c424ce011edc2df1a3d2365263d
Contents?: true
Size: 1011 Bytes
Versions: 1
Compression:
Stored size: 1011 Bytes
Contents
#!/usr/bin/env ruby # in lieu of -w, since we're using env to startup $VERBOSE = true require 'chuckle' require 'optimist' class Main attr_accessor :options def initialize(options = {}) self.options = options list = IO.readlines(options[:file]).map(&:chomp) list.each_with_index do |i, index| puts "#{index + 1}/#{list.length}. #{i}" begin chuckle.get(i) rescue Chuckle::Error => e puts " #{e.message}" end end end protected def chuckle @chuckle ||= Chuckle::Client.new(nretries: options[:nretries], timeout: options[:timeout]) end end # # parse command line # options = Optimist::options do banner <<EOF Usage: chuckle <url_file> chuckle fetches urls as listed in url_file. It just populate the disk cache. EOF opt :nretries, 'Number of retries per URL', type: Integer opt :timeout, 'Timeout per retry', type: Integer end Optimist::die 'need <url_file>' if ARGV.length != 1 options[:file] = ARGV.shift Main.new(options)
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
chuckle-1.0.9 | bin/chuckle |