Sha256: 3bad083de7001bf2be313ff9cf147ca2616cfc58f19d3af4ec0d88707d504bdf

Contents?: true

Size: 1.22 KB

Versions: 14

Compression:

Stored size: 1.22 KB

Contents

# frozen_string_literal: true

require "firestore"
require "github"
require "tools/sync_helpers"

module Icarus
  module Mod
    module Tools
      # Sync methods
      class ModinfoSync
        include SyncHelpers

        def initialize
          @firestore = 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 modinfo_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

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
Icarus-Mod-Tools-1.8.0 lib/icarus/mod/tools/modinfo_sync.rb
Icarus-Mod-Tools-1.7.1 lib/icarus/mod/tools/modinfo_sync.rb
Icarus-Mod-Tools-1.7.0 lib/icarus/mod/tools/modinfo_sync.rb
Icarus-Mod-Tools-1.6.0 lib/icarus/mod/tools/modinfo_sync.rb
Icarus-Mod-Tools-1.5.1 lib/icarus/mod/tools/modinfo_sync.rb
Icarus-Mod-Tools-1.5.0 lib/icarus/mod/tools/modinfo_sync.rb
Icarus-Mod-Tools-1.4.1 lib/icarus/mod/tools/modinfo_sync.rb
Icarus-Mod-Tools-1.4.0 lib/icarus/mod/tools/modinfo_sync.rb
Icarus-Mod-Tools-1.3.5 lib/icarus/mod/tools/modinfo_sync.rb
Icarus-Mod-Tools-1.3.4 lib/icarus/mod/tools/modinfo_sync.rb
Icarus-Mod-Tools-1.3.3 lib/icarus/mod/tools/modinfo_sync.rb
Icarus-Mod-Tools-1.3.2 lib/icarus/mod/tools/modinfo_sync.rb
Icarus-Mod-Tools-1.3.1 lib/icarus/mod/tools/modinfo_sync.rb
Icarus-Mod-Tools-1.3.0 lib/icarus/mod/tools/modinfo_sync.rb