Class: Koji::Detector

Inherits:
Object
  • Object
show all
Defined in:
lib/koji/detector.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(website) ⇒ Detector

Returns a new instance of Detector.



7
8
9
# File 'lib/koji/detector.rb', line 7

def initialize(website)
  @website = website
end

Instance Attribute Details

#websiteObject (readonly)

Returns the value of attribute website.



5
6
7
# File 'lib/koji/detector.rb', line 5

def website
  @website
end

Instance Method Details

#detailed_reportObject



33
34
35
36
# 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

#reportObject



26
27
28
29
30
31
# File 'lib/koji/detector.rb', line 26

def report
  {
    verdict: verdict,
    score: score
  }
end

#scoreObject



11
12
13
# File 'lib/koji/detector.rb', line 11

def score
  plugins.map(&:score).sum
end

#verdictObject



15
16
17
18
19
20
21
22
23
24
# 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