Sha256: e7640cfc43cb6ac46e6d2117b1d75306e6b9fd309adf05f501ab9c8666d3e75b
Contents?: true
Size: 1.11 KB
Versions: 16
Compression:
Stored size: 1.11 KB
Contents
require "./remote_data_file" 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 local_data_file = File.join(metadata_dir, "canonical-data.json") if File.exists?(local_data_file) File.read(local_data_file) else remote_data_file = RemoteDataFile.new(exercise_name) File.read(remote_data_file.path) end end ECR.def_to_s "#{__DIR__}/templates/example.tt" end
Version data entries
16 entries across 16 versions & 1 rubygems