Class: Snaptoken::Diff

Inherits:
Object
  • Object
show all
Defined in:
lib/snaptoken/diff.rb

Defined Under Namespace

Classes: DiffFile, DiffLine, DiffSection, HTMLLineByLine

Constant Summary collapse

GIT_DIFF_OPTIONS =
"--histogram --unified=100000 --ignore-space-change --no-index"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config, step_a, step_b) ⇒ Diff

Returns a new instance of Diff.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/snaptoken/diff.rb', line 6

def initialize(config, step_a, step_b)
  git_diff = `git diff #{GIT_DIFF_OPTIONS} #{step_a} #{step_b}`
  parse_git_diff(git_diff)
  @files.values.each(&:omit_adjacent_removals!)

  step = step_b.split('-')
  step.shift
  step = step.join('-')

  @html = {}
  @files.each do |filename, file|
    @html[filename] = file.to_html(config[:name], step)
  end
end

Instance Attribute Details

#filesObject (readonly)

Returns the value of attribute files.



4
5
6
# File 'lib/snaptoken/diff.rb', line 4

def files
  @files
end

#htmlObject (readonly)

Returns the value of attribute html.



4
5
6
# File 'lib/snaptoken/diff.rb', line 4

def html
  @html
end