Class: Inch::API::Diff

Inherits:
Object
  • Object
show all
Includes:
Utils::ShellHelper
Defined in:
lib/inch/api/diff.rb

Overview

Returns a Compare::Codebases object for two revisions of the same codebase

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils::ShellHelper

#git, #sh

Constructor Details

#initialize(dir, before_rev, after_rev = nil) ⇒ Diff

Returns a new instance of Diff.

Parameters:

  • dir (String)

    the working directory of the codebase

  • before_rev (String)

    the ‘before’ revision

  • after_rev (String, nil) (defaults to: nil)

    the ‘after’ revision that the ‘before’ one is compared against



19
20
21
22
23
24
25
26
27
28
# File 'lib/inch/api/diff.rb', line 19

def initialize(dir, before_rev, after_rev = nil)
  @work_dir = dir
  @codebase_old = codebase_for(before_rev)
  @codebase_new = if after_rev.nil?
      Codebase.parse(work_dir)
    else
      codebase_for(after_rev)
    end
  @comparer = API::Compare::Codebases.new(@codebase_old, @codebase_new)
end

Instance Attribute Details

#codebase_newObject (readonly)

Returns the value of attribute codebase_new.



11
12
13
# File 'lib/inch/api/diff.rb', line 11

def codebase_new
  @codebase_new
end

#codebase_oldObject (readonly)

Returns the value of attribute codebase_old.



10
11
12
# File 'lib/inch/api/diff.rb', line 10

def codebase_old
  @codebase_old
end

#comparerObject (readonly)

Returns the value of attribute comparer.



12
13
14
# File 'lib/inch/api/diff.rb', line 12

def comparer
  @comparer
end

#work_dirObject (readonly)

Returns the value of attribute work_dir.



13
14
15
# File 'lib/inch/api/diff.rb', line 13

def work_dir
  @work_dir
end