Class: Bugwatch::Diff

Inherits:
Object
  • Object
show all
Extended by:
Attrs
Defined in:
lib/bugwatch/diff.rb

Defined Under Namespace

Classes: Content

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Attrs

attrs, lazy_attrs

Constructor Details

#initialize(attributes = {}) ⇒ Diff

Returns a new instance of Diff.



49
50
51
# File 'lib/bugwatch/diff.rb', line 49

def initialize(attributes={})
  @attributes = attributes
end

Class Method Details

.from_grit(grit_diff) ⇒ Object



42
43
44
45
46
47
# File 'lib/bugwatch/diff.rb', line 42

def self.from_grit(grit_diff)
  new path: String(grit_diff.b_path || grit_diff.a_path),
      diff: -> { grit_diff.diff },
      a_blob: -> { blob_data(grit_diff.a_blob) },
      b_blob: -> { blob_data(grit_diff.b_blob) }
end

Instance Method Details

#contentObject



61
62
63
# File 'lib/bugwatch/diff.rb', line 61

def content
  Content.new(path, a_blob, b_blob)
end

#identify(line_number) ⇒ Object



53
54
55
# File 'lib/bugwatch/diff.rb', line 53

def identify(line_number)
  DiffParser.new(diff, b_blob).modifications(line_number..line_number)
end

#modificationsObject



57
58
59
# File 'lib/bugwatch/diff.rb', line 57

def modifications
  DiffParser.new(diff, b_blob).modifications
end