Sha256: fffe1e741f52018e80cd2ecfdee552d8f5202b7fcebb6619eef4a4bafc895226
Contents?: true
Size: 527 Bytes
Versions: 2
Compression:
Stored size: 527 Bytes
Contents
# frozen_string_literal: true require "uri" require "net/http" require "json" module Icarus module Mod module Tools # Sync helper methods module SyncHelpers class RequestFailed < StandardError; end def retrieve_from_url(url) 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 end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
Icarus-Mod-Tools-1.3.5 | lib/icarus/mod/tools/sync_helpers.rb |
Icarus-Mod-Tools-1.3.4 | lib/icarus/mod/tools/sync_helpers.rb |