blob: 1bbcc728b1d98d2963b207f3a077da10950c0b5d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
require 'json'
require 'yaml'
# Our custom YAML tags must retain their magic.
%w[ code ].each do |tag|
YAML::add_builtin_type(tag) { |_,val| val.merge(:__tag__ => tag) }
end
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)
file << warning.merge(doc).to_json()
end
end
end
end
|