Skip to content

Commit 349ef8c

Browse files
committed
Add mobi format
1 parent 281090f commit 349ef8c

File tree

3 files changed

+27
-8
lines changed

3 files changed

+27
-8
lines changed

Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@ gem "concurrent-ruby", "~> 1.1"
1515
gem "rouge", "~> 3.3"
1616

1717
gem "asciidoctor-epub3", "~> 1.5.alpha.8"
18+
19+
gem "kindlegen", "~> 3.0"

Gemfile.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ GEM
2727
nokogiri (~> 1.6.1)
2828
rubyzip (>= 1.1.1)
2929
hashery (2.1.2)
30+
kindlegen (3.0.3)
31+
rake
32+
rubyzip
3033
mini_portile2 (2.1.0)
3134
nokogiri (1.6.8.1)
3235
mini_portile2 (~> 2.1.0)
@@ -52,6 +55,7 @@ GEM
5255
pdf-reader (~> 2.0)
5356
prawn (~> 2.2)
5457
public_suffix (3.0.3)
58+
rake (12.3.2)
5559
rouge (3.3.0)
5660
ruby-rc4 (0.1.5)
5761
rubyzip (1.2.2)
@@ -69,6 +73,7 @@ DEPENDENCIES
6973
asciidoctor-epub3 (~> 1.5.alpha.8)
7074
asciidoctor-pdf (~> 1.5.alpha.16)
7175
concurrent-ruby (~> 1.1)
76+
kindlegen (~> 3.0)
7277
rouge (~> 3.3)
7378

7479
BUNDLED WITH

Rakefile

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,40 @@ def parse_lang(args)
1010
lang
1111
end
1212

13+
def out_filename(lang, extension)
14+
"api_on_rails-#{lang}.#{extension}"
15+
end
16+
1317
namespace :build do
1418
desc 'Build a PDF version'
1519
task :pdf, [:lang] do |_task, args|
16-
`asciidoctor-pdf #{parse_lang(args)}/api_on_rails.adoc --destination-dir build`
17-
puts 'Book build on build/api_on_rails.pdf'
20+
lang = parse_lang(args)
21+
filename = out_filename lang, 'pdf'
22+
`asciidoctor-pdf #{lang}/api_on_rails.adoc --destination-dir build --out-file #{filename}`
23+
puts "Book compiled on build/#{filename}"
1824
end
1925

2026
desc 'Build an HTML version'
2127
task :html, [:lang] do |_task, args|
22-
`asciidoctor #{parse_lang(args)}/api_on_rails.adoc --destination-dir build`
23-
puts 'Book build on build/api_on_rails.html'
28+
lang = parse_lang(args)
29+
filename = out_filename lang, 'html'
30+
`asciidoctor #{lang}/api_on_rails.adoc --destination-dir build --out-file #{filename}`
31+
puts "Book compiled on build/#{filename}"
2432
end
2533

2634
desc 'Build an EPUB version'
2735
task :epub, [:lang] do |_task, args|
28-
`asciidoctor-epub3 #{parse_lang(args)}/api_on_rails.adoc --destination-dir build`
29-
puts 'Book build on build/api_on_rails.epub'
36+
lang = parse_lang(args)
37+
filename = out_filename lang, 'epub'
38+
`asciidoctor-epub3 #{lang}/api_on_rails.adoc --destination-dir build --out-file #{filename}`
39+
puts "Book compiled on build/#{filename}"
3040
end
3141

3242
desc 'Build a MOBI version'
3343
task :mobi, [:lang] do |_task, args|
34-
`asciidoctor-epub3 #{parse_lang(args)}/api_on_rails.adoc --destination-dir build`
35-
puts 'Book build on build/api_on_rails.mobi'
44+
lang = parse_lang(args)
45+
filename = out_filename lang, 'mobi'
46+
`asciidoctor-epub3 #{lang}/api_on_rails.adoc --destination-dir build -a ebook-format=kf8 --out-file #{filename}`
47+
puts "Book compiled on build/api_on_rails-#{lang}-kf8.epub"
3648
end
3749
end

0 commit comments

Comments
 (0)