Sha256: 553f5de0dfe1aa6245fea5d55bf3bd794c09c9a4c65e636f3f806275694b085f

Contents?: true

Size: 828 Bytes

Versions: 2

Compression:

Stored size: 828 Bytes

Contents

require 'awesome_bot/white_list'

# Result
module AwesomeBot
  # Result
  class Result
    attr_accessor :dupes
    attr_accessor :skip_dupe
    attr_accessor :status
    attr_accessor :white_listed

    attr_reader :rejected
    attr_reader :links

    def initialize(links, white_list_from_cli)
      @links = links
      @w = white_list_from_cli

      return if @w.nil?
      @rejected, @links = links.partition { |u| AwesomeBot.white_list @w, u }
    end

    def statuses_issues
      status.select { |x| x['status'] != 200 }
    end

    def success
      success_dupe && success_links
    end

    def success_dupe
      return true if skip_dupe
      links.uniq.count == links.count
    end

    def success_links
      statuses_issues.count == 0
    end

    def white_listing
      !@w.nil?
    end
  end # class
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
awesome_bot-1.2.1 lib/awesome_bot/result.rb
awesome_bot-1.2.0 lib/awesome_bot/result.rb