Sha256: 39bdb4e647bfe358367a64f320d7028e7d086e901904942b21d7b86bdf17daf0

Contents?: true

Size: 1.32 KB

Versions: 2

Compression:

Stored size: 1.32 KB

Contents

# frozen_string_literal: true

require "firestore"
require "github"
require "tools/sync/helpers"

module Icarus
  module Mod
    module Tools
      module Sync
        # Sync methods
        class Modinfo
          include Helpers

          def initialize(client: nil)
            @firestore = client || Firestore.new
            @github = Github.new
            @repositories = []
          end

          def repositories
            @firestore.repos
          end

          def update(modinfo_array)
            @firestore.update(:modinfo, modinfo_array)
          end

          def modinfo(url)
            retrieve_from_url(url)
          end

          def data(repositories, verbose: false)
            repositories.map do |repo|
              print "searching #{repo}..." if verbose

              case repo
              when /github/
                @github.repository = repo
                modinfo_url = @github.find("modinfo.json")

                unless modinfo_url
                  puts "Skipped...no modinfo.json" if verbose
                  next
                end

                puts "Found!" if verbose
                modinfo_url
              else
                puts "Skipped...repository type not supported yet" if verbose
              end
            end.compact
          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/modinfo.rb
Icarus-Mod-Tools-1.8.2 lib/icarus/mod/tools/sync/modinfo.rb