Sha256: 1a8738497cd600a6c642590a18b19e0ad4fc6b19314a7c471e2f6fa09eacaced
Contents?: true
Size: 931 Bytes
Versions: 3
Compression:
Stored size: 931 Bytes
Contents
# frozen_string_literal: true require "http" require "oga" module Miteru class Website attr_reader :url def initialize(url) @url = url build end def title doc.at_css("title")&.text end def zip_files @zip_files ||= doc.css("a").map do |a| href = a.get("href") href&.end_with?(".zip") ? href : nil end.compact end def ok? response.code == 200 end def index? title == "Index of /" end def zip_files? !zip_files.empty? end def has_kit? ok? && index? && zip_files? end def build doc end private def response @response ||= get end def get ctx = OpenSSL::SSL::SSLContext.new ctx.verify_mode = OpenSSL::SSL::VERIFY_NONE HTTP.get(url, ssl_context: ctx) end def doc @doc ||= Oga.parse_html(response.body.to_s) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
miteru-0.3.1 | lib/miteru/website.rb |
miteru-0.3.0 | lib/miteru/website.rb |
miteru-0.2.0 | lib/miteru/website.rb |