#!/usr/bin/env ruby # Executable to add a new site into the tracking data repository # This is useful as a self-correction mechanism to flag out unique website in a constant way require "wmap" def print_usage puts "Program to add an entry into the local data repository. Usage: wadd <site> [data_dir]" end puts Wmap.banner print_usage if ARGV.length == 1 # Log the command entry Log_dir = File.dirname(__FILE__) + '/../logs/' elsif ARGV.length == 2 # Log to the instance running directory Log_dir = File.dirname(__FILE__) + '/../logs/' + ARGV[1] else Log_dir = File.dirname(__FILE__) + '/../logs/' end Dir.mkdir(Log_dir) unless Dir.exist?(Log_dir) Wmap.wlog("Execute the command: wadd #{ARGV[0]}","wadd",Log_dir+"wmap.log") if ARGV.length == 1 puts puts "Invoke the SiteTracker." st=Wmap::SiteTracker.instance st.verbose=false elsif ARGV.length == 2 puts puts "Invoke the SiteTracker." st=Wmap::SiteTracker.instance st.verbose=false st.data_dir=ARGV[1] else aborts "Error firing up SiteTracker instance!" end # Evaluate the argument and update the data store accordingly if st.is_site?(ARGV[0]) st.add(ARGV[0]) st.save! st=nil else abort "Unknown argument format: #{ARGV[0]}" end