Sha256: 748157840fc00d4f3ca19b5cc392bf299414903c1ad7a3450feb3e2bd7d83606

Contents?: true

Size: 971 Bytes

Versions: 2

Compression:

Stored size: 971 Bytes

Contents

module Chkex
  module Source
    class List < Base
      def initialize(source)
        super(source).organize
      end

      def process
        Notify.info "Checking #{@source.size} domains..."

        @source.each do |url|
          result = DomainInfo.new(url)

          unless result.error.nil?
            @results[:errors][result.error] = [] unless @results[:errors].key?(result.error)
            @results[:errors][result.error].push(domain: result.url)
          end

          next if result.expires_on.nil?

          expiry_date = Date.parse(result.expires_on.strftime('%Y-%m-%d'))
          diff = expiry_date.mjd - @now.mjd

          @results[:success][diff] = [] unless @results[:success].key?(diff)
          @results[:success][diff].push(expiry: expiry_date, domain: result.url)
        end

        self
      end

      def organize
        @results[:success] = @results[:success].sort_by { |k, _| k }
        @results
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
chkex-0.1.1 lib/chkex/sources/list.rb
chkex-0.1.0 lib/chkex/sources/list.rb