Sha256: f5682275b6c25d852bac10e3d429e111e16603328639ece33922c171f93e6fe0
Contents?: true
Size: 872 Bytes
Versions: 3
Compression:
Stored size: 872 Bytes
Contents
# frozen_string_literal: true require "thread" require "thread/pool" module Ryo module Plugin class Dir attr_reader :uri, :threads def initialize(uri) @uri = uri.is_a?(URI::HTTP) ? uri : URI.parse(uri) @threads = 10 end def paths File.readlines(File.expand_path("./aux/paths.txt", __dir__)).map(&:chomp).compact end def url_for(path) "#{uri.scheme}://#{uri.host}:#{uri.port}/#{path}" end def discover pool = Thread.pool(threads) results = [] paths.map { |path| url_for(path) }.each do |url| pool.process { res = Client.http.get(url) results << url if res.code == 200 } end pool.shutdown results end def self.discover(uri) new(uri).discover end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ryo-0.3.0 | lib/ryo/plugin/dir.rb |
ryo-0.2.0 | lib/ryo/plugin/dir.rb |
ryo-0.1.0 | lib/ryo/plugin/dir.rb |