Sha256: 1d34ae6c83981ab9f5aea3da1509f7ecccaf643e16895f85d5aa8d8c0f699d90

Contents?: true

Size: 1.08 KB

Versions: 6

Compression:

Stored size: 1.08 KB

Contents

module Inch
  module API
    module Compare
      class CodeObjects
        attr_reader :before, :after

        def initialize(object1, object2)
          @before, @after = object1, object2
          if @before.object_id == @after.object_id
            fail "@before and @after are identical ruby objects. this is bad."
          end
        end

        def changed?
          present? && !unchanged?
        end

        def fullname
          (@before || @after).fullname
        end

        def grade
          @after.grade
        end

        def added?
          @before.nil? && !@after.nil?
        end

        def degraded?
          changed? && @before.score > @after.score
        end

        def improved?
          changed? && @before.score < @after.score
        end

        def present?
          @before && @after
        end

        def removed?
          !@before.nil? && @after.nil?
        end

        def unchanged?
          present? && @before.score == @after.score
        end

        def scores
          [@before.score, @after.score]
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
inch-0.5.0.rc5 lib/inch/api/compare/code_objects.rb
inch-0.5.0.rc4 lib/inch/api/compare/code_objects.rb
inch-0.4.10 lib/inch/api/compare/code_objects.rb
inch-0.4.9 lib/inch/api/compare/code_objects.rb
inch-0.4.8 lib/inch/api/compare/code_objects.rb
inch-0.4.7 lib/inch/api/compare/code_objects.rb