mirror of
https://github.com/sinatra/sinatra
synced 2023-03-27 23:18:01 -04:00
Fix add_template rake task.
This commit is contained in:
parent
df18706ba6
commit
1cf11cb473
1 changed files with 4 additions and 3 deletions
7
Rakefile
7
Rakefile
|
@ -70,14 +70,15 @@ task :add_template, [:name] do |t, args|
|
||||||
Dir.glob('README.*') do |file|
|
Dir.glob('README.*') do |file|
|
||||||
code = File.read(file)
|
code = File.read(file)
|
||||||
if code =~ /^===.*#{args.name.capitalize}/
|
if code =~ /^===.*#{args.name.capitalize}/
|
||||||
puts "Already covered in #{file}."
|
puts "Already covered in #{file}"
|
||||||
else
|
else
|
||||||
template = code[/===[^\n]*Liquid.*index\.liquid<\/tt>[^\n]*/m]
|
template = code[/===[^\n]*Liquid.*index\.liquid<\/tt>[^\n]*/m]
|
||||||
if !template
|
if !template
|
||||||
puts "Liquid not found in #{file}"
|
puts "Liquid not found in #{file}"
|
||||||
else
|
else
|
||||||
template = template.gsub(/Liquid/, args.name.capitalize).gsub(/liquid/, args.name.downcase)
|
puts "Adding section to #{file}"
|
||||||
code.gsub! '=== CoffeScript', template << "\n\n=== CoffeScript"
|
template = template.gsub(/Liquid/, args.name.capitalize).gsub(/liquid/, args.name.downcase)
|
||||||
|
code.gsub! /^(\s*===.*CoffeeScript)/, template << "\n\\1"
|
||||||
File.open(file, "w") { |f| f << code }
|
File.open(file, "w") { |f| f << code }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue