Class: ReaPack::Index::Git::Diff

Inherits:
Object
  • Object
show all
Defined in:
lib/reapack/index/git.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(delta, repo) ⇒ Diff

Returns a new instance of Diff.



210
211
212
213
214
215
# File 'lib/reapack/index/git.rb', line 210

def initialize(delta, repo)
  @delta, @repo = delta, repo

  @status = delta.status.to_sym
  @file = delta.new_file
end

Instance Attribute Details

#statusObject (readonly)

Returns the value of attribute status.



217
218
219
# File 'lib/reapack/index/git.rb', line 217

def status
  @status
end

Instance Method Details

#fileObject



219
220
221
# File 'lib/reapack/index/git.rb', line 219

def file
  @path ||= @file[:path].force_encoding(Encoding::UTF_8)
end

#new_contentObject



223
224
225
226
227
# File 'lib/reapack/index/git.rb', line 223

def new_content
  return if status == :deleted
  @new_content ||=
    @repo.lookup(@file[:oid]).content.force_encoding(Encoding::UTF_8)
end

#new_headerObject



229
230
231
# File 'lib/reapack/index/git.rb', line 229

def new_header
  @new_header ||= ReaPack::Index.parse @new_content if new_content
end