From f916722d4370fac1cdf46801a9cf945c4900a44c Mon Sep 17 00:00:00 2001 From: Patrick J Cherry Date: Wed, 4 Jul 2012 16:42:19 +0100 Subject: Added URL-ability for source lists. --- lib/mauve/source_list.rb | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'lib/mauve') diff --git a/lib/mauve/source_list.rb b/lib/mauve/source_list.rb index a6baa2b..8248758 100644 --- a/lib/mauve/source_list.rb +++ b/lib/mauve/source_list.rb @@ -4,6 +4,7 @@ require 'ipaddr' require 'uri' require 'mauve/mauve_time' require 'mauve/mauve_resolv' +require 'mauve/generic_http_api_client' module Mauve @@ -22,11 +23,12 @@ module Mauve attr_reader :label, :last_resolved_at ## Default contructor. - def initialize (label) + def initialize (label, url = nil) @label = label @last_resolved_at = nil @list = [] @resolved_list = [] + @url = url end alias username label @@ -177,8 +179,16 @@ module Mauve # def resolve @last_resolved_at = Time.now + + url_list = [] + if @url + url_list_s = GenericHttpApiClient.do_get(@url) + if url_list_s.is_a?(String) + url_list = url_list_s.split("\n").reject{|s| s.empty?} + end + end - new_list = @list.collect do |host| + new_list = [url_list + @list].collect do |host| if host.is_a?(String) [host] + MauveResolv.get_ips_for(host).collect{|i| IPAddr.new(i)} else @@ -186,8 +196,10 @@ module Mauve end end + @resolved_list = new_list.flatten end + end end -- cgit v1.2.1