class Koji::Detector

Attributes

website[R]

Public Class Methods

new(website) click to toggle source
# File lib/koji/detector.rb, line 7
def initialize(website)
  @website = website
end

Public Instance Methods

detailed_report() click to toggle source
# File lib/koji/detector.rb, line 33
def detailed_report
  plugin_reports = plugins.map(&:report).select { |report| report.dig(:score).to_i.positive? }
  report.merge(plugin_reports: plugin_reports)
end
report() click to toggle source
# File lib/koji/detector.rb, line 26
def report
  {
    verdict: verdict,
    score: score
  }
end
score() click to toggle source
# File lib/koji/detector.rb, line 11
def score
  plugins.map(&:score).sum
end
verdict() click to toggle source
# File lib/koji/detector.rb, line 15
def verdict
  case score.to_i
  when -Float::INFINITY..49
    "Not underconstruction"
  when 50..99
    "Possibly underconstruction"
  when 100..Float::INFINITY
    "Underconstruction"
  end
end

Private Instance Methods

plugins() click to toggle source
# File lib/koji/detector.rb, line 40
def plugins
  @plugins ||= Koji.plugins.map { |klass| klass.new website }
end