class Qa::Authorities::Geonames
Public Instance Methods
build_query_url(q)
click to toggle source
# File lib/qa/authorities/geonames.rb, line 45 def build_query_url(q) query = ERB::Util.url_encode(untaint(q)) File.join(query_url_host, "searchJSON?q=#{query}&username=#{username}&maxRows=10") end
find(id)
click to toggle source
# File lib/qa/authorities/geonames.rb, line 54 def find(id) json(find_url(id)) end
find_url(id)
click to toggle source
# File lib/qa/authorities/geonames.rb, line 58 def find_url(id) File.join(find_url_host, "getJSON?geonameId=#{id}&username=#{username}") end
search(q)
click to toggle source
# File lib/qa/authorities/geonames.rb, line 37 def search(q) unless username Rails.logger.error "Questioning Authority tried to call geonames, but no username was set" return [] end parse_authority_response(json(build_query_url(q))) end
untaint(q)
click to toggle source
# File lib/qa/authorities/geonames.rb, line 50 def untaint(q) q.gsub(/[^\w\s-]/, '') end