Method: Onceover::VendoredModules#query_or_cache

Defined in:
lib/onceover/vendored_modules.rb

#query_or_cache(url, params, filepath) ⇒ Object

Return json from a query whom caches, or from the cache to avoid spamming github



141
142
143
144
145
146
147
148
149
150
151
152
# File 'lib/onceover/vendored_modules.rb', line 141

def query_or_cache(url, params, filepath)
  if (File.exist? filepath) && (@force_update == false)
    logger.debug "Using cache: #{filepath}"
    json = read_json_dump(filepath)
  else
    logger.debug "Making GET request to: #{url}"
    json = github_get(url, params)
    logger.debug "Caching response to: #{filepath}"
    write_json_dump(filepath, json)
  end
  json
end