Sha256: 2d206590ea375ca80930e49ad8a7f3d37c239111550d4ee910c3d509d243329a
Contents?: true
Size: 1.2 KB
Versions: 2
Compression:
Stored size: 1.2 KB
Contents
require 'nokogiri' require 'open-uri' module ProspectusDockerhub GOOD_STATUSES = %w[success].freeze # rubocop:disable Metrics/LineLength STATUS_XPATH = '//span[contains(@class, "BuildStatus__statusWrapper__")]'.freeze # rubocop:enable Metrics/LineLength ## # Helper for automatically adding build status check class Build < Module def initialize(repo_slug) @repo_slug = repo_slug || raise('No repo specified') end def extended(other) # rubocop:disable Metrics/MethodLength actual_val, expected_val = parse_status other.deps do item do name 'build' expected do static set actual_val end actual do static set expected_val end end end end private def parse_status return [status, status] if GOOD_STATUSES.include?(status) [status, 'success'] end def status @status ||= html.xpath(STATUS_XPATH).first.text.strip.downcase end def html @html ||= Nokogiri::HTML(open(url)) end def url "#{base_url}/#{@repo_slug}/builds" end def base_url 'https://hub.docker.com/r' end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
prospectus_dockerhub-0.0.2 | lib/prospectus_dockerhub.rb |
prospectus_dockerhub-0.0.1 | lib/prospectus_dockerhub.rb |