Class: RubyMaat::ChangeRecord

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_maat/change_record.rb

Overview

Represents a single change/modification record from VCS This is the fundamental data structure that flows through the entire pipeline

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(entity:, author:, date:, revision:, message: nil, loc_added: nil, loc_deleted: nil) ⇒ ChangeRecord

Returns a new instance of ChangeRecord.



9
10
11
12
13
14
15
16
17
# File 'lib/ruby_maat/change_record.rb', line 9

def initialize(entity:, author:, date:, revision:, message: nil, loc_added: nil, loc_deleted: nil)
  @entity = entity
  @author = author
  @date = date.is_a?(Date) ? date : Date.parse(date)
  @revision = revision
  @message = message
  @loc_added = loc_added.to_i if loc_added && (!loc_added.is_a?(Float) || !loc_added.nan?)
  @loc_deleted = loc_deleted.to_i if loc_deleted && (!loc_deleted.is_a?(Float) || !loc_deleted.nan?)
end

Instance Attribute Details

#authorObject (readonly)

Returns the value of attribute author.



7
8
9
# File 'lib/ruby_maat/change_record.rb', line 7

def author
  @author
end

#dateObject (readonly)

Returns the value of attribute date.



7
8
9
# File 'lib/ruby_maat/change_record.rb', line 7

def date
  @date
end

#entityObject (readonly)

Returns the value of attribute entity.



7
8
9
# File 'lib/ruby_maat/change_record.rb', line 7

def entity
  @entity
end

#loc_addedObject (readonly)

Returns the value of attribute loc_added.



7
8
9
# File 'lib/ruby_maat/change_record.rb', line 7

def loc_added
  @loc_added
end

#loc_deletedObject (readonly)

Returns the value of attribute loc_deleted.



7
8
9
# File 'lib/ruby_maat/change_record.rb', line 7

def loc_deleted
  @loc_deleted
end

#messageObject (readonly)

Returns the value of attribute message.



7
8
9
# File 'lib/ruby_maat/change_record.rb', line 7

def message
  @message
end

#revisionObject (readonly)

Returns the value of attribute revision.



7
8
9
# File 'lib/ruby_maat/change_record.rb', line 7

def revision
  @revision
end

Instance Method Details

#==(other) ⇒ Object



31
32
33
34
35
36
37
# File 'lib/ruby_maat/change_record.rb', line 31

def ==(other)
  other.is_a?(ChangeRecord) &&
    entity == other.entity &&
    author == other.author &&
    date == other.date &&
    revision == other.revision
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/ruby_maat/change_record.rb', line 43

def eql?(other)
  self == other
end

#hashObject



39
40
41
# File 'lib/ruby_maat/change_record.rb', line 39

def hash
  [entity, author, date, revision].hash
end

#to_hObject



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/ruby_maat/change_record.rb', line 19

def to_h
  {
    entity: entity,
    author: author,
    date: date,
    revision: revision,
    message: message,
    loc_added: loc_added,
    loc_deleted: loc_deleted
  }
end