Sha256: 84eb56579c2760ccd1f53c3e1639f4b68d818e7d0a94035a967c8152d9343a76
Contents?: true
Size: 1.36 KB
Versions: 2
Compression:
Stored size: 1.36 KB
Contents
# frozen_string_literal: true require "firestore" require "tools/sync/helpers" module Icarus module Mod module Tools module Sync # Sync methods class Progs include Helpers def initialize(client: nil) @firestore = client || Firestore.new end def progs @firestore.progs end def info_array @info_array ||= @firestore.proginfo.map do |url| retrieve_from_url(url)[:programs].map { |prog| Tools::Proginfo.new(prog) if prog[:name] =~ /[a-z0-9]+/i } rescue Icarus::Mod::Tools::Sync::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 end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
Icarus-Mod-Tools-1.8.2.1 | lib/icarus/mod/tools/sync/progs.rb |
Icarus-Mod-Tools-1.8.2 | lib/icarus/mod/tools/sync/progs.rb |