lib/wmap/host_tracker.rb
# Save the current local hosts hash table into a (random) data repository file
Save the current local hosts hash table into a (random) data repository file
Save the current local hosts hash table into a ( random ) data repository file
def save_known_hosts_to_file!(f_hosts=@hosts_file)
		puts "Saving the local host repository from memory to file: #{f_hosts} ..."
		timestamp=Time.now
		f=File.open(f_hosts, 'w')
		f.write "# local hosts file created by the #{self.class} class #{__method__} method at: #{timestamp}"
		@known_hosts.keys.sort.map do |key|
			unless key =~ /\d+\.\d+\.\d+\.\d+/
				f.write "\n#{key}\t#{@known_hosts[key]}"
			end
		end
		f.write "\n"
		f.close
		puts "local host repository is successfully saved to: #{f_hosts}"
	end
def save_known_hosts_to_file! ( f_hosts = @hosts_file ) puts "Saving the local host repository from memory to file: #{f_hosts} ..." timestamp = Time . now f = File . open ( f_hosts , 'w' ) f . write "# local hosts file created by the #{self.class} class #{__method__} method at: #{timestamp}" @known_hosts . keys . sort . map do | key | unless key =~ / \d + \. \d + \. \d + \. \d + / f . write "\n#{key}\t#{@known_hosts[key]}" end end f . write "\n" f . close puts "local host repository is successfully saved to: #{f_hosts}" end
Save the current local hosts hash table into a (random) data repository file
Save the current local hosts hash table into a ( random ) data repository file
#rescue => ee #	puts "Exception on method #{__method__}: #{ee}"
f_hosts
<not_specific>