I;m to tierd to explain

This commit is contained in:
2026-07-16 01:17:20 -06:00
parent e764dcceb3
commit 678aa1f70d
+24 -3
View File
@@ -93,12 +93,32 @@ end
repeat = 0 repeat = 0
working = 0 working = 0
notWorking = 0 notWorking = 0
exist = true
begin
config = File.read("config.txt") config = File.read("config.txt")
rescue File::NotFoundError
puts "Oh No! It seems that your config.txt file does not exist!"
puts "This is required for rete to know what classifies if a url is working or not!"
puts "You can fix this by creating a config.txt file and by then entering status codes you classify as \"working\""
exit(1)
end
while repeat < ARGV.size while repeat < ARGV.size
if Valid.url? ARGV[repeat]
begin begin
response = HTTP::Client.get(ARGV[repeat]) validUrl = Valid.url? ARGV[repeat]
rescue Regex::Error
validUrl = false
end
if validUrl == true
begin
STDIN.read_timeout = 1
uri = URI.parse(ARGV[repeat])
client = HTTP::Client.new(uri)
client.connect_timeout = urlTimeout.to_i.seconds
response = client.get("/")
if config.includes?(response.status_code.to_s) if config.includes?(response.status_code.to_s)
puts "#{ARGV[repeat]} is a valid URL and works. Status code: #{response.status_code}" puts "#{ARGV[repeat]} is a valid URL and works. Status code: #{response.status_code}"
working += 1 working += 1
@@ -106,7 +126,7 @@ config = File.read("config.txt")
puts "#{ARGV[repeat]} is a valid URL but does not work. Status Code: #{response.status_code}" puts "#{ARGV[repeat]} is a valid URL but does not work. Status Code: #{response.status_code}"
notWorking += 1 notWorking += 1
end end
rescue Socket::Addrinfo::Error rescue
puts "#{ARGV[repeat]} is a valid URL but does not exist." puts "#{ARGV[repeat]} is a valid URL but does not exist."
notWorking += 1 notWorking += 1
end end
@@ -122,3 +142,4 @@ config = File.read("config.txt")
puts "A total of #{repeat} url(s) were tested." puts "A total of #{repeat} url(s) were tested."
puts "#{working}/#{repeat} url(s) were working." puts "#{working}/#{repeat} url(s) were working."
puts "#{notWorking}/#{repeat} url(s) were not working." puts "#{notWorking}/#{repeat} url(s) were not working."
exit 0