Sha256: f3fa07e1b81800deadd7d3bf32629aa82338009b3c08e97cae75cacb7b629dc1

Contents?: true

Size: 882 Bytes

Versions: 5

Compression:

Stored size: 882 Bytes

Contents

$:.unshift File.dirname(__FILE__)

require 'set'

module Reek

  class SortByContext
    def self.compare(smell1, smell2)
      smell1.detailed_report <=> smell2.detailed_report
    end
  end

  class SortBySmell
    def self.compare(smell1, smell2)
      smell1.report <=> smell2.report
    end
  end

  class Report

    SORT_ORDERS = {
      :context => SortByContext,
      :smell => SortBySmell
    }

    def initialize  # :nodoc:
      @smells = SortedSet.new
    end

    def <<(smell)  # :nodoc:
      @smells << smell
    end
    
    def empty?  # :nodoc:
      @smells.empty?
    end

    def length  # :nodoc:
      @smells.length
    end

    def [](index)  # :nodoc:
      @smells.to_a[index]
    end

    # Creates a formatted report of all the smells recorded in
    # this report.
    def to_s
      @smells.map {|smell| smell.report}.join("\n")
    end
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
reek-0.2.1 lib/reek/report.rb
reek-0.2.2 lib/reek/report.rb
reek-0.2.3 lib/reek/report.rb
reek-0.3.0 lib/reek/report.rb
reek-0.3.1 lib/reek/report.rb