Sha256: 2234d1532045da574786689b27c8422de72654d937794eb183555d86bc655a13

Contents?: true

Size: 944 Bytes

Versions: 4

Compression:

Stored size: 944 Bytes

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) }
          end.flatten
        end

        def find_mod(modinfo)
          @firestore.find_mod(:name, modinfo.name)&.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

Version Path
Icarus-Mod-Tools-1.3.3 lib/icarus/mod/tools/mod_sync.rb
Icarus-Mod-Tools-1.3.2 lib/icarus/mod/tools/mod_sync.rb
Icarus-Mod-Tools-1.3.1 lib/icarus/mod/tools/mod_sync.rb
Icarus-Mod-Tools-1.3.0 lib/icarus/mod/tools/mod_sync.rb