Sha256: 2699e15b0da15f24578a6776403f151e5fefbe754d425fdfe1abf12f1efc48c5

Contents?: true

Size: 840 Bytes

Versions: 55

Compression:

Stored size: 840 Bytes

Contents

class TransposeCase < OpenStruct
  def test_name
    "test_#{description.tr(' ', '_')}"
  end

  def skipped
    index.zero? ? '# skip' : 'skip'
  end

  def workload
    'Transpose.transpose(input)'
  end

  def expect
    indented_heredoc(expected, 'EXPECTED')
  end

  def input_text
    indented_heredoc(input, 'INPUT')
  end

  private

  def indented_heredoc(string, delimiter)
    [
      "<<-#{delimiter}.gsub(/^ {6}/, '')",
      indent_lines(string),
      indent_line(delimiter)
    ].join("\n")
  end

  def indent_lines(lines, indent = 3)
    lines.map { |line| indent_line(line, indent) }.join("\n")
  end

  def indent_line(line, indent = 2)
    ' ' * indent * 2 + line
  end
end

TransposeCases = proc do |data|
  JSON.parse(data)['cases'].map.with_index do |row, i|
    TransposeCase.new(row.merge('index' => i))
  end
end

Version data entries

55 entries across 55 versions & 1 rubygems

Version Path
trackler-2.0.6.11 tracks/ruby/lib/transpose_cases.rb
trackler-2.0.6.10 tracks/ruby/lib/transpose_cases.rb
trackler-2.0.6.9 tracks/ruby/lib/transpose_cases.rb
trackler-2.0.6.8 tracks/ruby/lib/transpose_cases.rb
trackler-2.0.6.7 tracks/ruby/lib/transpose_cases.rb
trackler-2.0.6.6 tracks/ruby/lib/transpose_cases.rb
trackler-2.0.6.5 tracks/ruby/lib/transpose_cases.rb
trackler-2.0.6.4 tracks/ruby/lib/transpose_cases.rb
trackler-2.0.6.3 tracks/ruby/lib/transpose_cases.rb
trackler-2.0.6.2 tracks/ruby/lib/transpose_cases.rb
trackler-2.0.6.1 tracks/ruby/lib/transpose_cases.rb
trackler-2.0.6.0 tracks/ruby/lib/transpose_cases.rb
trackler-2.0.5.18 tracks/ruby/lib/transpose_cases.rb
trackler-2.0.5.17 tracks/ruby/lib/transpose_cases.rb
trackler-2.0.5.16 tracks/ruby/lib/transpose_cases.rb
trackler-2.0.5.15 tracks/ruby/lib/transpose_cases.rb
trackler-2.0.5.14 tracks/ruby/lib/transpose_cases.rb
trackler-2.0.5.13 tracks/ruby/lib/transpose_cases.rb
trackler-2.0.5.12 tracks/ruby/lib/transpose_cases.rb
trackler-2.0.5.11 tracks/ruby/lib/transpose_cases.rb