-
Notifications
You must be signed in to change notification settings - Fork 6
/
Rakefile
81 lines (74 loc) · 2.06 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# To use this build script, first install the bundler gem:
#
# $ gem install bundler
#
# Then use the `bundle` command to install the dependencies into the project:
#
# $ rm -rf Gemfile.lock .bundle
# bundle config --local git.allow_insecure true
# bundle config --local build.nokogiri --use-system-libraries
# bundle --path=.bundle/gems
#
# NOTE The gems are installed under the path .bundle/gems.
#
# Finally, run a named task using the `bundle exec rake` command:
#
# $ bundle exec rake pdf
#
# You can find a list of tasks using the following:
#
# $ bundle exec rake -T
#
MASTER_FILENAME='learn-rails-51-part-II.adoc'
BUILD_DIR='output'
autoload :FileUtils, 'fileutils'
desc 'Build the HTML5 format'
task :html do
require 'asciidoctor'
Asciidoctor.convert_file MASTER_FILENAME,
safe: :unsafe,
# FIXME task should copy images instead of embedding them
attributes: 'data-uri',
to_dir: BUILD_DIR,
mkdirs: true
end
desc 'Build the PDF format'
task :pdf do
require 'asciidoctor-pdf'
Asciidoctor.convert_file MASTER_FILENAME,
safe: :unsafe,
backend: 'pdf',
to_dir: BUILD_DIR,
mkdirs: true
end
# TIP invoke using epub[ebook-validate] to validate
desc 'Build the EPUB3 format'
task :epub, [:attrs] do |_, args|
require 'asciidoctor-epub3'
Asciidoctor.convert_file MASTER_FILENAME,
safe: :unsafe,
backend: 'epub3',
attributes: ['epub3-stylesdir=styles/epub3', args[:attrs]].compact * ' ',
to_dir: BUILD_DIR,
mkdirs: true
end
desc 'Build the MOBI format'
task :mobi do
require 'asciidoctor-epub3'
Asciidoctor.convert_file MASTER_FILENAME,
safe: :unsafe,
backend: 'epub3',
attributes: 'epub3-stylesdir=styles/epub3 ebook-format=kf8 ebook-compress=huffdic',
to_dir: BUILD_DIR,
mkdirs: true
File.unlink %(#{BUILD_DIR}/#{File.basename MASTER_FILENAME, '.*'}-kf8.epub)
end
task kf8: :mobi
desc 'Build the EPUB3 and MOBI formats'
task ebook: [:epub, :mobi]
desc 'Build all formats'
task default: [:html, :ebook, :pdf]
desc 'Clean the build directory'
task :clean do
FileUtils.remove_entry_secure BUILD_DIR
end