mirror of
https://github.com/twbs/bootstrap.git
synced 2024-12-04 16:24:22 +01:00
28 lines
733 B
Ruby
28 lines
733 B
Ruby
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|
|
|
doc = YAML.load_file(filename)
|
|
file << doc.merge(:__ATTN__ => note).to_json()
|
|
end
|
|
end
|
|
end
|
|
end
|