techbook 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/techbook/builder.rb +14 -4
- data/lib/techbook/cli.rb +3 -7
- data/lib/techbook/generator.rb +10 -22
- data/lib/techbook/version.rb +1 -1
- data/templates/{01-first-chapter.asc.erb → 01-first-chapter.asc} +0 -0
- data/templates/{README.md.erb → README.md} +3 -3
- data/templates/{book.asc.erb → book.asc} +7 -7
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd65efc29e593a9cf856fd84b6c2bf053b7c336a68af8b71061abc5dcbc8626e
|
4
|
+
data.tar.gz: 563f357bfb9b9fa6e33e5456304265c7aa6705dd0d1f0ee928f13f1d6448bc9f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd1274dcbc8d8608d31c30d5987921cde3144572d7588c40c062f482bd904e0baaa81a31b21a02272c4d485db82ffc49616c0821d3ddd6fa0f07112c7a9db65b
|
7
|
+
data.tar.gz: bceb7ae25a804f60e226478e463290e481aea74ef394934421f3e36f265a1a3eb76981c807a78f5633e06f40f048e293c6b083b5277ddda711dcbef3b55641c8
|
data/Gemfile.lock
CHANGED
data/lib/techbook/builder.rb
CHANGED
@@ -9,10 +9,10 @@ require "fileutils"
|
|
9
9
|
|
10
10
|
module Techbook
|
11
11
|
class Builder
|
12
|
-
attr_accessor :basename, :pdf, :html, :epub, :mobi, :output, :file, :path
|
12
|
+
attr_accessor :basename, :pdf, :html, :epub, :mobi, :docbook, :output, :file, :path
|
13
13
|
|
14
|
-
def self.run(pdf:, html:, epub:, mobi:, output:, watch:)
|
15
|
-
b = new pdf, html, epub, mobi, output
|
14
|
+
def self.run(pdf:, html:, epub:, mobi:, docbook:, output:, watch:)
|
15
|
+
b = new pdf, html, epub, mobi, docbook, output
|
16
16
|
b.build
|
17
17
|
|
18
18
|
if watch
|
@@ -29,11 +29,12 @@ module Techbook
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
def initialize(pdf, html, epub, mobi, output)
|
32
|
+
def initialize(pdf, html, epub, mobi, docbook, output)
|
33
33
|
@pdf = pdf
|
34
34
|
@html = html
|
35
35
|
@epub = epub
|
36
36
|
@mobi = mobi
|
37
|
+
@docbook = docbook
|
37
38
|
@output = output
|
38
39
|
|
39
40
|
@basename = File.basename @output
|
@@ -49,6 +50,7 @@ module Techbook
|
|
49
50
|
|
50
51
|
build_pdf
|
51
52
|
build_html
|
53
|
+
build_docbook
|
52
54
|
build_epub
|
53
55
|
build_mobi
|
54
56
|
|
@@ -99,6 +101,13 @@ module Techbook
|
|
99
101
|
Asciidoctor.convert_file @book, base_options.merge(backend: "html")
|
100
102
|
end
|
101
103
|
|
104
|
+
def build_docbook
|
105
|
+
puts "[" + (@docbook ? "✓".green : "✕".red) + "] DOCBOOK"
|
106
|
+
return unless @docbook
|
107
|
+
|
108
|
+
Asciidoctor.convert_file @book, base_options.merge(backend: "docbook")
|
109
|
+
end
|
110
|
+
|
102
111
|
def build_epub
|
103
112
|
puts "[" + (@epub ? "✓".green : "✕".red) + "] EPUB"
|
104
113
|
return unless @epub
|
@@ -127,6 +136,7 @@ module Techbook
|
|
127
136
|
FileUtils.copy_entry File.join(@path, "src"), File.join(@output, "dist", "src")
|
128
137
|
|
129
138
|
FileUtils.copy File.join(@path, "#{@basename}.pdf"), File.join(@output, "dist") if @pdf
|
139
|
+
FileUtils.copy File.join(@path, "#{@basename}.xml"), File.join(@output, "dist") if @docbook
|
130
140
|
FileUtils.copy File.join(@path, "#{@basename}.html"), File.join(@output, "dist") if @html
|
131
141
|
FileUtils.copy File.join(@path, "#{@basename}.epub"), File.join(@output, "dist") if @epub
|
132
142
|
FileUtils.copy File.join(@path, "#{@basename}.mobi"), File.join(@output, "dist") if @mobi
|
data/lib/techbook/cli.rb
CHANGED
@@ -5,21 +5,16 @@ module Techbook
|
|
5
5
|
class CLI < Thor
|
6
6
|
class_option :output, aliases: 'o', default: Dir.pwd
|
7
7
|
|
8
|
-
option :author, aliases: 'a', default: 'Your Name'
|
9
|
-
option :email, aliases: 'e', default: 'you@example.com'
|
10
|
-
option :lang, aliases: 'l', default: 'en'
|
11
8
|
desc "generate NAME", "Create book templates as NAME in specified output."
|
12
9
|
def generate(name)
|
13
|
-
Generator::run name,
|
14
|
-
email: options[:email],
|
15
|
-
output: options[:output],
|
16
|
-
lang: options[:lang]
|
10
|
+
Generator::run name, output: options[:output]
|
17
11
|
end
|
18
12
|
|
19
13
|
option :pdf, type: :boolean, default: true
|
20
14
|
option :mobi, type: :boolean
|
21
15
|
option :epub, type: :boolean
|
22
16
|
option :html, type: :boolean
|
17
|
+
option :docbook, type: :boolean
|
23
18
|
option :watch, type: :boolean
|
24
19
|
desc "build", "Build the book."
|
25
20
|
def build
|
@@ -27,6 +22,7 @@ module Techbook
|
|
27
22
|
mobi: options[:mobi],
|
28
23
|
epub: options[:epub],
|
29
24
|
html: options[:html],
|
25
|
+
docbook: options[:docbook],
|
30
26
|
output: options[:output],
|
31
27
|
watch: options[:watch]
|
32
28
|
end
|
data/lib/techbook/generator.rb
CHANGED
@@ -1,30 +1,24 @@
|
|
1
1
|
require "techbook"
|
2
|
-
|
3
2
|
require "fileutils"
|
4
|
-
require "erb"
|
5
3
|
|
6
4
|
module Techbook
|
7
5
|
class Generator
|
8
|
-
attr_accessor :name, :
|
6
|
+
attr_accessor :name, :path, :basename, :output
|
9
7
|
|
10
|
-
def self.run(name,
|
11
|
-
g = new name,
|
8
|
+
def self.run(name, output:)
|
9
|
+
g = new name, output
|
12
10
|
g.generate
|
13
11
|
end
|
14
12
|
|
15
|
-
def initialize(name,
|
13
|
+
def initialize(name, output)
|
16
14
|
@name = name
|
17
|
-
@author = author
|
18
|
-
@email = email
|
19
15
|
@output = output
|
20
|
-
@lang = lang
|
21
16
|
end
|
22
17
|
|
23
18
|
def generate
|
24
19
|
puts "Generating book as #{@name} in #{@output}...".yellow
|
25
20
|
create_dir
|
26
21
|
copy_files
|
27
|
-
render_files
|
28
22
|
end
|
29
23
|
|
30
24
|
private
|
@@ -37,21 +31,15 @@ module Techbook
|
|
37
31
|
end
|
38
32
|
|
39
33
|
def copy_files
|
40
|
-
FileUtils.cp File.join(Techbook.root, "templates", "book
|
41
|
-
FileUtils.cp File.join(Techbook.root, "templates", "
|
42
|
-
FileUtils.cp File.join(Techbook.root, "templates", "keep"), File.join(@path, "book", "src", ".keep")
|
34
|
+
FileUtils.cp File.join(Techbook.root, "templates", "book.asc"), File.join(@path, "#{@basename}.asc")
|
35
|
+
FileUtils.cp File.join(Techbook.root, "templates", "book-theme.yml"), File.join(@path, "book-theme.yml")
|
43
36
|
FileUtils.cp File.join(Techbook.root, "templates", "gitignore"), File.join(@path, ".gitignore")
|
44
|
-
|
37
|
+
FileUtils.cp File.join(Techbook.root, "templates", "README.md"), File.join(@path, "README.md")
|
45
38
|
|
46
|
-
|
47
|
-
layout = File.read File.join(Techbook.root, "templates", "book.asc.erb")
|
48
|
-
File.open(File.join(@path, "#{@basename}.asc"), "w") { |file| file.write(ERB.new(layout).result(binding)) }
|
39
|
+
FileUtils.cp File.join(Techbook.root, "templates", "01-first-chapter.asc"), File.join(@path, "book", "01-first-chapter.asc")
|
49
40
|
|
50
|
-
|
51
|
-
File.
|
52
|
-
|
53
|
-
readme = File.read File.join(Techbook.root, "templates", "README.md.erb")
|
54
|
-
File.open(File.join(@path, "README.md"), "w") { |file| file.write(ERB.new(readme).result(binding)) }
|
41
|
+
FileUtils.cp File.join(Techbook.root, "templates", "keep"), File.join(@path, "book", "img", ".keep")
|
42
|
+
FileUtils.cp File.join(Techbook.root, "templates", "keep"), File.join(@path, "book", "src", ".keep")
|
55
43
|
end
|
56
44
|
|
57
45
|
def sanitize(filename)
|
data/lib/techbook/version.rb
CHANGED
File without changes
|
@@ -1,5 +1,5 @@
|
|
1
|
-
=
|
2
|
-
|
1
|
+
= My Awesome Book: The fabulous book about me
|
2
|
+
Me <me@email.com>
|
3
3
|
:doctype: book
|
4
4
|
:reproducible:
|
5
5
|
:experimental:
|
@@ -8,13 +8,13 @@
|
|
8
8
|
:toclevels: 2
|
9
9
|
:toc-placement: preamble
|
10
10
|
ifdef::backend-pdf[]
|
11
|
-
:pdf-theme:
|
11
|
+
:pdf-theme: book
|
12
12
|
:pdf-themesdir: {docdir}/../
|
13
|
-
// :title-logo-image: img
|
13
|
+
// :title-logo-image: img/cover.svg
|
14
14
|
:source-highlighter: rouge
|
15
|
-
// :rouge-style: monokai.sublime
|
15
|
+
// :rouge-style: base16, bw, colorful, github [default], gruvbox, igorpro, magritte, molokai, monokai, monokai.sublime, pastie, thankful_eyes, tulip
|
16
16
|
endif::[]
|
17
|
-
:lang:
|
17
|
+
:lang: en
|
18
18
|
:appendix-caption: Appendix
|
19
19
|
:caution-caption: Caution
|
20
20
|
:warning-caption: Warning
|
@@ -33,4 +33,4 @@ endif::[]
|
|
33
33
|
:version-label: Version
|
34
34
|
|
35
35
|
// New chapters will be included automatically here...
|
36
|
-
include::
|
36
|
+
include::01-first-chapter.asc[]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: techbook
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Felipe Fontoura
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-08-
|
11
|
+
date: 2019-08-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -229,10 +229,10 @@ files:
|
|
229
229
|
- lib/techbook/publisher.rb
|
230
230
|
- lib/techbook/version.rb
|
231
231
|
- techbook.gemspec
|
232
|
-
- templates/01-first-chapter.asc
|
233
|
-
- templates/README.md
|
232
|
+
- templates/01-first-chapter.asc
|
233
|
+
- templates/README.md
|
234
234
|
- templates/book-theme.yml
|
235
|
-
- templates/book.asc
|
235
|
+
- templates/book.asc
|
236
236
|
- templates/gitignore
|
237
237
|
- templates/keep
|
238
238
|
homepage: https://github.com/felipefontoura/techbook
|