Sha256: f61aff75d6c0c58e04a346c22341580a23066777b19196b8a040d9d719669b15

Contents?: true

Size: 1.08 KB

Versions: 34

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

34 entries across 34 versions & 1 rubygems

Version Path
inch-0.9.0.rc1 lib/inch/api/compare/code_objects.rb
inch-0.8.0 lib/inch/api/compare/code_objects.rb
inch-0.8.0.rc2 lib/inch/api/compare/code_objects.rb
inch-0.8.0.rc1 lib/inch/api/compare/code_objects.rb
inch-0.7.1 lib/inch/api/compare/code_objects.rb
inch-0.7.0 lib/inch/api/compare/code_objects.rb
inch-0.6.4 lib/inch/api/compare/code_objects.rb
inch-0.6.3 lib/inch/api/compare/code_objects.rb
inch-0.6.2 lib/inch/api/compare/code_objects.rb
inch-0.6.1 lib/inch/api/compare/code_objects.rb
inch-0.6.0 lib/inch/api/compare/code_objects.rb
inch-0.6.0.rc6 lib/inch/api/compare/code_objects.rb
inch-0.6.0.rc5 lib/inch/api/compare/code_objects.rb
inch-0.6.0.rc4 lib/inch/api/compare/code_objects.rb
inch-0.6.0.rc3 lib/inch/api/compare/code_objects.rb
inch-0.6.0.rc2 lib/inch/api/compare/code_objects.rb
inch-0.6.0.rc1 lib/inch/api/compare/code_objects.rb
inch-0.5.10 lib/inch/api/compare/code_objects.rb
inch-0.5.9 lib/inch/api/compare/code_objects.rb
inch-0.5.8 lib/inch/api/compare/code_objects.rb