Class: Chkex::Source::List

Inherits:
Base
  • Object
show all
Defined in:
lib/chkex/sources/list.rb

Instance Attribute Summary

Attributes inherited from Base

#results

Instance Method Summary collapse

Methods inherited from Base

#strip

Constructor Details

#initialize(source) ⇒ List

Returns a new instance of List.



4
5
6
# File 'lib/chkex/sources/list.rb', line 4

def initialize(source)
  super(source).organize
end

Instance Method Details

#organizeObject



31
32
33
34
# File 'lib/chkex/sources/list.rb', line 31

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

#processObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/chkex/sources/list.rb', line 8

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