Class: FlogBackend

Inherits:
Backend show all
Defined in:
lib/backends/flog_backend.rb

Overview

Gather complexity metrics about a piece of code via flog

Class Method Summary collapse

Methods inherited from Backend

with_no_output, write_layers

Class Method Details

.record(method, score) ⇒ Object



18
19
20
21
22
23
# File 'lib/backends/flog_backend.rb', line 18

def record(method, score)
  return if method =~ /\#none$/ # tossing this stuff
  color = 'red' # TODO: determine color smartly
  message = "#{method} flogs at #{score}"
  (@layers[@file] ||= []) << Layer.new(method, color, message, self, @file)
end

.run(file) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/backends/flog_backend.rb', line 8

def run(file)
  @file = file
  @layers = {}

  flogger = Flog.new
  flogger.flog_files @file
  flogger.totals.each { |method, score| record method, score }
  write_layers
end