feat: Added mustache templating.

This commit is contained in:
Spencer Brower
2026-07-12 13:38:32 -04:00
parent 42d58394ef
commit 8b2dceb679
40 changed files with 7838 additions and 163 deletions
+36
View File
@@ -0,0 +1,36 @@
require 'json'
require 'yaml'
# Our custom YAML tags must retain their magic.
class TaggedMap < Hash
yaml_tag '!code'
def init_with(psych_coder)
self.replace({:__tag__ => 'code'}.merge(psych_coder.map))
end
end
YAML::add_tag('code', TaggedMap)
desc 'Build all alternate versions of the specs.'
multitask :build => [ 'build:json' ]
namespace :build do
note = 'Do not edit this file; changes belong in the appropriate YAML file.'
desc 'Build JSON versions of the specs.'
task :json do
rm(Dir['specs/*.json'], :verbose => false)
Dir.glob('specs/*.yml').each do |filename|
json_file = filename.gsub('.yml', '.json')
File.open(json_file, 'w') do |file|
warning = {:__ATTN__ => note}
doc = YAML.load_file(
filename,
permitted_classes: [TaggedMap]
)
file << JSON.pretty_generate(warning.merge(doc)) << "\n"
end
end
end
end