Sha256: a6043fc8fa203a12f88b4f228ee91ab480691c5fe01898f1381af3a0c33cd4df

Contents?: true

Size: 1.09 KB

Versions: 17

Compression:

Stored size: 1.09 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
            raise "@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

17 entries across 17 versions & 1 rubygems

Version Path
inch-0.5.0.rc3 lib/inch/api/compare/code_objects.rb
inch-0.5.0.rc2 lib/inch/api/compare/code_objects.rb
inch-0.5.0.rc1 lib/inch/api/compare/code_objects.rb
inch-0.4.6 lib/inch/api/compare/code_objects.rb
inch-0.4.5 lib/inch/api/compare/code_objects.rb
inch-0.4.4 lib/inch/api/compare/code_objects.rb
inch-0.4.4.rc4 lib/inch/api/compare/code_objects.rb
inch-0.4.4.rc3 lib/inch/api/compare/code_objects.rb
inch-0.4.4.rc2 lib/inch/api/compare/code_objects.rb
inch-0.4.4.rc1 lib/inch/api/compare/code_objects.rb
inch-0.4.3 lib/inch/api/compare/code_objects.rb
inch-0.4.3.rc2 lib/inch/api/compare/code_objects.rb
inch-0.4.3.rc1 lib/inch/api/compare/code_objects.rb
inch-0.4.2 lib/inch/api/compare/code_objects.rb
inch-0.4.1 lib/inch/api/compare/code_objects.rb
inch-0.4.0 lib/inch/api/compare/code_objects.rb
inch-0.4.0.rc3 lib/inch/api/compare/code_objects.rb