softcover 0.8.9 → 0.9.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/lib/softcover/book_manifest.rb +17 -5
- data/lib/softcover/builder.rb +29 -1
- data/lib/softcover/builders/epub.rb +5 -11
- data/lib/softcover/builders/html.rb +5 -3
- data/lib/softcover/builders/mobi.rb +6 -13
- data/lib/softcover/builders/pdf.rb +23 -4
- data/lib/softcover/builders/preview.rb +1 -3
- data/lib/softcover/cli.rb +24 -3
- data/lib/softcover/commands/build.rb +29 -6
- data/lib/softcover/commands/check.rb +103 -0
- data/lib/softcover/commands/deployment.rb +0 -7
- data/lib/softcover/commands/epub_validator.rb +2 -8
- data/lib/softcover/sanitizer.rb +5 -1
- data/lib/softcover/template/.softcover-build +6 -0
- data/lib/softcover/template/chapters/a_chapter.md +10 -11
- data/lib/softcover/template/chapters/a_chapter.tex +13 -21
- data/lib/softcover/template/chapters/another_chapter.md +3 -1
- data/lib/softcover/template/config/lang.yml +14 -0
- data/lib/softcover/template/config/preamble.tex +8 -0
- data/lib/softcover/template/epub/OEBPS/styles/custom_epub.css +7 -0
- data/lib/softcover/template/images/cover-web.png +0 -0
- data/lib/softcover/template/images/cover.pdf +0 -0
- data/lib/softcover/template/images/cover.png +0 -0
- data/lib/softcover/template/latex_styles/custom_pdf.sty +6 -4
- data/lib/softcover/template/latex_styles/language_customization.sty +11 -0
- data/lib/softcover/template/latex_styles/softcover.sty +10 -7
- data/lib/softcover/utils.rb +65 -6
- data/lib/softcover/version.rb +1 -1
- data/lib/softcover.rb +1 -0
- data/softcover.gemspec +10 -10
- data/spec/builders/mobi_spec.rb +5 -3
- data/spec/builders/pdf_spec.rb +19 -0
- data/spec/cli_spec.rb +27 -0
- data/spec/commands/build_spec.rb +9 -0
- data/spec/commands/check_spec.rb +57 -0
- metadata +49 -41
@@ -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}}
|
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.
|
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
|
|
@@ -22,7 +22,7 @@ def hello
|
|
22
22
|
puts "hello, world!"
|
23
23
|
end
|
24
24
|
\end{code}
|
25
|
-
\noindent Softcover can highlight any language supported by \href{http://pygments.org/languages/}{Pygments} (which
|
25
|
+
\noindent Softcover can highlight any language supported by \href{http://pygments.org/languages/}{Pygments} (which is most of them).
|
26
26
|
|
27
27
|
You can also define \emph{code listings}, as seen in Listing~\ref{code:hello_world}. Such code listings are automatically numbered and linked.
|
28
28
|
|
@@ -39,7 +39,7 @@ end
|
|
39
39
|
|
40
40
|
You can indicate inline code with the \verb+\kode+ command, as in \kode{current\_\-user}. If you prefer a plainer version of the same thing, you can use ``typewriter text'', as in \texttt{current\_\-user}.
|
41
41
|
|
42
|
-
For words whose hypenation isn't built in, you can indicate an optional hyphen using \verb+\-+ (Listing~\ref{code:hyphenation}), which will only be used if necessary to make a clean line break (and even then only when producing PDFs). You can also define global hyphenation rules in \texttt{custom.sty}, which includes a rule for hyphenating ``JavaScript'' (Listing~\ref{code:custom}).
|
42
|
+
For words whose hypenation isn't built in, you can indicate an optional hyphen using \verb+\-+ (Listing~\ref{code:hyphenation}), which will only be used if necessary to make a clean line break (and even then only when producing PDFs). You can also define global hyphenation rules in \texttt{custom\_pdf.sty}, which includes a rule for hyphenating ``JavaScript'' (Listing~\ref{code:custom}).
|
43
43
|
|
44
44
|
\begin{codelisting}
|
45
45
|
\label{code:hyphenation}
|
@@ -52,8 +52,8 @@ current\_\-user
|
|
52
52
|
|
53
53
|
\begin{codelisting}
|
54
54
|
\label{code:custom}
|
55
|
-
\codecaption{Defining custom commands. \\ \filepath{latex\_styles/custom.sty}}
|
56
|
-
%= <<(latex_styles/
|
55
|
+
\codecaption{Defining custom commands. \\ \filepath{latex\_styles/custom\_pdf.sty}}
|
56
|
+
%= <<(latex_styles/custom_pdf.sty, lang: tex)
|
57
57
|
\end{codelisting}
|
58
58
|
|
59
59
|
Listing~\ref{code:hyphenation} also shows how to escape the underscore character using a backslash. This is necessary because plain underscores are reserved for math environments (Section~\ref{sec:mathematics}).
|
@@ -140,11 +140,11 @@ Softcover supports raw tables via the \kode{tabular} environment. To make a tabu
|
|
140
140
|
|
141
141
|
\section{Command-line interface}
|
142
142
|
|
143
|
-
Softcover comes with a command-line interface called \kode{poly}. To get more information, just run \kode{
|
143
|
+
Softcover comes with a command-line interface called \kode{poly}. To get more information, just run \kode{softcover help}:
|
144
144
|
|
145
145
|
%= lang:console
|
146
146
|
\begin{code}
|
147
|
-
$
|
147
|
+
$ softcover help
|
148
148
|
Commands:
|
149
149
|
softcover build, build:all # Build all formats
|
150
150
|
softcover build:epub # Build EPUB
|
@@ -152,26 +152,18 @@ Commands:
|
|
152
152
|
softcover build:mobi # Build MOBI
|
153
153
|
softcover build:pdf # Build PDF
|
154
154
|
softcover build:preview # Build book preview in all formats
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
softcover help [COMMAND] # Describe available commands...
|
159
|
-
softcover login # Log into Softcover account
|
160
|
-
softcover logout # Log out of Softcover account
|
161
|
-
softcover new <name> # Generate new book directory structure.
|
162
|
-
softcover open # Open book on Softcover website (OS X)
|
163
|
-
softcover publish # Publish your book on Softcover
|
164
|
-
softcover publish:screencasts # Publish screencasts
|
165
|
-
softcover server # Run local server
|
155
|
+
.
|
156
|
+
.
|
157
|
+
.
|
166
158
|
\end{code}
|
167
159
|
|
168
160
|
\noindent You can run \kode{softcover help <command>} to get additional help on a given command:
|
169
161
|
|
170
162
|
%= lang:console
|
171
163
|
\begin{code}
|
172
|
-
$
|
164
|
+
$ softcover help build
|
173
165
|
Usage:
|
174
|
-
|
166
|
+
softcover build, build:all
|
175
167
|
|
176
168
|
Options:
|
177
169
|
-q, [--quiet] # Quiet output
|
@@ -187,4 +179,4 @@ This is the end of the template---apart from two mostly empty chapters (Chapter~
|
|
187
179
|
|
188
180
|
%= <<(chapters/yet_another_chapter.tex)
|
189
181
|
|
190
|
-
See \href{http://manual.softcover.org/book}{\emph{The Softcover Book}} to learn more about what Softcover can do.
|
182
|
+
See \href{http://manual.softcover.org/book}{\emph{The Softcover Book}} to learn more about what Softcover can do.
|
@@ -1,9 +1,11 @@
|
|
1
1
|
# Another chapter
|
2
2
|
|
3
|
-
This is another chapter.[^numbering] It also
|
3
|
+
This is another chapter.[^numbering] It also includes a little code fencing, mainly to test an edge case for the sake of the Softcover test suite:[^why_code_fencing]
|
4
4
|
|
5
5
|
```console
|
6
6
|
$ find . \( -name \*.gemspec -or -name \*.jpg \) -type f
|
7
7
|
```
|
8
8
|
|
9
9
|
[^numbering]: Footnotes are numbered on a per-chapter basis.
|
10
|
+
|
11
|
+
[^why_code_fencing]: The test suite uses the template files to stress-test the build system. In this case, there used to be a bug when math syntax appeared in a non-math context. Including the code fencing as above ensures that any regressions will cause the test suite to fail.
|
@@ -0,0 +1,14 @@
|
|
1
|
+
---
|
2
|
+
chapter:
|
3
|
+
word: Chapter
|
4
|
+
order: standard # Use 'reverse' to change 'Chapter 1' to '1 Chapter'
|
5
|
+
section: Section
|
6
|
+
table: Table
|
7
|
+
figure: Figure
|
8
|
+
fig: Fig
|
9
|
+
aside: Box
|
10
|
+
listing: Listing
|
11
|
+
equation: Equation
|
12
|
+
eq: Eq
|
13
|
+
frontmatter: Frontmatter
|
14
|
+
contents: Contents
|
@@ -0,0 +1,8 @@
|
|
1
|
+
\documentclass[14pt]{extbook} % Edit this line to change the documentclass.
|
2
|
+
% Add custom preamble content below.
|
3
|
+
% Example commands for using the Polyglossia package with French are
|
4
|
+
% included for reference.
|
5
|
+
% You may also have to edit config/lang.yml to sync up the HTML/EPUB/MOBI.
|
6
|
+
% \usepackage{polyglossia}
|
7
|
+
% \setdefaultlanguage{french}
|
8
|
+
% \DeclareTextCommandDefault{\nobreakspace}{\leavevmode\nobreak\ }
|
Binary file
|
Binary file
|
Binary file
|
@@ -1,7 +1,9 @@
|
|
1
|
-
% You
|
1
|
+
% You should use this file to define commands that *only* pertain to the PDF.
|
2
|
+
% Otherwise, use `custom.sty`.
|
2
3
|
% For example, you can define the proper hypenation of any words that LaTeX
|
3
4
|
% can't hyphenate natively.
|
4
|
-
\hyphenation{Ja-va-Script}
|
5
|
+
% \hyphenation{Ja-va-Script}
|
5
6
|
% You can also include and use packages.
|
6
|
-
\usepackage{newunicodechar}
|
7
|
-
\newunicodechar{★}{\ensuremath{\star}}
|
7
|
+
% \usepackage{newunicodechar}
|
8
|
+
% \newunicodechar{★}{\ensuremath{\star}}
|
9
|
+
% \newunicodechar{ž}{\v{z}}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
% This file is automatically overwritten; do not edit.
|
2
|
+
|
3
|
+
% Aside box label
|
4
|
+
\renewcommand{\boxlabel}{Box}
|
5
|
+
|
6
|
+
% Codelisting captions
|
7
|
+
\usepackage[hypcap=false]{caption}
|
8
|
+
\DeclareCaptionFormat{listing}{\hspace{-0.2em}\colorbox[gray]{.85}{\hspace{0.1em}\parbox{0.997\textwidth}{#1#2#3}}\vspace{-1.3\baselineskip}}
|
9
|
+
\captionsetup[listing]{format=listing,labelfont=bf,skip=16pt,font={rm,normalsize}}
|
10
|
+
\DeclareCaptionType{listing}
|
11
|
+
\newcommand{\codecaption}[1]{\captionof{listing}{#1}}
|
@@ -114,17 +114,13 @@
|
|
114
114
|
\numberwithin{codelisting}{chapter}
|
115
115
|
\newenvironment{codelisting}{\refstepcounter{codelisting}\begin{framed_shaded}\vspace{-0.5em}}%
|
116
116
|
{\end{framed_shaded}}
|
117
|
-
%
|
118
|
-
\usepackage[hypcap=false]{caption}
|
119
|
-
\DeclareCaptionFormat{listing}{\hspace{-0.2em}\colorbox[gray]{.85}{\hspace{0.1em}\parbox{0.997\textwidth}{#1#2#3}}\vspace{-1.3\baselineskip}}
|
120
|
-
\captionsetup[listing]{format=listing,labelfont=bf,skip=16pt,font={rm,normalsize}}
|
121
|
-
\DeclareCaptionType{listing}
|
122
|
-
\newcommand{\codecaption}[1]{\captionof{listing}{#1}}
|
117
|
+
% See latex_styles/language_customization.sty for codelisting captions.
|
123
118
|
|
124
119
|
% Aside boxes
|
125
120
|
\usepackage{amsthm}
|
126
121
|
\theoremstyle{definition}
|
127
|
-
\
|
122
|
+
\newcommand{\boxlabel}{Box}
|
123
|
+
\newtheorem{aside}{\boxlabel}[chapter]
|
128
124
|
\usepackage{latex_styles/framed}
|
129
125
|
\definecolor{shadecolor}{gray}{0.97}
|
130
126
|
\definecolor{boxcolor}{gray}{0.10}
|
@@ -144,6 +140,13 @@
|
|
144
140
|
\vskip0.5em}%
|
145
141
|
}
|
146
142
|
|
143
|
+
% Define some commonly used Unicode characters.
|
144
|
+
\usepackage{newunicodechar}
|
145
|
+
\newunicodechar{—}{---}
|
146
|
+
\newunicodechar{–}{--}
|
147
|
+
|
148
|
+
\usepackage{latex_styles/language_customization}
|
149
|
+
|
147
150
|
% Add custom commands.
|
148
151
|
\usepackage{latex_styles/custom}
|
149
152
|
\usepackage{latex_styles/custom_pdf}
|
data/lib/softcover/utils.rb
CHANGED
@@ -103,13 +103,14 @@ module Softcover::Utils
|
|
103
103
|
end
|
104
104
|
end
|
105
105
|
tex_file << '\end{document}'
|
106
|
-
tex_file.join("\n")
|
106
|
+
tex_file.join("\n") + "\n"
|
107
107
|
end
|
108
108
|
|
109
109
|
def master_latex_header(manifest)
|
110
|
+
preamble = File.read(path('config/preamble.tex'))
|
110
111
|
subtitle = manifest.subtitle.nil? ? "" : "\\subtitle{#{manifest.subtitle}}"
|
111
112
|
<<-EOS
|
112
|
-
|
113
|
+
#{preamble}
|
113
114
|
\\usepackage{#{Softcover::Directories::STYLES}/softcover}
|
114
115
|
\\VerbatimFootnotes % Allows verbatim text in footnotes
|
115
116
|
\\title{#{manifest.title}}
|
@@ -165,11 +166,11 @@ module Softcover::Utils
|
|
165
166
|
end
|
166
167
|
|
167
168
|
# Returns the executable if it exists, raising an error otherwise.
|
168
|
-
def executable(filename
|
169
|
+
def executable(filename)
|
169
170
|
filename.tap do |f|
|
170
171
|
unless File.exist?(f)
|
171
172
|
$stderr.puts "Document not built due to missing dependency"
|
172
|
-
$stderr.puts
|
173
|
+
$stderr.puts "Run `softcover check` to check dependencies"
|
173
174
|
exit 1
|
174
175
|
end
|
175
176
|
end
|
@@ -179,8 +180,13 @@ module Softcover::Utils
|
|
179
180
|
Dir.mkdir(dir) unless File.directory?(dir)
|
180
181
|
end
|
181
182
|
|
183
|
+
# Removes a file (or list of files).
|
182
184
|
def rm(file)
|
183
|
-
|
185
|
+
if file.is_a?(Array)
|
186
|
+
file.each { |f| rm(f) }
|
187
|
+
else
|
188
|
+
FileUtils.rm(file) if File.exist?(file)
|
189
|
+
end
|
184
190
|
end
|
185
191
|
|
186
192
|
# Returns the system-independent file path.
|
@@ -214,5 +220,58 @@ module Softcover::Utils
|
|
214
220
|
def linux?
|
215
221
|
RUBY_PLATFORM.match(/linux/)
|
216
222
|
end
|
217
|
-
end
|
218
223
|
|
224
|
+
# Returns the commands from the given lines.
|
225
|
+
# We skip comments and blank lines.
|
226
|
+
def commands(lines)
|
227
|
+
skip = /(^\s*#|^\s*$)/
|
228
|
+
lines.reject { |line| line =~ skip }.join("\n")
|
229
|
+
end
|
230
|
+
|
231
|
+
# Returns the filename of a dependency given a label.
|
232
|
+
def dependency_filename(label)
|
233
|
+
case label
|
234
|
+
when :latex
|
235
|
+
`which xelatex`.chomp
|
236
|
+
when :convert
|
237
|
+
`which convert`.chomp
|
238
|
+
when :node
|
239
|
+
`which node`.chomp
|
240
|
+
when :phantomjs
|
241
|
+
`which phantomjs`.chomp
|
242
|
+
when :kindlegen
|
243
|
+
`which kindlegen`.chomp
|
244
|
+
when :java
|
245
|
+
`which java`.chomp
|
246
|
+
when :calibre
|
247
|
+
`which ebook-convert`.chomp
|
248
|
+
when :ghostscript
|
249
|
+
`which gs`.chomp
|
250
|
+
when :epubcheck
|
251
|
+
File.join(Dir.home, 'epubcheck-3.0', 'epubcheck-3.0.jar')
|
252
|
+
when :inkscape
|
253
|
+
filename = `which inkscape`.chomp
|
254
|
+
if filename.empty?
|
255
|
+
filename = '/Applications/Inkscape.app/Contents/Resources/bin/' +
|
256
|
+
'inkscape'
|
257
|
+
end
|
258
|
+
filename
|
259
|
+
else
|
260
|
+
raise "Unknown label #{label}"
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
264
|
+
# Returns the language labels from the config file.
|
265
|
+
def language_labels
|
266
|
+
YAML.load_file(File.join(Softcover::Directories::CONFIG, 'lang.yml'))
|
267
|
+
end
|
268
|
+
|
269
|
+
def chapter_label(chapter_number)
|
270
|
+
if language_labels["chapter"]["order"] == "reverse"
|
271
|
+
"#{chapter_number} #{language_labels['chapter']['word']}"
|
272
|
+
else
|
273
|
+
"#{language_labels['chapter']['word']} #{chapter_number}"
|
274
|
+
end
|
275
|
+
end
|
276
|
+
|
277
|
+
end
|
data/lib/softcover/version.rb
CHANGED
data/lib/softcover.rb
CHANGED
@@ -30,6 +30,7 @@ require_relative 'softcover/builders/preview'
|
|
30
30
|
require_relative 'softcover/cli'
|
31
31
|
require_relative 'softcover/commands/auth'
|
32
32
|
require_relative 'softcover/commands/build'
|
33
|
+
require_relative 'softcover/commands/check'
|
33
34
|
require_relative 'softcover/commands/deployment'
|
34
35
|
require_relative 'softcover/commands/epub_validator'
|
35
36
|
require_relative 'softcover/commands/generator'
|
data/softcover.gemspec
CHANGED
@@ -18,23 +18,23 @@ 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.
|
21
|
+
gem.add_dependency 'polytexnic', '~> 0.9.1'
|
22
22
|
gem.add_dependency 'msgpack', '~> 0.4.2'
|
23
23
|
gem.add_dependency 'nokogiri', '~> 1.6.0'
|
24
|
-
gem.add_dependency 'thor'
|
25
|
-
gem.add_dependency 'activesupport'
|
26
|
-
gem.add_dependency 'rest-client'
|
27
|
-
gem.add_dependency 'curb'
|
28
|
-
gem.add_dependency 'ruby-progressbar'
|
29
|
-
gem.add_dependency 'maruku'
|
30
|
-
gem.add_dependency 'pygments.rb'
|
31
|
-
gem.add_dependency 'kramdown'
|
24
|
+
gem.add_dependency 'thor', '~> 0.18.1'
|
25
|
+
gem.add_dependency 'activesupport', '~> 4.0.3'
|
26
|
+
gem.add_dependency 'rest-client', '~> 1.6.7'
|
27
|
+
gem.add_dependency 'curb', '~> 0.8.5'
|
28
|
+
gem.add_dependency 'ruby-progressbar', '~> 1.4.1'
|
29
|
+
gem.add_dependency 'maruku', '~> 0.7.1'
|
30
|
+
gem.add_dependency 'pygments.rb', '~> 0.4.2'
|
31
|
+
gem.add_dependency 'kramdown', '~> 1.3.2'
|
32
32
|
|
33
33
|
gem.add_dependency 'sinatra', '~> 1.4.4'
|
34
34
|
gem.add_dependency 'thin', '~> 1.6.1'
|
35
35
|
gem.add_dependency 'async_sinatra', '~> 1.1.0'
|
36
36
|
gem.add_dependency 'sinatra-respond_to', '~> 0.9.0'
|
37
|
-
gem.add_dependency 'coffee-script'
|
37
|
+
gem.add_dependency 'coffee-script', '~> 2.2.0'
|
38
38
|
gem.add_dependency 'listen', '~> 1.3.1'
|
39
39
|
gem.add_dependency 'rb-fsevent', '~> 0.9.3'
|
40
40
|
gem.add_dependency 'sanitize', '~> 2.0.6'
|
data/spec/builders/mobi_spec.rb
CHANGED
@@ -16,7 +16,9 @@ describe Softcover::Builders::Mobi do
|
|
16
16
|
|
17
17
|
describe "MOBI command" do
|
18
18
|
context "default" do
|
19
|
-
let(:command)
|
19
|
+
let(:command) do
|
20
|
+
@builder.mobi_command(@builder.mobi_filename, calibre: true)
|
21
|
+
end
|
20
22
|
it "should use Calibre's ebook-convert" do
|
21
23
|
expect(command).to include 'ebook-convert'
|
22
24
|
end
|
@@ -24,7 +26,7 @@ describe Softcover::Builders::Mobi do
|
|
24
26
|
|
25
27
|
context "kindlegen" do
|
26
28
|
let(:command) do
|
27
|
-
@builder.mobi_command(@builder.mobi_filename
|
29
|
+
@builder.mobi_command(@builder.mobi_filename)
|
28
30
|
end
|
29
31
|
it "should use Amazon.com's kindlegen" do
|
30
32
|
expect(command).to include 'kindlegen'
|
@@ -35,7 +37,7 @@ describe Softcover::Builders::Mobi do
|
|
35
37
|
let(:filename) do
|
36
38
|
@builder.mobi_filename(preview: true)
|
37
39
|
end
|
38
|
-
it "should
|
40
|
+
it "should create a preview file" do
|
39
41
|
expect(filename).to include 'book-preview'
|
40
42
|
end
|
41
43
|
end
|
data/spec/builders/pdf_spec.rb
CHANGED
@@ -24,6 +24,19 @@ describe Softcover::Builders::Pdf do
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
+
context "preamble" do
|
28
|
+
subject(:preamble_file) { File.join('config', 'preamble.tex') }
|
29
|
+
it { should exist }
|
30
|
+
context "content" do
|
31
|
+
subject { Softcover::Utils::master_latex_header(builder.manifest) }
|
32
|
+
it { should include File.read(preamble_file) }
|
33
|
+
it { should include '\usepackage{latex_styles/softcover}' }
|
34
|
+
it { should include "\\title{#{builder.manifest.title}}" }
|
35
|
+
it { should include "\\author{#{builder.manifest.author}}" }
|
36
|
+
it { should include "\\date{#{builder.manifest.date}}" }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
27
40
|
it "should prepend the fontsize verbatim declaration for source code" do
|
28
41
|
fontsize = '\begin{Verbatim}[fontsize=\relsize'
|
29
42
|
expect(File.read(Dir.glob('tmp/*.tmp.tex').first)).to include fontsize
|
@@ -52,6 +65,12 @@ describe Softcover::Builders::Pdf do
|
|
52
65
|
expect(File.read(styles)).to match /newcommand/
|
53
66
|
end
|
54
67
|
|
68
|
+
context "language customization file" do
|
69
|
+
subject { File.join(Softcover::Directories::STYLES,
|
70
|
+
'language_customization.sty') }
|
71
|
+
it { should exist }
|
72
|
+
end
|
73
|
+
|
55
74
|
context "after removing Book.txt" do
|
56
75
|
before { FileUtils.rm Softcover::BookManifest::TXT_PATH }
|
57
76
|
it "should still build the book" do
|
data/spec/cli_spec.rb
CHANGED
@@ -47,6 +47,28 @@ describe Softcover::CLI do
|
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
|
+
context "softcover clean" do
|
51
|
+
before do
|
52
|
+
chdir_to_fixtures
|
53
|
+
|
54
|
+
FileUtils.touch('foo.aux')
|
55
|
+
FileUtils.touch('foo.toc')
|
56
|
+
FileUtils.touch('foo.out')
|
57
|
+
FileUtils.touch('foo.tmp.pdf')
|
58
|
+
FileUtils.touch('.highlight_cache')
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should remove unnecessary files" do
|
62
|
+
`softcover clean`
|
63
|
+
expect('foo.aux').not_to exist
|
64
|
+
expect('foo.aux').not_to exist
|
65
|
+
expect('foo.toc').not_to exist
|
66
|
+
expect('foo.out').not_to exist
|
67
|
+
expect('foo.tmp.pdf').not_to exist
|
68
|
+
expect('.highlight_cache').not_to exist
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
50
72
|
shared_examples "book" do
|
51
73
|
context "pdf" do
|
52
74
|
|
@@ -147,4 +169,9 @@ describe Softcover::CLI do
|
|
147
169
|
end
|
148
170
|
end
|
149
171
|
end
|
172
|
+
|
173
|
+
describe "check" do
|
174
|
+
subject { `softcover check` }
|
175
|
+
it { should match /all dependencies satisfied/i }
|
176
|
+
end
|
150
177
|
end
|
data/spec/commands/build_spec.rb
CHANGED
@@ -47,4 +47,13 @@ describe Softcover::Commands::Build do
|
|
47
47
|
build.preview
|
48
48
|
end
|
49
49
|
end
|
50
|
+
|
51
|
+
describe "commands helper" do
|
52
|
+
let(:lines) { ['foo', ' # bar', 'baz'] }
|
53
|
+
subject { Softcover::Commands::Build.commands(lines) }
|
54
|
+
|
55
|
+
it { should match /foo/ }
|
56
|
+
it { should_not match /bar/ }
|
57
|
+
it { should match /baz/ }
|
58
|
+
end
|
50
59
|
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'stringio'
|
3
|
+
|
4
|
+
module Kernel
|
5
|
+
|
6
|
+
def capture_stdout
|
7
|
+
out = StringIO.new
|
8
|
+
$stdout = out
|
9
|
+
yield
|
10
|
+
return out.string
|
11
|
+
ensure
|
12
|
+
$stdout = STDOUT
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
describe Softcover::Commands::Check do
|
18
|
+
|
19
|
+
subject(:check) do
|
20
|
+
capture_stdout do
|
21
|
+
Softcover::Commands::Check.check_dependencies!
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
it { should match /all dependencies satisfied/i }
|
26
|
+
|
27
|
+
describe "missing dependencies" do
|
28
|
+
before do
|
29
|
+
Softcover::Commands::Check.dependency_labels.each do |label|
|
30
|
+
Softcover::Commands::Check.stub(:present?).with(label).and_return(false)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
it { should match /Checking for LaTeX.*Missing/ }
|
35
|
+
it { should match /Checking for PhantomJS.*Missing/ }
|
36
|
+
it { should match /Checking for Inkscape.*Missing/ }
|
37
|
+
it { should match /Checking for Calibre.*Missing/ }
|
38
|
+
it { should match /Checking for KindleGen.*Missing/ }
|
39
|
+
it { should match /Checking for Java.*Missing/ }
|
40
|
+
it { should match /Checking for EpubCheck.*Missing/ }
|
41
|
+
it { should match /Checking for GhostScript.*Missing/ }
|
42
|
+
it { should match /Checking for ImageMagick.*Missing/ }
|
43
|
+
it { should match /Checking for Node\.js.*Missing/ }
|
44
|
+
|
45
|
+
it { should match /Missing dependencies:/ }
|
46
|
+
it { should match /LaTeX/ }
|
47
|
+
it { should match /PhantomJS/ }
|
48
|
+
it { should match /Inkscape/ }
|
49
|
+
it { should match /Calibre/ }
|
50
|
+
it { should match /KindleGen/ }
|
51
|
+
it { should match /Java/ }
|
52
|
+
it { should match /EpubCheck/ }
|
53
|
+
it { should match /GhostScript/ }
|
54
|
+
it { should match /ImageMagick/ }
|
55
|
+
it { should match /Node\.js/ }
|
56
|
+
end
|
57
|
+
end
|