softcover 0.6.7 → 0.6.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 18e10cc07c83b7d50616aa5a8a627b434ed437de
4
- data.tar.gz: 9579bb03abbf836ed83e86aef3a2ecb996183f5f
3
+ metadata.gz: 5647cff927ffdc738c3bec013c0c729d3397a429
4
+ data.tar.gz: 1d588aa9b57576bbec00cafed17338e6b9daec4b
5
5
  SHA512:
6
- metadata.gz: 45e0e95ed9a948cce46ebb8c282345af60d3befbb578cce6d7ea1b674e43a7ff575d41f86cd527ebc4dc1dcfa22f075d9af8a78baf463e3d554f89223ee6d0ff
7
- data.tar.gz: 9c7d2c428d7c4856f1a97cb70e1a9538982372b869e08a920773cb457c13a4ff5ecf117da1c19339ba328cf0e22ad5ff322312861850daf6b7a79e8be2b44e6d
6
+ metadata.gz: cb8ef238014720f30ce9a72e08c49ad2ba06100b44ef92ce2034e74c09be8859c47031e394eb802b38b86550b08ff967f8ecb276c6a7ac40db9da75421c64b0b
7
+ data.tar.gz: ce8b423b371662063f4068378b7d4e5670f1a8d93cdc9621bc8dba818728602d4b04fbed5fe329899dc483a2964a867bff4e122d40a0928e24b43bc96a2f6825
File without changes
File without changes
@@ -373,7 +373,7 @@ module Softcover
373
373
  %(<?xml version="1.0" encoding="UTF-8"?>
374
374
  <ncx xmlns="http://www.daisy.org/z3986/2005/ncx/" version="2005-1">
375
375
  <head>
376
- <meta name="dtb:uid" content="d430b920-e684-11e1-aff1-0800200c9a66"/>
376
+ <meta name="dtb:uid" content="#{manifest.uuid}"/>
377
377
  <meta name="dtb:depth" content="2"/>
378
378
  <meta name="dtb:totalPageCount" content="0"/>
379
379
  <meta name="dtb:maxPageNumber" content="0"/>
@@ -4,21 +4,44 @@ module Softcover
4
4
 
5
5
  def build!(options={})
6
6
  Softcover::Builders::Epub.new.build!(options)
7
- filename = manifest.filename
8
- filename += '-preview' if options[:preview]
9
- command = "#{kindlegen} ebooks/#{filename}.epub"
10
- # Because of the way kindlegen uses tempfiles, testing for the
11
- # actual generation of the MOBI causes an error, so in tests
12
- # we just return the command.
13
- if options[:quiet] || options[:silent]
14
- silence { Softcover.test? ? command : system(command) }
7
+ filename = mobi_filename(options)
8
+ command = mobi_command(filename, options)
9
+ silent = options[:silent] || Softcover.test?
10
+ if options[:quiet] || silent
11
+ silence { system(command) }
15
12
  else
16
- Softcover.test? ? command : system(command)
13
+ system(command)
14
+ end
15
+ unless options[:kindlegen]
16
+ FileUtils.mv("ebooks/#{filename}.azw3", "ebooks/#{filename}.mobi")
17
+ puts "MOBI saved to ebooks/#{filename}.mobi" unless silent
18
+ end
19
+ end
20
+
21
+ # Returns the filename of the MOBI (preview if necessary).
22
+ def mobi_filename(options={})
23
+ options[:preview] ? manifest.filename + '-preview' : manifest.filename
24
+ end
25
+
26
+ # Returns the command for making a MOBI, based on the options.
27
+ def mobi_command(filename, options={})
28
+ if options[:kindlegen]
29
+ "#{kindlegen} ebooks/#{filename}.epub"
30
+ else
31
+ "#{calibre} ebooks/#{filename}.epub ebooks/#{filename}.azw3"
17
32
  end
18
33
  end
19
34
 
20
35
  private
21
36
 
37
+ def calibre
38
+ filename = `which ebook-convert`.chomp
39
+ url = 'http://calibre-ebook.com/'
40
+ message = "Install Calibre (#{url}) and enable command line tools"
41
+ message += " (http://manual.calibre-ebook.com/cli/cli-index.html)"
42
+ @calibre ||= executable(filename, message)
43
+ end
44
+
22
45
  def kindlegen
23
46
  filename = `which kindlegen`.chomp
24
47
  url = 'http://www.amazon.com/gp/feature.html?ie=UTF8&docId=1000765211'
@@ -37,7 +37,6 @@ module Softcover
37
37
 
38
38
  polytex_filenames = manifest.pdf_chapter_filenames << book_filename
39
39
  polytex_filenames.each do |filename|
40
- puts filename unless options[:quiet] || options[:silent]
41
40
  polytex = File.open(filename) { |f| f.read }
42
41
  latex = Polytexnic::Pipeline.new(polytex).to_latex
43
42
  if filename == book_filename
data/lib/softcover/cli.rb CHANGED
@@ -6,7 +6,7 @@ module Softcover
6
6
 
7
7
  map "-v" => :version
8
8
 
9
- desc "version", "Return the version number"
9
+ desc "version", "Return the version number (-v for short)"
10
10
  method_option :version, aliases: '-v',
11
11
  desc: "Print version number", type: :boolean
12
12
  def version
@@ -41,6 +41,10 @@ module Softcover
41
41
  method_option :'find-overfull', aliases: '-f',
42
42
  desc: "Find overfull hboxes",
43
43
  type: :boolean
44
+ elsif format == 'mobi'
45
+ method_option :kindlegen, aliases: '-k',
46
+ desc: "Use kindlegen to build the MOBI",
47
+ type: :boolean
44
48
  end
45
49
  method_option :quiet, aliases: '-q',
46
50
  desc: "Quiet output", type: :boolean
@@ -22,9 +22,8 @@ module Softcover
22
22
 
23
23
  def epubcheck
24
24
  filename = File.join(Dir.home, 'epubcheck-3.0', 'epubcheck-3.0.jar')
25
- url = 'https://code.google.com/p/epubcheck/downloads/' +
26
- 'detail?name=epubcheck-3.0.zip'
27
- message = "Put EpubCheck (#{url}) in your home directory"
25
+ url = 'https://github.com/IDPF/epubcheck/releases/download/v3.0/epubcheck-3.0.zip'
26
+ message = "Download EpubCheck 3.0 (#{url}) and unzip it in your home directory"
28
27
  @epubcheck ||= executable(filename, message).inspect
29
28
  end
30
29
  end
@@ -30,4 +30,5 @@ screencasts/
30
30
 
31
31
  # Other miscellaneous files
32
32
  log/
33
+ *.bak
33
34
  .DS_Store
@@ -18,6 +18,15 @@ body #book {
18
18
 
19
19
  #book h2 {
20
20
  font-size: 180%;
21
+ margin-top: 1.5em;
22
+ }
23
+
24
+ #book h3 {
25
+ margin-top: 1.5em;
26
+ }
27
+
28
+ #book h4 {
29
+ margin-top: 2em;
21
30
  }
