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