Sha256: 768923f89fa93650a6db61b41617e5666d8e59dc2c078c29dd85ca8725bfa29f
Contents?: true
Size: 1.21 KB
Versions: 4
Compression:
Stored size: 1.21 KB
Contents
# frozen_string_literal: true require "firestore" require "tools/sync_helpers" module Icarus module Mod module Tools # Sync methods class ModSync include SyncHelpers def initialize @firestore = Firestore.new end def mods @firestore.mods end def modinfo_array @modinfo_array ||= @firestore.modinfo_array.map do |url| retrieve_from_url(url)[:mods].map { |mod| Modinfo.new(mod) if mod[:name] =~ /[a-z0-9]+/i } rescue Icarus::Mod::Tools::RequestFailed warn "Skipped; Failed to retrieve #{url}" next rescue JSON::ParserError => e warn "Skipped; Invalid JSON: #{e.full_message}" next end.flatten.compact end def find_mod(modinfo) @firestore.find_mod(name: modinfo.name, author: modinfo.author)&.id end def find_modinfo(modinfo) @modinfo_array.find { |mod| mod.name == modinfo.name } end def update(modinfo) @firestore.update(:mod, modinfo, merge: false) end def delete(modinfo) @firestore.delete(:mod, modinfo) end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems