Class: Pinspec::Inputs::SampleRunner::Result

Inherits:
Data
  • Object
show all
Defined in:
lib/pinspec/inputs/sample_runner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#countsObject (readonly)

Returns the value of attribute counts

Returns:

  • (Object)

    the current value of counts



12
13
14
# File 'lib/pinspec/inputs/sample_runner.rb', line 12

def counts
  @counts
end

#envObject (readonly)

Returns the value of attribute env

Returns:

  • (Object)

    the current value of env



12
13
14
# File 'lib/pinspec/inputs/sample_runner.rb', line 12

def env
  @env
end

#errorsObject (readonly)

Returns the value of attribute errors

Returns:

  • (Object)

    the current value of errors



12
13
14
# File 'lib/pinspec/inputs/sample_runner.rb', line 12

def errors
  @errors
end

#rowsObject (readonly)

Returns the value of attribute rows

Returns:

  • (Object)

    the current value of rows



12
13
14
# File 'lib/pinspec/inputs/sample_runner.rb', line 12

def rows
  @rows
end

#stratifiedObject (readonly)

Returns the value of attribute stratified

Returns:

  • (Object)

    the current value of stratified



12
13
14
# File 'lib/pinspec/inputs/sample_runner.rb', line 12

def stratified
  @stratified
end

Instance Method Details

#all_rowsObject



31
32
33
# File 'lib/pinspec/inputs/sample_runner.rb', line 31

def all_rows
  counts.keys.each_with_object({}) { |table, out| out[table] = rows_for(table) }
end

#empty?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/pinspec/inputs/sample_runner.rb', line 17

def empty?
  total_rows.zero?
end

#rows_for(table) ⇒ Object



21
22
23
24
25
26
27
28
29
# File 'lib/pinspec/inputs/sample_runner.rb', line 21

def rows_for(table)
  seen = {}

  (Array(rows[table]) + Array(stratified[table])).each do |row|
    seen[row["id"] || row[:id] || row.hash] = row
  end

  seen.values
end

#total_rowsObject



13
14
15
# File 'lib/pinspec/inputs/sample_runner.rb', line 13

def total_rows
  counts.values.sum
end