Sha256: 65d4bf84406e232a9b9e9d05523e8d9b68a822d6d379c141bbdd41d8e36dec3f

Contents?: true

Size: 643 Bytes

Versions: 4

Compression:

Stored size: 643 Bytes

Contents

module Cycromatic
  class TextFormatter
    attr_reader :io

    def initialize(io:)
      @io = io
    end

    def started(path:)
    end

    def finished(path:)
    end

    def completed
    end

    def error(path:, exception:)
      io.puts "#{path}\t(error)"
    end

    def calculated(path:, complexity:)
      loc = complexity.node.loc
      name = case complexity.type
             when :toplevel
               "[toplevel]"
             when :method
               complexity.node.children.find {|c| c.is_a? Symbol }.to_s
             end

      io.puts "#{path}\t#{name}:#{loc.first_line}\t#{complexity.value}"
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cycromatic-0.1.3 lib/cycromatic/text_formatter.rb
cycromatic-0.1.2 lib/cycromatic/text_formatter.rb
cycromatic-0.1.1 lib/cycromatic/text_formatter.rb
cycromatic-0.1.0 lib/cycromatic/text_formatter.rb