22
31
 
23
32
  #book img.tex {
@@ -96,7 +105,7 @@ body #book {
96
105
  margin-top: 0.2em;
97
106
  width: 100%;
98
107
  white-space: pre;
99
- font-family: Courier, monospace;
108
+ font-family: "Courier New", Courier, monospace;
100
109
  border: 1px solid #999;
101
110
  background: #eee;
102
111
  margin-bottom: 1em;
@@ -133,6 +142,11 @@ body #book {
133
142
  margin-top: -0.4em;
134
143
  }
135
144
 
145
+ #book .code .highlight .lineno {
146
+ color: #666;
147
+ font-weight: normal;
148
+ }
149
+
136
150
  #book .filepath {
137
151
  font-family: Courier, monospace;
138
152
  font-size: 80%;
@@ -46,8 +46,9 @@
46
46
  \definecolor{darkblue}{rgb}{0,0.18,0.45}
47
47
  \definecolor{darkgreen}{rgb}{0,0.39,0}
48
48
  % Bizarrely, we need to define the ALL CAPS version of DARKGREEN to account
49
- % for some edge cases, whose nature remains myterious.
49
+ % for some edge cases, whose nature remains mysterious.
50
50
  \definecolor{DARKGREEN}{rgb}{0,0.39,0}
51
+ \definecolor{hilightyellow}{rgb}{1.0,1.0,0.8}
51
52
  \hypersetup{colorlinks,linkcolor=darkblue,urlcolor=blue}
