@@ -2,37 +2,32 @@ namespace :book do
2
2
desc 'build basic book formats'
3
3
task :build do
4
4
5
- `cp progit.asc progit.asc.bak`
6
5
begin
7
6
version_string = ENV [ 'TRAVIS_TAG' ] || `git describe --tags` . chomp
8
7
if version_string . empty?
9
8
version_string = '0'
10
9
end
11
- text = File . read ( 'progit.asc' )
12
- new_contents = text . gsub ( "$$VERSION$$" , version_string ) . gsub ( "$$DATE$$" , Time . now . strftime ( "%Y-%m-%d" ) )
13
- File . open ( "progit.asc" , "w" ) { |file | file . puts new_contents }
14
-
10
+ date_string = Time . now . strftime ( "%Y-%m-%d" )
11
+ params = "--attribute revnumber='#{ version_string } ' --attribute revdate='#{ date_string } '"
15
12
puts "Generating contributors list"
16
13
`git shortlog -s | grep -v -E "(Straub|Chacon)" | cut -f 2- | column -c 120 > book/contributors.txt`
17
14
18
15
puts "Converting to HTML..."
19
- `bundle exec asciidoctor progit.asc`
16
+ `bundle exec asciidoctor #{ params } progit.asc`
20
17
puts " -- HTML output at progit.html"
21
18
22
19
puts "Converting to EPub..."
23
- `bundle exec asciidoctor-epub3 progit.asc`
20
+ `bundle exec asciidoctor-epub3 #{ params } progit.asc`
24
21
puts " -- Epub output at progit.epub"
25
22
26
23
puts "Converting to Mobi (kf8)..."
27
- `bundle exec asciidoctor-epub3 -a ebook-format=kf8 progit.asc`
24
+ `bundle exec asciidoctor-epub3 #{ params } -a ebook-format=kf8 progit.asc`
28
25
puts " -- Mobi output at progit.mobi"
29
26
30
27
puts "Converting to PDF... (this one takes a while)"
31
- `bundle exec asciidoctor-pdf progit.asc 2>/dev/null`
28
+ `bundle exec asciidoctor-pdf #{ params } progit.asc 2>/dev/null`
32
29
puts " -- PDF output at progit.pdf"
33
30
34
- ensure
35
- `mv progit.asc.bak progit.asc`
36
31
end
37
32
end
38
33
end
0 commit comments