From 5a59d856d49d3c599430ccb1f1013d2cafa8787f Mon Sep 17 00:00:00 2001 From: LeEnno Date: Mon, 14 Dec 2015 13:13:06 +0100 Subject: [PATCH] introduce skip_cookie_file option --- lib/inwx/domrobot.rb | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/lib/inwx/domrobot.rb b/lib/inwx/domrobot.rb index 64587e8..989fe0b 100644 --- a/lib/inwx/domrobot.rb +++ b/lib/inwx/domrobot.rb @@ -4,7 +4,8 @@ module INWX class Domrobot attr_accessor :client, :cookie - def initialize(address) + def initialize(address, options = {}) + @options = options @cookie = "" # Create a new client instance @client = XMLRPC::Client.new(address,"/xmlrpc/","443", nil, nil, nil, nil, true, 100) @@ -26,20 +27,24 @@ def logout() def setCookie(cookie) self.cookie = cookie - fp = File.new("domrobot.tmp", "w") - fp.write(cookie) - fp.close + unless @options[:skip_cookie_file] + fp = File.new("domrobot.tmp", "w") + fp.write(cookie) + fp.close + end end def getCookie() if self.cookie.length > 2 return self.cookie end - if File.exist?("domrobot.tmp") - fp = File.new("domrobot.tmp", "r") - cookie = fp.read() - fp.close - return cookie + unless @options[:skip_cookie_file] + if File.exist?("domrobot.tmp") + fp = File.new("domrobot.tmp", "r") + cookie = fp.read() + fp.close + return cookie + end end end