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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8e1d2047c6a4d4c0f9a7347f853b4396fa4994e190f347837d9148b177fa29af
4
- data.tar.gz: 7c8f8c1dc85bafdb364fa4bbb7bac8fc3785a92ce118e8d5884fbdb07a3c5424
3
+ metadata.gz: dd65efc29e593a9cf856fd84b6c2bf053b7c336a68af8b71061abc5dcbc8626e
4
+ data.tar.gz: 563f357bfb9b9fa6e33e5456304265c7aa6705dd0d1f0ee928f13f1d6448bc9f
5
5
  SHA512:
6
- metadata.gz: 2392d7aec4e6fb498cea5ec90d8ff26e368002045418168e6dc97104fb7ae34adbfad6600f42a367daa5a18a30139b858b14617518a7de42e027feefd4499ea8
7
- data.tar.gz: 5db6e39b89817e33f38430a666c6d461e42c0d5648b7af3e7fa8469198615d2c67226ec0547c060e50a4d10153b39e1d879c1c6724f40f5e4d00502d2fdfb3b4
6
+ metadata.gz: dd1274dcbc8d8608d31c30d5987921cde3144572d7588c40c062f482bd904e0baaa81a31b21a02272c4d485db82ffc49616c0821d3ddd6fa0f07112c7a9db65b
7
+ data.tar.gz: bceb7ae25a804f60e226478e463290e481aea74ef394934421f3e36f265a1a3eb76981c807a78f5633e06f40f048e293c6b083b5277ddda711dcbef3b55641c8
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- techbook (0.1.2)
4
+ techbook (0.2.0)
5
5
  asciidoctor (~> 2.0)
6
6
  asciidoctor-diagram (~> 1.5, >= 1.5.18)
7
7
  asciidoctor-epub3 (~> 1.5.0.alpha.9)
@@ -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, author: options[:author],
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
@@ -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, :author, :email, :path, :basename, :output, :lang
6
+ attr_accessor :name, :path, :basename, :output
9
7
 
10
- def self.run(name, author:, email:, output:, lang:)
11
- g = new name, author, email, output, lang
8
+ def self.run(name, output:)
9
+ g = new name, output
12
10
  g.generate
13
11
  end
14
12
 
15
- def initialize(name, author, email, output, lang)
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-theme.yml"), File.join(@path, "#{@basename}-theme.yml")
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")
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
- end
37
+ FileUtils.cp File.join(Techbook.root, "templates", "README.md"), File.join(@path, "README.md")
45
38
 
46
- def render_files
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
- first_chapter = File.read File.join(Techbook.root, "templates", "01-first-chapter.asc.erb")
51
- File.open(File.join(@path, "book", "01-first-chapter.asc"), "w") { |file| file.write(ERB.new(first_chapter).result(binding)) }
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)
@@ -1,3 +1,3 @@
1
1
  module Techbook
2
- VERSION = "0.1.2"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -1,10 +1,10 @@
1
- # <%= name %>
1
+ # My Awesome Book
2
2
 
3
- By <%= author %>
3
+ Me <me@email.com>
4
4
 
5
5
  ## Build
6
6
 
7
7
  To build this book type the following commands:
8
8
 
9
- $ cd <%= basename %>
9
+ $ cd your-book
10
10
  $ techbook build
@@ -1,5 +1,5 @@
1
- = <%= name %>
2
- <%= author %> <<%= email %>>
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: <%= basename %>
11
+ :pdf-theme: book
12
12
  :pdf-themesdir: {docdir}/../
13
- // :title-logo-image: img:cover.svg[pdfwidth=4.25in,align=center]
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: <%= 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::book/01-first-chapter.asc[]
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.1.2
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-05 00:00:00.000000000 Z
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.erb
233
- - templates/README.md.erb
232
+ - templates/01-first-chapter.asc
233
+ - templates/README.md
234
234
  - templates/book-theme.yml
235
- - templates/book.asc.erb
235
+ - templates/book.asc
236
236
  - templates/gitignore
237
237
  - templates/keep
238
238
  homepage: https://github.com/felipefontoura/techbook