def fetch_gem(resource)
      return unless Utils.configuration.fetch_gem
      name = File.basename(resource)
      result = name.match(URI_REGEXP)
      return unless result

      gem_name, gem_version, gem_platform, gem_type = result.captures
      return unless gem_name && gem_version

      begin
        gem = Utils.stored_gem(gem_name, gem_version, gem_platform)
        gem.gemspec = true if gem_type == GEMSPEC_TYPE

        # rubocop:disable Metrics/LineLength
        return if Utils.gems_fetcher.gem_exists?(gem.filename(gem_version)) && gem_type == GEM_TYPE
        return if Utils.gems_fetcher.gemspec_exists?(gem.gemspec_filename(gem_version)) && gem_type == GEMSPEC_TYPE
        # rubocop:enable Metrics/LineLength

        Utils.logger
             .info("Try to download #{gem_name} with version #{gem_version}")
        Utils.gems_fetcher.source.gems.clear
        Utils.gems_fetcher.source.gems.push(gem)
        Utils.gems_fetcher.fetch

        update_indexes if Utils.configuration.update_on_fetch
      rescue StandardError => e
        Utils.logger.error(e)
      end
    end
def fetch_gem(resource)
      return unless Utils.configuration.fetch_gem
      name = File.basename(resource)
      result = name.match(URI_REGEXP)
      return unless result

      gem_name, gem_version, gem_platform, gem_type = result.captures
      return unless gem_name && gem_version

      begin
        gem = Utils.stored_gem(gem_name, gem_version, gem_platform)
        gem.gemspec = true if gem_type == GEMSPEC_TYPE

        # rubocop:disable Metrics/LineLength
        return if Utils.gems_fetcher.gem_exists?(gem.filename(gem_version)) && gem_type == GEM_TYPE
        return if Utils.gems_fetcher.gemspec_exists?(gem.gemspec_filename(gem_version)) && gem_type == GEMSPEC_TYPE
        # rubocop:enable Metrics/LineLength

        Utils.logger
             .info("Try to download #{gem_name} with version #{gem_version}")
        Utils.gems_fetcher.source.gems.clear
        Utils.gems_fetcher.source.gems.push(gem)
        Utils.gems_fetcher.fetch

        update_indexes if Utils.configuration.update_on_fetch
      rescue StandardError => e
        Utils.logger.error(e)
      end
    end
Try to fetch gem and download its if it's possible, and
 build and install indicies.

 @param [String] resource
 @return [Indexer]