lib/hosts_updater.rb
# Download files mentioned in SOURCES and combine them into one saved as hosts_auto_location.
# Any comments and duplicates are ommited from original files.
Download files mentioned in SOURCES and combine them into one saved as hosts_auto_location.
Any comments and duplicates are ommited from original files.
Download files mentioned in SOURCES and combine them into one saved as hosts_auto_location . Any comments and duplicates are ommited from original files .
def update_auto_file
    elements = []
    @options[:sources].each do |source_key, source_data|
      next unless source_data
      elements += download_source(source_data)
    end
    hosts = Hosts::File.new
    hosts.elements = elements.uniq(&:name).sort { |e1,e2| e1.name <=> e2.name }
    hosts.elements.insert 0, Hosts::Comment.new(' This file was auto-generated by hosts-updater.')
    hosts.elements.insert 1, Hosts::Comment.new(' Changes to this file may cause incorrect behavior and will be lost if the code is regenerated.')
    hosts.elements.insert 2, Hosts::EmptyElement.new
    File.write(hosts_auto_location, hosts.to_s(:force_generation => true))
  end
def update_auto_file elements = [ ] @options [ :sources ] . each do | source_key , source_data | next unless source_data elements += download_source ( source_data ) end hosts = Hosts :: File . new hosts . elements = elements . uniq ( & :name ) . sort { | e1 , e2 | e1 . name <=> e2 . name } hosts . elements . insert 0 , Hosts :: Comment . new ( ' This file was auto-generated by hosts-updater.' ) hosts . elements . insert 1 , Hosts :: Comment . new ( ' Changes to this file may cause incorrect behavior and will be lost if the code is regenerated.' ) hosts . elements . insert 2 , Hosts :: EmptyElement . new File . write ( hosts_auto_location , hosts . to_s ( :force_generation => true ) ) end
Download files mentioned in SOURCES and combine them into one saved as hosts_auto_location.
Download files mentioned in SOURCES and combine them into one saved as hosts_auto_location .