52
53
 
53
54
  % Code environments
@@ -1,3 +1,3 @@
1
1
  module Softcover
2
- VERSION = "0.6.7"
2
+ VERSION = "0.6.9"
3
3
  end
data/softcover.gemspec CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |gem|
18
18
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
19
  gem.require_paths = ["lib"]
20
20
 
21
- gem.add_dependency 'polytexnic', '~> 0.5'
21
+ gem.add_dependency 'polytexnic', '~> 0.6.9'
22
22
  gem.add_dependency 'msgpack', '~> 0.4.2'
23
23
  gem.add_dependency 'nokogiri', '~> 1.5.0'
24
24
  gem.add_dependency 'thor'
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Softcover::Builders::Mobi do
4
- context "for a PolyTeX book" do
4
+ describe "#build!" do
5
5
  before(:all) do
6
6
  generate_book
7
7
  @builder = Softcover::Builders::Mobi.new
@@ -10,37 +10,34 @@ describe Softcover::Builders::Mobi do
10
10
  end
11
11
  after(:all) { remove_book }
12
12
 
13
- describe "#build!" do
14
- it "should generate the EPUB" do
15
- expect('ebooks/book.epub').to exist
16
- end
13
+ it "should generate the MOBI" do
14
+ expect('ebooks/book.mobi').to exist
15
+ end
17
16
 
18
- # Because of the way kindlegen uses tempfiles, testing for the
19
- # actual generation of the MOBI causes an error, so we just
20
- # check the command.
21
- describe "MOBI generation" do
22
- subject(:built) { @built }
23
- it { should match /kindlegen/ }
24
- it { should match /ebooks\/book\.epub/ }
17
+ describe "MOBI command" do
18
+ context "default" do
19
+ let(:command) { @builder.mobi_command(@builder.mobi_filename) }
20
+ it "should use Calibre's ebook-convert" do
21
+ expect(command).to include 'ebook-convert'
22
+ end
25
23
  end
26
- end
27
- end
28
24
 
29
- context "for a Markdown book" do
30
- before(:all) do
31
- generate_book(markdown: true)
32
- @builder = Softcover::Builders::Mobi.new
33
- @built = @builder.build!
34
- chdir_to_book
35
- end
36
- after(:all) { remove_book }
25
+ context "kindlegen" do
26
+ let(:command) do
27
+ @builder.mobi_command(@builder.mobi_filename, kindlegen: true)
28
+ end
29
+ it "should use Amazon.com's kindlegen" do
30
+ expect(command).to include 'kindlegen'
31
+ end
32
+ end
37
33
 
38
- describe "#build!" do
39
- describe "MOBI generation" do
40
- subject(:built) { @built }
41
- it { should match /kindlegen/ }
42
- it { should match /ebooks\/book\.epub/ }
43
- it { should_not match /Book.txt.epub/ }
34
+ context "preview" do
35
+ let(:filename) do
36
+ @builder.mobi_filename(preview: true)
37
+ end
38
+ it "should use Calibre's ebook-convert" do
39
+ expect(filename).to include 'book-preview'
40
+ end
44
41
  end
