softcover 0.9.23 → 1.0.beta1

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
  SHA1:
3
- metadata.gz: e52c2d46c2c93d04f42a525c55f006ac451feb66
4
- data.tar.gz: 642848689b0b9419132cb12d3d41077e38a0d821
3
+ metadata.gz: 07316c46b4a5618e9456de93af46e5bbb111ba9c
4
+ data.tar.gz: 915b545aaa9fdaf36207fb95d8a7671d8627939c
5
5
  SHA512:
6
- metadata.gz: a7c27be993df17653ec60d2ef765f50472f4e324d74a1e7ef2f024367166210831ec2ab78aa4ac3b4c6c004398128dc1977c87e1e1280ee2459a3eba4e1e2d22
7
- data.tar.gz: b0ac15249fb787f9fe1a748da17e0a4773a0d44eb42abf0d18b121fdeff2401d3909646c89b76aa8a06cfe143ce3bf3efe6fcdd6fb11a3ab91166a003b911724
6
+ metadata.gz: f02e3ee81191ad6d8731df6c1bcd6a94c134a7e0595a1039671e0f94bb2158dd581fa606127324e08db7a9c9e9fbfb2ad6cf64d4e2c3f172b580b23b97b780d8
7
+ data.tar.gz: d0770ea2d5d9c20f45ca27fef220431ea7f489b59976d1a4b1ef23557ae2a327856902aba861b7fcfe3e643920e51766f200c43ea757ef5f8c6fadda3689405f
File without changes
data/Gemfile CHANGED
@@ -13,7 +13,7 @@ LC_ALL="en_US.UTF-8"
13
13
  gemspec
14
14
 
15
15
  group :test do
16
- gem 'rspec'
16
+ gem 'rspec', '2.14.1'
17
17
  gem 'webmock', require: false
18
18
  gem 'coveralls', require: false
19
19
  gem 'rack-test'
@@ -1,7 +1,35 @@
1
1
  module Softcover
2
+
3
+ module EpubUtils
4
+
5
+ # Returns the name of the cover file.
6
+ # We support (in order) JPG/JPEG, PNG, and TIFF.
7
+ def cover_img
8
+ extensions = %w[jpg jpeg png tiff]
9
+ extensions.each do |ext|
10
+ file = Dir[path("#{images_dir}/cover.#{ext}")].first
11
+ return File.basename(file) if file
12
+ end
13
+ return false
14
+ end
15
+
16
+ def cover?
17
+ cover_img
18
+ end
19
+
20
+ def cover_img_path
21
+ path("#{images_dir}/#{cover_img}")
22
+ end
23
+
24
+ def images_dir
25
+ path('epub/OEBPS/images')
26
+ end
27
+ end
28
+
2
29
  module Builders
3
30
  class Epub < Builder
4
31
  include Softcover::Output
32
+ include Softcover::EpubUtils
5
33
 
6
34
  def build!(options={})
7
35
  @preview = options[:preview]
@@ -121,10 +149,6 @@ module Softcover
121
149
  end
122
150
  end
123
151
 
124
- def images_dir
125
- File.join('epub', 'OEBPS', 'images')
126
- end
127
-
128
152
  # Returns HTML for HTML source that includes math.
129
153
  # As a side-effect, html_with_math creates PNGs corresponding to any
130
154
  # math in the given source. The technique involves using PhantomJS to
@@ -398,25 +422,10 @@ module Softcover
398
422
  )
399
423
  end
400
424
 
401
- # Returns the name of the cover file.
402
- # We support (in order) JPG/JPEG, PNG, and TIFF.
403
- def cover_img
404
- extensions = %w[jpg jpeg png tiff]
405
- extensions.each do |ext|
406
- file = Dir[path("#{images_dir}/cover.#{ext}")].first
407
- return File.basename(file) if file
408
- end
409
- return false
410
- end
411
-
412
425
  def cover_id
413
426
  "img-#{cover_img.sub('.', '-')}"
414
427
  end
415
428
 
416
- def cover?
417
- cover_img
418
- end
419
-
420
429
  # Returns the Table of Contents for the spine.
421
430
  def toc_ncx
422
431
  title = manifest.title
@@ -88,7 +88,8 @@ module Softcover
88
88
  # interim.
89
89
  unless (File.exist?(chapter.cache_filename) &&
90
90
  File.read(chapter.cache_filename) == digest(markdown) &&
91
- File.exist?(polytex_filename))
91
+ File.exist?(polytex_filename) &&
92
+ !markdown.include?('\input'))
92
93
  File.write(polytex_filename, polytex(chapter, markdown))
93
94
  end
94
95
  end
@@ -1,6 +1,8 @@
1
1
  module Softcover
2
2
  module Builders
3
3
  class Mobi < Builder
4
+ include Softcover::Utils
5
+ include Softcover::EpubUtils
4
6
 
5
7
  def build!(options={})
6
8
  Softcover::Builders::Epub.new.build!(options)
@@ -12,10 +14,6 @@ module Softcover
12
14
  else
13
15
  system(command)
14
16
  end
