lib/term_extraction/yahoo.rb in alexrabarts-term_extraction-0.1.2 vs lib/term_extraction/yahoo.rb in alexrabarts-term_extraction-0.1.3

- old
+ new

@@ -1,6 +1,8 @@ require 'nokogiri' +require 'addressable/uri' +require 'open-uri' class TermExtraction class Yahoo < TermExtraction def terms terms = [] @@ -11,12 +13,22 @@ terms << n.text end end terms - end + end + def uri + api_uri = Addressable::URI.parse(gateway) + api_uri.query_values = { + 'appid' => @api_key, + 'output' => 'xml', + 'context' => @context + } + api_uri + end + class << self def canonical_name 'yahoo' end end @@ -28,21 +40,10 @@ def gateway 'http://search.yahooapis.com/ContentAnalysisService/V1/termExtraction' end - def url - uri = Addressable::URI.parse(gateway) - uri.query_values = { - # TODO: Change appid to the BMP one - 'appid' => @api_key, - 'output' => 'xml', - 'context' => @context - } - uri - end - def remote_xml - open(url).read + open(uri).read end end end \ No newline at end of file