aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick J Cherry <patrick@bytemark.co.uk>2012-07-04 16:42:19 +0100
committerPatrick J Cherry <patrick@bytemark.co.uk>2012-07-04 16:42:19 +0100
commitf916722d4370fac1cdf46801a9cf945c4900a44c (patch)
tree76735e5e8bbc0426217aadbe6f7740dbef3c2cd0
parent780bea3eac378f7b129e4d79948f3bc2548c86cb (diff)
Added URL-ability for source lists.
-rw-r--r--lib/mauve/source_list.rb16
1 files changed, 14 insertions, 2 deletions
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