Sha256: a2f9d99c418f82ed90bd97cfd08fd91ab212357d25d8b2ec47ca55626d7687da

Contents?: true

Size: 1.67 KB

Versions: 12

Compression:

Stored size: 1.67 KB

Contents

#!/usr/bin/env ruby
# Executable to bulk add sites into the tracking data repository
require "wmap"
require "optparse"

# program command line options
options = {:data_dir => nil, :target => nil, :verbose => false}
parser = OptionParser.new do|opts|
	opts.banner = Wmap.banner
	opts.on('-d', '--data_dir data_dir', 'Web Mapper local cache data directory') do |data_dir|
		options[:data_dir] = data_dir;
	end
	opts.on('-t', '--target target', 'Web Mapper target') do |target|
		options[:target] = target;
	end
	opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
		options[:verbose] = v;
	end
	opts.on('-h', '--help', 'Displays Help') do
		puts opts
		exit 0
	end
end
parser.parse!
puts Wmap.banner

if options[:data_dir]
	# Log the command entry
	Log_dir = Pathname.new(options[:data_dir]).join('logs')
else
	Log_dir=Pathname.new(Gem.loaded_specs['wmap'].full_gem_path).join('logs')
end
Dir.mkdir(Log_dir) unless Dir.exist?(Log_dir)

Wmap.wlog("Execute the command: wadds #{options[:target]}","wadds",Log_dir+"wmap.log")

if File.exist?(options[:target]) && options[:data_dir]
	puts puts "Invoke the SiteTracker."
	st=Wmap::SiteTracker.instance
	st.verbose=options[:verbose]
	st.data_dir = options[:data_dir]
	st.sites_file = st.data_dir + "/" + "sites"
	st.load_site_stores_from_file(st.sites_file)
else
	aborts "Error firing up SiteTracker instance!"
end

# Evaluate the argument and update the data store accordingly
sites=st.file_2_list(options[:target]).map { |x| st.url_2_site(x) }
if sites.length > 0
	news=st.adds(sites)
	puts news
	st.save! if news.length>0
	st=nil
else
	st=nil
	abort "No site entry found in file: #{options[:target]}. Please check your file format to ensure one site per line."
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
wmap-2.8.6 bin/wadds
wmap-2.8.5 bin/wadds
wmap-2.8.4 bin/wadds
wmap-2.8.3 bin/wadds
wmap-2.8.2 bin/wadds
wmap-2.8.1 bin/wadds
wmap-2.7.9 bin/wadds
wmap-2.7.7 bin/wadds
wmap-2.7.6 bin/wadds
wmap-2.7.2 bin/wadds
wmap-2.7.1 bin/wadds
wmap-2.7.0 bin/wadds