45
42
  end
46
43
  end
@@ -2,59 +2,40 @@ require 'spec_helper'
2
2
 
3
3
  describe Softcover::Builders::Preview do
4
4
 
5
- context "for a PolyTeX book" do
6
- before(:all) do
7
- generate_book
8
- @builder = Softcover::Builders::Preview.new
9
- @builder.build!
10
- chdir_to_book
5
+ before(:all) do
6
+ generate_book
7
+ @builder = Softcover::Builders::Preview.new
8
+ @builder.build!
9
+ chdir_to_book
10
+ end
11
+ after(:all) { remove_book }
12
+
13
+ describe "#build!" do
14
+
15
+ it "should build a PDF" do
16
+ expect('ebooks/book-preview.pdf').to exist
11
17
  end
12
- after(:all) { remove_book }
13
18
 
14
- describe "#build!" do
19
+ context "EPUB & MOBI books" do
20
+ it "should build an EPUB" do
21
+ expect('ebooks/book-preview.epub').to exist
22
+ end
15
23
 
16
- it "should build a PDF" do
17
- expect('ebooks/book-preview.pdf').to exist
24
+ it "should build an EPUB" do
25
+ expect('ebooks/book-preview.mobi').to exist
18
26
  end
19
27
 
20
- context "EPUB & MOBI books" do
21
- it "should build an EPUB" do
22
- expect('ebooks/book-preview.epub').to exist
28
+ it "should include the right chapters" do
29
+ @builder.manifest.preview_chapters.each do |ch|
30
+ expect(File.join('epub', 'OEBPS', ch.fragment_name)).to exist
23
31
  end
24
-
25
- #
26
- # We don't test for MOBI because kindlegen doesn't work in tests.
27
- #
28
-
29
- it "should include the right chapters" do
30
- @builder.manifest.preview_chapters.each do |ch|
31
- expect(File.join('epub', 'OEBPS', ch.fragment_name)).to exist
32
- end
33
- nonpreview_chapters = @builder.manifest.chapters -
34
- @builder.manifest.preview_chapters
35
- nonpreview_chapters.each do |ch|
36
- expect(File.join('epub', 'OEBPS', ch.fragment_name)).not_to exist
37
- end
32
+ nonpreview_chapters = @builder.manifest.chapters -
33
+ @builder.manifest.preview_chapters
34
+ nonpreview_chapters.each do |ch|
35
+ expect(File.join('epub', 'OEBPS', ch.fragment_name)).not_to exist
38
36
  end
39
37
  end
40
38
  end
41
39
  end
42
-
43
- context "for a Markdown book" do
44
- before(:all) do
45
- generate_book(markdown: true)
46
- @builder = Softcover::Builders::Preview.new
47
- @builder.build!
48
- chdir_to_book
49
- end
50
- after(:all) { remove_book }
51
-
52
- describe "#build!" do
53
-
54
- it "should build a PDF" do
55
- expect('ebooks/book-preview.pdf').to exist
56
- end
57
- end
58
- end
59
40
  end
60
41
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: softcover
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.7
4
+ version: 0.6.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Hartl
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-11-27 00:00:00.000000000 Z
12
+ date: 2013-11-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: polytexnic
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - ~>
19
19
  - !ruby/object:Gem::Version
20
- version: '0.5'
20
+ version: 0.6.9
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - ~>
26
26
  - !ruby/object:Gem::Version
27
- version: '0.5'
27
+ version: 0.6.9
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: msgpack
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -366,6 +366,8 @@ files:
366
366
  - .pull_requests/1384801823
367
367
  - .pull_requests/1385070261
368
368
  - .pull_requests/1385518404
369
+ - .pull_requests/1385766008
370
+ - .pull_requests/1385778329
369
371
  - .rspec
370
372
  - .ruby-gemset
371
373
  - .ruby-version