# File lib/genome-bootstrap/ddns.rb, line 55 def fetch_hash(options={:tries => 3}) options[:tries].times do # In order to test the regex with mocha we can't rely on the # return value from the main_page method. That's why I # declare 'hash' here and store the results from inside the # block hash = nil main_page do |html| hash = /#{@hostname}<\/pre>.*?hash=(.*)\"/.match(html)[1] rescue nil end return hash if hash puts "Hash not found for #{@hostname}" request_new_hash end raise RuntimeError.new("Error fetching DDNS hash:\n" + "This usually happens when a hostname is reserved under another " + "user's account or you typed password incorrectly.") end