Module: Icarus::Mod::Tools::Sync::Helpers

Included in:
ModinfoList, Mods, ToolinfoList, Tools
Defined in:
lib/icarus/mod/tools/sync/helpers.rb

Overview

Sync helper methods

Instance Method Summary collapse

Instance Method Details

#retrieve_from_url(url) ⇒ Object

Raises:



15
16
17
18
19
20
21
22
23
# File 'lib/icarus/mod/tools/sync/helpers.rb', line 15

def retrieve_from_url(url)
  raise RequestFailed, "Invalid URI: '#{url}'" unless url && url =~ URI::DEFAULT_PARSER.make_regexp

  res = Net::HTTP.get_response(URI(url))

  raise RequestFailed, "HTTP Request failed for #{url} (#{res.code}): #{res.message}" unless res&.code == "200"

  JSON.parse(res.body, symbolize_names: true)
end