Sha256: cebe9fb58257afbf9f114a1e197b75828c90a8a9c9c18b72537959d541ea9602

Contents?: true

Size: 916 Bytes

Versions: 189

Compression:

Stored size: 916 Bytes

Contents

require "ecr"
require "json"

abstract class ExerciseGenerator
  METADATA_REPOSITORY = "x-common"

  def self.generate
    new.generate
  end

  def generate
    raise "There are no test cases for #{exercise_name}" if test_cases.empty?
    File.write(test_file, to_s)
  end

  def describe_name
    exercise_name.split('-').map(&.capitalize).join
  end

  abstract def exercise_name
  abstract def test_cases

  private def root
    File.expand_path(File.join("..", "..", "..", ".."), __FILE__)
  end

  private def test_file
    File.expand_path(File.join("exercises", exercise_name, "spec", "#{exercise_name.tr("-", "_")}_spec.cr"), root)
  end

  private def metadata_dir
    File.expand_path(File.join("..", METADATA_REPOSITORY, "exercises", exercise_name), root)
  end

  private def data
    File.read(File.join(metadata_dir, "canonical-data.json"))
  end

  ECR.def_to_s "#{__DIR__}/templates/example.tt"
end

Version data entries

189 entries across 189 versions & 1 rubygems

Version Path
trackler-2.1.0.53 tracks/crystal/src/generator/exercises/exercise_generator.cr
trackler-2.1.0.52 tracks/crystal/src/generator/exercises/exercise_generator.cr
trackler-2.1.0.51 tracks/crystal/src/generator/exercises/exercise_generator.cr
trackler-2.1.0.50 tracks/crystal/src/generator/exercises/exercise_generator.cr
trackler-2.1.0.49 tracks/crystal/src/generator/exercises/exercise_generator.cr
trackler-2.1.0.48 tracks/crystal/src/generator/exercises/exercise_generator.cr
trackler-2.1.0.47 tracks/crystal/src/generator/exercises/exercise_generator.cr
trackler-2.1.0.46 tracks/crystal/src/generator/exercises/exercise_generator.cr
trackler-2.1.0.45 tracks/crystal/src/generator/exercises/exercise_generator.cr
trackler-2.1.0.44 tracks/crystal/src/generator/exercises/exercise_generator.cr
trackler-2.1.0.43 tracks/crystal/src/generator/exercises/exercise_generator.cr
trackler-2.1.0.42 tracks/crystal/src/generator/exercises/exercise_generator.cr
trackler-2.1.0.41 tracks/crystal/src/generator/exercises/exercise_generator.cr
trackler-2.1.0.40 tracks/crystal/src/generator/exercises/exercise_generator.cr
trackler-2.1.0.39 tracks/crystal/src/generator/exercises/exercise_generator.cr
trackler-2.1.0.38 tracks/crystal/src/generator/exercises/exercise_generator.cr
trackler-2.1.0.37 tracks/crystal/src/generator/exercises/exercise_generator.cr
trackler-2.1.0.36 tracks/crystal/src/generator/exercises/exercise_generator.cr
trackler-2.1.0.34 tracks/crystal/src/generator/exercises/exercise_generator.cr
trackler-2.1.0.33 tracks/crystal/src/generator/exercises/exercise_generator.cr