-
-
Notifications
You must be signed in to change notification settings - Fork 81
/
Rakefile.rb
51 lines (47 loc) · 1.33 KB
/
Rakefile.rb
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
task :default do
sh "compass compile"
end
task :doc do
require 'git'
require 'fileutils'
repo = Git.open('.')
# copy source into a build dir
buildDir = "build"
FileUtils.rm_rf buildDir
FileUtils.mkdir(buildDir)
(
FileList.new('docs/**/*')+
FileList.new('javascripts/**/*')+
FileList.new('lib/**/*')+
FileList.new('stylesheets/**/*')+
FileList.new('templates/**/*')+
FileList.new('tests/**/*')+
["index.html"]
).each do |file|
if File.file?(file)
if !File.directory?(File.dirname("#{buildDir}/#{file}"))
puts 'Mkdir' + File.dirname("#{buildDir}/#{file}")
FileUtils.mkdir_p(File.dirname("#{buildDir}/#{file}"))
end
FileUtils.cp(file, "#{buildDir}/#{file}")
puts 'File ' + file
else #assume dir
FileUtils.mkdir_p("#{buildDir}/#{file}")
puts 'Dir ' + file
end
end
# Prepare tests addons
headMarker = '<!doctype html>'
# take latest header & footer layout for tests
htmlHeader = headMarker + File.open("docs/layout/header.html", "r").read
htmlFooter = File.open("docs/layout/footer.html", "r").read
# HTML files need header and footer
FileList.new('#buildDir/tests/**/*.html').each do |file|
contents = File.open(file, "rb").read
htmlfile = File.open("#{file}", "w")
contents = contents.sub(headMarker, htmlHeader)
htmlFooter += contents
htmlfile.write(contents)
htmlfile.close
end
end