lib/cucumber/ast/table.rb
# Pads our own cell_matrix and returns a cell matrix of same
# column width that can be used for diffing
Pads our own cell_matrix and returns a cell matrix of same
column width that can be used for diffing
Pads our own cell_matrix and returns a cell matrix of same column width that can be used for diffing
def pad!(other_cell_matrix) 
        clear_cache!
        cols = cell_matrix.transpose
        unmapped_cols = other_cell_matrix.transpose
        mapped_cols = []
        cols.each_with_index do |col, col_index|
          header = col[0]
          candidate_cols, unmapped_cols = unmapped_cols.partition do |other_col|
            other_col[0] == header
          end
          raise "More than one column has the header #{header}" if candidate_cols.size > 2
          other_padded_col = if candidate_cols.size == 1
            candidate_cols[0]
          else
            mark_as_missing(cols[col_index])
            (0...other_cell_matrix.length).map do |row|
              val = row == 0 ? header.value : nil
              SurplusCell.new(val, self, -1)
            end
          end
          mapped_cols.insert(col_index, other_padded_col)
        end
        unmapped_cols.each_with_index do |col, col_index|
          empty_col = (0...cell_matrix.length).map do |row| 
            SurplusCell.new(nil, self, -1)
          end
          cols << empty_col
        end
        @cell_matrix = cols.transpose
        (mapped_cols + unmapped_cols).transpose
      end
def pad! ( other_cell_matrix ) clear_cache! cols = cell_matrix . transpose unmapped_cols = other_cell_matrix . transpose mapped_cols = [ ] cols . each_with_index do | col , col_index | header = col [ 0 ] candidate_cols , unmapped_cols = unmapped_cols . partition do | other_col | other_col [ 0 ] == header end raise "More than one column has the header #{header}" if candidate_cols . size > 2 other_padded_col = if candidate_cols . size == 1 candidate_cols [ 0 ] else mark_as_missing ( cols [ col_index ] ) ( 0 ... other_cell_matrix . length ) . map do | row | val = row == 0 ? header . value : nil SurplusCell . new ( val , self , - 1 ) end end mapped_cols . insert ( col_index , other_padded_col ) end unmapped_cols . each_with_index do | col , col_index | empty_col = ( 0 ... cell_matrix . length ) . map do | row | SurplusCell . new ( nil , self , - 1 ) end cols << empty_col end @cell_matrix = cols . transpose ( mapped_cols + unmapped_cols ) . transpose end
Pads our own cell_matrix and returns a cell matrix of same
column width that can be used for diffing
Pads our own cell_matrix and returns a cell matrix of same column width that can be used for diffing
#:nodoc: # Found a matching column
other_cell_matrix