Class: CoverRage::Record

Inherits:
Data
  • Object
show all
Defined in:
lib/cover_rage/record.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#execution_countObject (readonly)

Returns the value of attribute execution_count

Returns:

  • (Object)

    the current value of execution_count



4
5
6
# File 'lib/cover_rage/record.rb', line 4

def execution_count
  @execution_count
end

#last_executed_atObject (readonly)

Returns the value of attribute last_executed_at

Returns:

  • (Object)

    the current value of last_executed_at



4
5
6
# File 'lib/cover_rage/record.rb', line 4

def last_executed_at
  @last_executed_at
end

#pathObject (readonly)

Returns the value of attribute path

Returns:

  • (Object)

    the current value of path



4
5
6
# File 'lib/cover_rage/record.rb', line 4

def path
  @path
end

#revisionObject (readonly)

Returns the value of attribute revision

Returns:

  • (Object)

    the current value of revision



4
5
6
# File 'lib/cover_rage/record.rb', line 4

def revision
  @revision
end

#sourceObject (readonly)

Returns the value of attribute source

Returns:

  • (Object)

    the current value of source



4
5
6
# File 'lib/cover_rage/record.rb', line 4

def source
  @source
end

Class Method Details

.merge(existing, current) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/cover_rage/record.rb', line 5

def self.merge(existing, current)
  records_to_save = []
  current.each do |record|
    found = existing.find { _1.path == record.path }
    records_to_save <<
      if found.nil? || record.revision != found.revision
        record
      else
        record + found
      end
  end
  records_to_save
end

Instance Method Details

#+(other) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/cover_rage/record.rb', line 19

def +(other)
  with(
    execution_count: execution_count.map.with_index do |item, index|
      item.nil? ? nil : item + other.execution_count[index]
    end,
    last_executed_at: last_executed_at.map.with_index do |item, index|
      if item.nil? && other.last_executed_at[index].nil? then nil
      elsif item.nil? then other.last_executed_at[index]
      elsif other.last_executed_at[index].nil? then item
      else [item, other.last_executed_at[index]].max
      end
    end
  )
end