author 1.1.3.alpha → 1.1.4.alpha

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- M2FhMTUyMGU5ZTgyNjFmZjNhMGFmNzYwMTdlODZkYjg3YjVkMjA2ZQ==
4
+ YTU2OWU2NjFkNmU1YWRlYmUyMDQ0NDFkYjUwOWY3NzBkZmYyZTdiYw==
5
5
  data.tar.gz: !binary |-
6
- NjVkNjk2MTI1OTlhNmNjZDUyNGY5ODU1ZWMzMTNmNThhMzI5Y2M5Mw==
6
+ NjE3MTA2NjVjOGI5OTZmODI0YTA1NjUxZmYxNTYyZWU3Njc3MTMxMA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NTU5Y2YyMTlhNzJmNDgyNDEwMGMxYTI2NjYyYzc2YzIzZjBmNzA3YTk2NmVm
10
- MmRhMzI4YjVhODBhZjVkOTk1ZTkwZjg2ZGJkNDc3NDBkMzlhYjgxYzExYzM5
11
- NjYyNDJjOGFlOTc3ZDliZGIwMmE3MThmYzNlMGQ5NWM1NzA4NmI=
9
+ OTY2Zjc1NTQ4YmRmYmJjZjk1M2ZhMmQxZGVmNzIxYjkwZjRiNzRiNzhiNmI1
10
+ NGUxNzdkYjI3NzdiYmRhYzk4ODIxMjU4MzUzNmU2MGJlMWI5Mjg3MzQwNGU5
11
+ MjUyZGE0N2E4ZjdjODM3MTc5YzVjNzA4ZWIwM2Y4YjViZGFiOTY=
12
12
  data.tar.gz: !binary |-
13
- Y2MzYzAwOTJjMzJmMTQ3ZGI3ODkwOTVlYzUzODEwYTFmN2VmNjliOWRjZDJm
14
- ZTAxZTRkZGYxNmIzZmUxNmVhNDk4MjQ4NGUyYWNkYjFmNTQ0MTU3NTUwZDM3
15
- Nzg5OGM4NTdlMDE4YTRhNjVkNTllMzg2MGMyMDVmZGIwMzJhYWY=
13
+ MTEzZGMwNGRkZDMxMzI5ZGI1ZDZhZTAyNjY5YmRjMTYzYWQ4ZWIwZWQwNzZl
14
+ NTkzMmE4MzE1Y2Q0YmI2YTM2MDNkOTY4MDNiNDgxMjMzNWYzMzg2YzE2NTg2
15
+ MTFmZDY0ZWUzYTgwZTFiOWZhZDkyMWYwNDFkOWNhMzFhNTc0YTg=
@@ -18,6 +18,14 @@ module Author
18
18
  Author::Exporters::PDF.export
19
19
  end
20
20
 
21
+ desc "mobi", "Build .mobi format"
22
+ def mobi
23
+ say "Building the XHTML site"
24
+ Author::Exporters::XHTML.export
25
+ say "Building the .mobi file"
26
+ Author::Exporters::Mobi.export
27
+ end
28
+
21
29
  end
22
30
  end
23
31
  end
@@ -0,0 +1,29 @@
1
+ module Author
2
+ module Exporters
3
+ class Mobi < Base
4
+ # 1. check that kindlegen is installed
5
+ # 2. check that xhtml file exists
6
+ # 4. run kindlegen command
7
+
8
+ def self.export
9
+ exporter = new
10
+ exporter.kindlegen_installed?
11
+ exporter.xhtml_exists?
12
+ exporter.export
13
+ end
14
+
15
+ def xhtml_exists?
16
+ raise "No book.xhtml file found" unless File.file?(output_path)
17
+ end
18
+
19
+ def kindlegen_installed?
20
+ raise "KindleGen is not installed. This is required to build .mobi files." unless `which kindlegen` && $?.success?
21
+ end
22
+
23
+ def export
24
+ system("kindlegen #{output_path}")
25
+ end
26
+
27
+ end
28
+ end
29
+ end
@@ -1,3 +1,3 @@
1
1
  module Author
2
- VERSION = "1.1.3.alpha"
2
+ VERSION = "1.1.4.alpha"
3
3
  end
@@ -14,4 +14,8 @@ describe Author::Commands::Builder do
14
14
  expect(output).to_include "pdf"
15
15
  end
16
16
 
17
+ it "should respond to mobi" do
18
+ expect(output).to_include "mobi"
19
+ end
20
+
17
21
  end
@@ -0,0 +1,37 @@
1
+ require_relative '../helper'
2
+ require 'author/exporters/base'
3
+ require 'author/exporters/mobi'
4
+
5
+ describe Author::Exporters::Mobi do
6
+
7
+ let(:exporter) { Author::Exporters::Mobi }
8
+
9
+ it "should respond to #export" do
10
+ expect(exporter).to_respond_to :export
11
+ end
12
+
13
+ it "should raise error if no book.xhtml file exists" do
14
+ expect { exporter.export }.to_raise RuntimeError
15
+ end
16
+
17
+ it "should raise error if no book.css file exists" do
18
+ expect { exporter.export }.to_raise RuntimeError
19
+ end
20
+
21
+ context "an instance" do
22
+ let(:exporter) { Author::Exporters::Mobi.new }
23
+
24
+ it "should respond to #kindlegen_installed?" do
25
+ expect(exporter).to_respond_to :kindlegen_installed?
26
+ end
27
+
28
+ it "should respond to #xhtml_exists?" do
29
+ expect(exporter).to_respond_to :xhtml_exists?
30
+ end
31
+
32
+ it "should respond to #export" do
33
+ expect(exporter).to_respond_to :export
34
+ end
35
+ end
36
+
37
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: author
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3.alpha
4
+ version: 1.1.4.alpha
5
5
  platform: ruby
6
6
  authors:
7
7
  - Terry Schmidt
@@ -145,6 +145,7 @@ files:
145
145
  - lib/author/commands/generator.rb
146
146
  - lib/author/commands/version.rb
147
147
  - lib/author/exporters/base.rb
148
+ - lib/author/exporters/mobi.rb
148
149
  - lib/author/exporters/pdf.rb
149
150
  - lib/author/exporters/xhtml.rb
150
151
  - lib/author/plugins/awesome_codeblock.rb
@@ -159,6 +160,7 @@ files:
159
160
  - test/commands/cli_test.rb
160
161
  - test/commands/generator_test.rb
161
162
  - test/commands/version_test.rb
163
+ - test/exporters/mobi_test.rb
162
164
  - test/exporters/pdf_test.rb
163
165
  - test/exporters/xhtml_test.rb
164
166
  - test/helper.rb
@@ -210,6 +212,7 @@ test_files:
210
212
  - test/commands/cli_test.rb
211
213
  - test/commands/generator_test.rb
212
214
  - test/commands/version_test.rb
215
+ - test/exporters/mobi_test.rb
213
216
  - test/exporters/pdf_test.rb
214
217
  - test/exporters/xhtml_test.rb
215
218
  - test/helper.rb