Skip to content

Commit f2678ab

Browse files
authored
Merge pull request #1130 from dfa1/simplify_rakefile
inject version and date using attributes
2 parents 9538178 + 19c515a commit f2678ab

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

Rakefile

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,32 @@ namespace :book do
22
desc 'build basic book formats'
33
task :build do
44

5-
`cp progit.asc progit.asc.bak`
65
begin
76
version_string = ENV['TRAVIS_TAG'] || `git describe --tags`.chomp
87
if version_string.empty?
98
version_string = '0'
109
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}'"
1512
puts "Generating contributors list"
1613
`git shortlog -s | grep -v -E "(Straub|Chacon)" | cut -f 2- | column -c 120 > book/contributors.txt`
1714

1815
puts "Converting to HTML..."
19-
`bundle exec asciidoctor progit.asc`
16+
`bundle exec asciidoctor #{params} progit.asc`
2017
puts " -- HTML output at progit.html"
2118

2219
puts "Converting to EPub..."
23-
`bundle exec asciidoctor-epub3 progit.asc`
20+
`bundle exec asciidoctor-epub3 #{params} progit.asc`
2421
puts " -- Epub output at progit.epub"
2522

2623
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`
2825
puts " -- Mobi output at progit.mobi"
2926

3027
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`
3229
puts " -- PDF output at progit.pdf"
3330

34-
ensure
35-
`mv progit.asc.bak progit.asc`
3631
end
3732
end
3833
end

progit.asc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Pro Git
22
=======
33
Scott Chacon; Ben Straub
4-
$$VERSION$$, $$DATE$$
4+
55
:doctype: book
66
:docinfo:
77
:toc:

0 commit comments

Comments
 (0)