class Plagiarism::Strategies::Google

Constants

URL
VERSION

Public Class Methods

fetch(content, params) click to toggle source
# File lib/plagiarism/strategries/google.rb, line 9
def fetch(content, params)
  Typhoeus.get URL, params: params.merge(
    key: Config.google_key,
    cx: Config.google_cx,
    q: content,
    fields: 'items(link)',
    prettyPrint: false
  )
end
iterate(response, action = :all?) { |uri| ... } click to toggle source
# File lib/plagiarism/strategries/google.rb, line 19
def iterate(response, action = :all?)
  results = JSON.parse(response)['items'] || []
  results.send(action) do |r|
    uri = URI.parse URI::encode(r['link'])
    yield uri
  end
end