15
- if options[:calibre]
16
- FileUtils.mv("ebooks/#{filename}.azw3", "ebooks/#{filename}.mobi")
17
- puts "MOBI saved to ebooks/#{filename}.mobi" unless silent
18
- end
19
17
  end
20
18
 
21
19
  # Returns the filename of the MOBI (preview if necessary).
@@ -25,10 +23,11 @@ module Softcover
25
23
 
26
24
  # Returns the command for making a MOBI, based on the options.
27
25
  def mobi_command(filename, options={})
28
- if options[:calibre]
29
- "#{calibre} ebooks/#{filename}.epub ebooks/#{filename}.azw3"
30
- else
26
+ if options[:kindlegen]
31
27
  "#{kindlegen} ebooks/#{filename}.epub"
28
+ else
29
+ "#{calibre} ebooks/#{filename}.epub ebooks/#{filename}.mobi" +
30
+ " #{calibre_options}"
32
31
  end
33
32
  end
34
33
 
@@ -38,6 +37,20 @@ module Softcover
38
37
  @calibre ||= executable(dependency_filename(:calibre))
39
38
  end
40
39
 
40
+ # Returns the options for the Calibre `ebook-convert` CLI.
41
+ def calibre_options
42
+ # Include both Mobipocket & KF8 formats.
43
+ # It took me forever to figure this out. It really should be
44
+ # the Calibre default.
45
+ opts = "--mobi-file-type both"
46
+ if cover?
47
+ opts += " --cover #{cover_img_path}"
48
+ # Get covers to work in Kindle desktop app.
49
+ opts += " --share-not-sync"
50
+ end
51
+ opts
52
+ end
53
+
41
54
  def kindlegen
42
55
  @kindlegen ||= executable(dependency_filename(:kindlegen))
43
56
  end
data/lib/softcover/cli.rb CHANGED
@@ -42,9 +42,9 @@ module Softcover
42
42
  desc: "Find overfull hboxes",
43
43
  type: :boolean
44
44
  elsif format == 'mobi'
45
- method_option :calibre, aliases: '-c',
46
- desc: "Use Calibre to build the MOBI",
47
- type: :boolean
45
+ method_option :kindlegen, aliases: '-k',
46
+ desc: "Use KindleGen to build the MOBI",
47
+ type: :boolean
48
48
  end
49
49
  method_option :quiet, aliases: '-q',
50
50
  desc: "Quiet output", type: :boolean
@@ -1,9 +1,9 @@
1
1
  # A chapter
2
2
  \label{cha:a_chapter}
3
3
 
