-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
46 lines (35 loc) · 1.25 KB
/
Rakefile
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
REMOTE="origin"
REMOTE_V="[email protected]:dmytro/startpack.git"
SOURCE_BRANCH="master"
PUBLISH_BRANCH="gh-pages"
DATE=Time.now.strftime("%Y/%m/%d %H:%M")
desc "Create build directory and gh-pages branch."
task :setup do
sh "[ -d build ] || git clone -b #{PUBLISH_BRANCH} #{REMOTE_V} build"
end
desc "compile and publish the site to Github"
task :publish do
sh "git checkout #{SOURCE_BRANCH}"
comment = %x{ git log -n 1 --no-merges --format=%s%b }.chomp.strip
sh "bundle exec middleman build"
sh "cd build && git add -A && git commit -m \"At #{DATE} #{comment}\" && git push #{REMOTE} #{PUBLISH_BRANCH}"
sh "git push origin #{SOURCE_BRANCH}"
end
namespace :dict do
desc "Generate ID spans for dictionary entries"
task :ids do
source = "source/dict.html.md"
lines = File.readlines(source).map { |line|
line.sub(%r{^- \*\*(.*)\*\*(.*)$},'- <span id="\1">**\1**</span>\2')
}
File.open(source,"w") { |f| f.print lines.join; f.close }
end
task :sort do
source = "source/dict.html.md"
lines = File.readlines(source)
start = lines.find_index { |x| x =~ %r{<start />} }
head = lines[0..start]
entries = lines - head
File.open(source,"w") { |f| f.print (head + ["\n"] + entries.sort).join; f.close }
end
end