1
0
Fork 0
mirror of https://github.com/sinatra/sinatra synced 2023-03-27 23:18:01 -04:00

Add task for adding template languages to all READMEs.

This commit is contained in:
Konstantin Haase 2010-11-05 13:47:13 +01:00
parent 4988126624
commit 8753c6046b

View file

@ -65,6 +65,25 @@ file 'doc/api/index.html' => FileList['lib/**/*.rb', 'README.*'] do |f|
end end
CLEAN.include 'doc/api' CLEAN.include 'doc/api'
# README ===============================================================
task :add_template, [:name] do |t, args|
Dir.glob('README.*') do |file|
code = File.read(file)
if code =~ /^===.*#{args.name.capitalize}/
puts "Already covered in #{file}."
else
template = code[/===[^\n]*Liquid.*index\.liquid<\/tt>[^\n]*/m]
if !template
puts "Liquid not found in #{file}"
else
template = template.gsub(/Liquid/, args.name.capitalize).gsub(/liquid/, args.name.downcase)
code.gsub! '=== CoffeScript', template << "\n\n=== CoffeScript"
File.open(file, "w") { |f| f << code }
end
end
end
end
# PACKAGING ============================================================ # PACKAGING ============================================================
if defined?(Gem) if defined?(Gem)