4
- This is the first paragraph of the Softcover Markdown template produced with the \softcover\ command-line interface. It shows how to write a document in Markdown, a lightweight markup language, augmented with the [kramdown](http://kramdown.rubyforge.org/) converter and some custom extensions, including support for embedded \PolyTeX, a subset of the powerful \LaTeX\ typesetting system. For more information, see [*The Softcover Book*](http://manual.softcover.io/book). To learn how to easily publish (and optionally sell) documents produced with Softcover, visit [Softcover.io](http://softcover.io/). Softcover is currently in private beta; go to [Softcover.io](http://softcover.io/) to get an invitation.
4
+ This is the first paragraph of the Softcover Markdown template produced with the \softcover\ command-line interface. It shows how to write a document in Markdown, a lightweight markup language, augmented with the [kramdown](http://kramdown.rubyforge.org/) converter and some custom extensions, including support for embedded \PolyTeX, a subset of the powerful \LaTeX\ typesetting system. For more information, see [*The Softcover Book*](http://manual.softcover.io/book). To learn how to easily publish (and optionally sell) documents produced with Softcover, visit [Softcover.io](http://softcover.io/).
5
5
 
6
- This is the *second* paragraph, showing how to emphasize text.[^sample-footnote] You can also make text **bold** or _emphasize a second way_.
6
+ This is the *second* paragraph, showing how to emphasize text.[^sample-footnote] You can also make text **bold** or _emphasize a second way_. Via embedded \PolyTeX, Softcover also supports colored text, such as \coloredtext{red}{red}, \coloredtext{CornflowerBlue}{cornflower blue}, and \coloredtexthtml{E8AB3A}{arbitrary HTML colors}.
7
7
 
8
8
  ## A section
9
9
  \label{sec:a_section}
@@ -1,7 +1,7 @@
1
1
  \chapter{A chapter}
2
2
  \label{cha:a_chapter}
3
3
 
4
- This is the first paragraph of the Softcover template. It shows how to write a document in \PolyTeX, a subset of the \LaTeX\ typesetting language optimized for ebooks. For more information, see \href{http://manual.softcover.org/book}{\emph{The Softcover Book}}. To learn how to easily publish (and optionally sell) documents produced with Softcover, visit \href{http://softcover.io/}{Softcover.io}. Softcover is currently in private beta; go to \href{http://softcover.io/}{Softcover.io} to get an invitation.
4
+ This is the first paragraph of the Softcover template. It shows how to write a document in \PolyTeX, a subset of the \LaTeX\ typesetting language optimized for ebooks. For more information, see \href{http://manual.softcover.org/book}{\emph{The Softcover Book}}. To learn how to easily publish (and optionally sell) documents produced with Softcover, visit \href{http://softcover.io/}{Softcover.io}.
5
5
 
6
6
  This is the \emph{second} paragraph, showing how to emphasize text.\footnote{This is a footnote. It is numbered automatically.} You can also make text \textbf{bold} or \textit{italicized} (which looks the same as emphasized text).
7
7
 
@@ -11,10 +11,10 @@
11
11
 
12
12
  % Font encodings
13
13
  \usepackage[T1]{fontenc}
14
+ % Be able to define colors
15
+ \usepackage[svgnames]{xcolor}
14
16
  % Be able to include book covers
15
17
  \usepackage{pdfpages}
16
- % Be able to define colors
17
- \usepackage{xcolor}
18
18
  % Include graphics
19
19
  \usepackage{graphicx}
20
20
  \def\maxwidth#1{\ifdim\Gin@nat@width>#1 #1\else\Gin@nat@width\fi}
@@ -129,6 +129,7 @@
129
129
  \newcommand{\kodesize}{\smaller[0.75]}
130
130
  \newcommand{\kode}[1]{\textcolor{darkgreen}{\textbf{\texttt{\kodesize #1}}}}
131
131
  \newcommand{\coloredtext}[2]{\textcolor{#1}{#2}}
132
+ \newcommand{\coloredtexthtml}[2]{\textcolor[HTML]{#1}{#2}}
132
133
 
133
134
  % Subtitle command
134
135
  \usepackage{titling}
@@ -197,7 +197,7 @@ module Softcover::Utils
197
197
  # Returns the system-independent file path.
198
198
  # It's nicer to write `path('foo/bar/baz')` than
199
199
  # `File.join('foo', 'bar', 'baz')`.
200
- def path(path_string)
200
+ def path(path_string='')
201
201
  File.join(*path_string.split('/'))
202
202
  end
203
203
 
@@ -1,3 +1,3 @@
1
1
  module Softcover
2
- VERSION = "0.9.23"
2
+ VERSION = "1.0.beta1"
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.9.10'
21
+ gem.add_dependency 'polytexnic', '~> 1.0.beta1'
22
22
  gem.add_dependency 'msgpack', '~> 0.4.2'
23
23
  gem.add_dependency 'nokogiri', '~> 1.6.0'
24
24
  gem.add_dependency 'thor', '~> 0.18.1'
@@ -17,16 +17,29 @@ describe Softcover::Builders::Mobi do
17
17
  describe "MOBI command" do
18
18
  context "default" do
19
19
  let(:command) do
20
- @builder.mobi_command(@builder.mobi_filename, calibre: true)
20
+ @builder.mobi_command(@builder.mobi_filename)
21
21
  end
22
+
22
23
  it "should use Calibre's ebook-convert" do
23
24
  expect(command).to include 'ebook-convert'
24
25
  end
26
+
27
+ it "should build both kinds of Kindle files" do
28
+ expect(command).to include ' --mobi-file-type both'
29
+ end
30
+
31
+ it "should include the cover" do
32
+ expect(command).to include ' --cover epub/OEBPS/images/cover.jpg'
33
+ end
34
+
35
+ it "should configure the cover to work with Kindle desktop app" do
36
+ expect(command).to include ' --share-not-sync'
37
+ end
25
38
  end
26
39
 
27
40
  context "kindlegen" do
28
41
  let(:command) do
29
- @builder.mobi_command(@builder.mobi_filename)
42
+ @builder.mobi_command(@builder.mobi_filename, kindlegen: true)
30
43
  end
31
44
  it "should use Amazon.com's kindlegen" do
32
45
  expect(command).to include 'kindlegen'
data/spec/cli_spec.rb CHANGED
@@ -120,6 +120,12 @@ describe Softcover::CLI do
120
120
  expect(path('ebooks/book.mobi')).to exist
121
121
  end
122
122
  end
123
+
124
+ context "command-line options" do
125
+ subject(:options) { `softcover help build:mobi` }
126
+ it { should_not include 'calibre' }
127
+ it { should include 'kindlegen' }
128
+ end
123
129
  end
124
130
  end
125
131
 
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.9.23
4
+ version: 1.0.beta1
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: 2014-06-20 00:00:00.000000000 Z
12
+ date: 2014-06-23 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.9.10
20
+ version: 1.0.beta1
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.9.10
27
+ version: 1.0.beta1
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: msgpack
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -384,6 +384,7 @@ files:
384
384
  - .pull_requests/1388713504
385
385
  - .pull_requests/1388804598
386
386
  - .pull_requests/1395697365
387
+ - .pull_requests/1403289532
387
388
  - .rspec
388
389
  - .travis.yml
389
390
  - Gemfile
@@ -1051,9 +1052,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
1051
1052
  version: '0'
1052
1053
  required_rubygems_version: !ruby/object:Gem::Requirement
1053
1054
  requirements:
1054
- - - '>='
1055
+ - - '>'
1055
1056
  - !ruby/object:Gem::Version
1056
- version: '0'
1057
+ version: 1.3.1
1057
1058
  requirements: []
1058
1059
  rubyforge_project:
1059
1060
  rubygems_version: 2.0.14