Sha256: cf923188ba91e7f1801cdda9b5d87f551d5a15cf7cfc60d8687b412844dfd811
Contents?: true
Size: 1.24 KB
Versions: 1
Compression:
Stored size: 1.24 KB
Contents
# frozen_string_literal: true require "firestore" require "tools/sync_helpers" module Icarus module Mod module Tools # Sync methods class ProgSync include SyncHelpers def initialize @firestore = Firestore.new end def progs @firestore.progs end def info_array @info_array ||= @firestore.proginfo_list.map do |url| retrieve_from_url(url)[:programs].map { |prog| Proginfo.new(prog) if prog[: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(proginfo) @firestore.find_by_type(type: "progs", name: proginfo.name, author: proginfo.author)&.id end def find_info(proginfo) @info_array.find { |prog| prog.name == proginfo.name } end def update(proginfo) @firestore.update(:prog, proginfo, merge: false) end def delete(proginfo) @firestore.delete(:prog, proginfo) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
Icarus-Mod-Tools-1.8.1 | lib/icarus/mod/tools/prog_sync.rb |