Sha256: 3aaa6548adf9138cc32f25f756da2ebe8d287c8eac18eac57c135c7fba0b8129

Contents?: true

Size: 866 Bytes

Versions: 90

Compression:

Stored size: 866 Bytes

Contents

require 'exercise_cases'

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

90 entries across 90 versions & 1 rubygems

Version Path
trackler-2.1.0.1 tracks/ruby/lib/transpose_cases.rb
trackler-2.1.0.0 tracks/ruby/lib/transpose_cases.rb
trackler-2.0.8.55 tracks/ruby/lib/transpose_cases.rb
trackler-2.0.8.54 tracks/ruby/lib/transpose_cases.rb
trackler-2.0.8.53 tracks/ruby/lib/transpose_cases.rb
trackler-2.0.8.52 tracks/ruby/lib/transpose_cases.rb
trackler-2.0.8.51 tracks/ruby/lib/transpose_cases.rb
trackler-2.0.8.50 tracks/ruby/lib/transpose_cases.rb
trackler-2.0.8.49 tracks/ruby/lib/transpose_cases.rb
trackler-2.0.8.48 tracks/ruby/lib/transpose_cases.rb
trackler-2.0.8.47 tracks/ruby/lib/transpose_cases.rb
trackler-2.0.8.46 tracks/ruby/lib/transpose_cases.rb
trackler-2.0.8.45 tracks/ruby/lib/transpose_cases.rb
trackler-2.0.8.44 tracks/ruby/lib/transpose_cases.rb
trackler-2.0.8.43 tracks/ruby/lib/transpose_cases.rb
trackler-2.0.8.42 tracks/ruby/lib/transpose_cases.rb
trackler-2.0.8.41 tracks/ruby/lib/transpose_cases.rb
trackler-2.0.8.40 tracks/ruby/lib/transpose_cases.rb
trackler-2.0.8.39 tracks/ruby/lib/transpose_cases.rb
trackler-2.0.8.38 tracks/ruby/lib/transpose_cases.rb