Sha256: 5617859f4511d6699c662c5afdfd7c77fd55eecc49ef1e5e2951b78a747bb68d

Contents?: true

Size: 798 Bytes

Versions: 90

Compression:

Stored size: 798 Bytes

Contents

require 'exercise_cases'

class SieveCase < OpenStruct
  OPEN_ARRAY = "[\n\s\s\s\s\s\s".freeze
  CLOSE_ARRAY = "\n\s\s\s\s]".freeze
  NEW_ARRAY_ROW = ",\n\s\s\s\s\s\s".freeze
  ARRAY_ELEMENTS_PER_ROW = 17.freeze

  def name
    'test_%s' % description.tr(' ', '_')
  end

  def expected_string
    return expected unless needs_indentation?

    array_rows = expected.each_slice(ARRAY_ELEMENTS_PER_ROW).map { |elements| elements.join(', ') }
    "#{OPEN_ARRAY}#{array_rows.join(NEW_ARRAY_ROW)}#{CLOSE_ARRAY}"
  end

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

  private

  def needs_indentation?
    expected.size > ARRAY_ELEMENTS_PER_ROW
  end
end

SieveCases = proc do |data|
  JSON.parse(data)['cases'].map.with_index do |row, i|
    SieveCase.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/sieve_cases.rb
trackler-2.1.0.0 tracks/ruby/lib/sieve_cases.rb
trackler-2.0.8.55 tracks/ruby/lib/sieve_cases.rb
trackler-2.0.8.54 tracks/ruby/lib/sieve_cases.rb
trackler-2.0.8.53 tracks/ruby/lib/sieve_cases.rb
trackler-2.0.8.52 tracks/ruby/lib/sieve_cases.rb
trackler-2.0.8.51 tracks/ruby/lib/sieve_cases.rb
trackler-2.0.8.50 tracks/ruby/lib/sieve_cases.rb
trackler-2.0.8.49 tracks/ruby/lib/sieve_cases.rb
trackler-2.0.8.48 tracks/ruby/lib/sieve_cases.rb
trackler-2.0.8.47 tracks/ruby/lib/sieve_cases.rb
trackler-2.0.8.46 tracks/ruby/lib/sieve_cases.rb
trackler-2.0.8.45 tracks/ruby/lib/sieve_cases.rb
trackler-2.0.8.44 tracks/ruby/lib/sieve_cases.rb
trackler-2.0.8.43 tracks/ruby/lib/sieve_cases.rb
trackler-2.0.8.42 tracks/ruby/lib/sieve_cases.rb
trackler-2.0.8.41 tracks/ruby/lib/sieve_cases.rb
trackler-2.0.8.40 tracks/ruby/lib/sieve_cases.rb
trackler-2.0.8.39 tracks/ruby/lib/sieve_cases.rb
trackler-2.0.8.38 tracks/ruby/lib/sieve_cases.rb