rpub 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +1 -1
- data/.rspec +0 -1
- data/.travis.yml +3 -4
- data/.yardopts +1 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +70 -46
- data/Guardfile +6 -0
- data/HISTORY.md +10 -0
- data/README.md +1 -1
- data/Rakefile +7 -2
- data/bin/rpub +64 -1
- data/doc/.gitignore +8 -0
- data/doc/api/Rpub.html +339 -0
- data/doc/api/Rpub/Book.html +983 -0
- data/doc/api/Rpub/Chapter.html +737 -0
- data/doc/api/Rpub/Command.html +356 -0
- data/doc/api/Rpub/Commands.html +117 -0
- data/doc/api/Rpub/Commands/Clean.html +216 -0
- data/doc/api/Rpub/Commands/Compile.html +218 -0
- data/doc/api/Rpub/Commands/Generate.html +242 -0
- data/doc/api/Rpub/Commands/Package.html +230 -0
- data/doc/api/Rpub/Commands/Preview.html +216 -0
- data/doc/api/Rpub/Commands/Stats.html +226 -0
- data/doc/api/Rpub/Compressor.html +687 -0
- data/doc/api/Rpub/Context.html +553 -0
- data/doc/api/Rpub/Document.html +647 -0
- data/doc/api/Rpub/Document/OutlineElement.html +388 -0
- data/doc/api/Rpub/Epub.html +465 -0
- data/doc/api/Rpub/Epub/Container.html +224 -0
- data/doc/api/Rpub/Epub/Content.html +344 -0
- data/doc/api/Rpub/Epub/Cover.html +236 -0
- data/doc/api/Rpub/Epub/HtmlToc.html +240 -0
- data/doc/api/Rpub/Epub/Toc.html +244 -0
- data/doc/api/Rpub/FilesystemSource.html +544 -0
- data/doc/api/Rpub/HashDelegation.html +281 -0
- data/doc/api/Rpub/HashDelegation/ClassMethods.html +175 -0
- data/doc/api/Rpub/MediaType.html +192 -0
- data/doc/api/Rpub/Preview.html +464 -0
- data/doc/api/Rpub/XmlFile.html +457 -0
- data/doc/api/_index.html +405 -0
- data/doc/api/class_list.html +54 -0
- data/doc/api/css/common.css +1 -0
- data/doc/api/css/full_list.css +57 -0
- data/doc/api/css/style.css +339 -0
- data/doc/api/file.HISTORY.html +131 -0
- data/doc/api/file.LICENSE.html +92 -0
- data/doc/api/file.README.html +337 -0
- data/doc/api/file_list.html +62 -0
- data/doc/api/frames.html +26 -0
- data/doc/api/index.html +337 -0
- data/doc/api/js/app.js +219 -0
- data/doc/api/js/full_list.js +178 -0
- data/doc/api/js/jquery.js +4 -0
- data/doc/api/method_list.html +533 -0
- data/doc/api/top-level-namespace.html +112 -0
- data/doc/index.html +312 -0
- data/doc/javascripts/scale.fix.js +17 -0
- data/doc/params.json +1 -0
- data/doc/stylesheets/pygment_trac.css +69 -0
- data/doc/stylesheets/styles.css +255 -0
- data/features/clean.feature +31 -0
- data/features/compile.feature +49 -0
- data/features/embedded_assets.feature +51 -0
- data/features/generate.feature +63 -0
- data/features/layout.feature +41 -0
- data/features/package.feature +30 -0
- data/features/previews.feature +66 -0
- data/features/stats.feature +18 -0
- data/features/step_definitions/general_steps.rb +60 -0
- data/features/styles.feature +33 -0
- data/features/support/env.rb +7 -0
- data/features/table_of_contents.feature +35 -0
- data/lib/rpub.rb +28 -31
- data/lib/rpub/book.rb +9 -16
- data/lib/rpub/chapter.rb +4 -54
- data/lib/rpub/command.rb +32 -0
- data/lib/rpub/commands/clean.rb +4 -49
- data/lib/rpub/commands/compile.rb +4 -49
- data/lib/rpub/commands/generate.rb +10 -67
- data/lib/rpub/commands/package.rb +9 -37
- data/lib/rpub/commands/preview.rb +4 -54
- data/lib/rpub/commands/stats.rb +6 -10
- data/lib/rpub/compressor.rb +3 -3
- data/lib/rpub/context.rb +48 -0
- data/lib/rpub/document.rb +68 -0
- data/lib/rpub/epub.rb +8 -7
- data/lib/rpub/epub/content.rb +9 -30
- data/lib/rpub/epub/cover.rb +1 -8
- data/lib/rpub/epub/html_toc.rb +4 -9
- data/lib/rpub/epub/toc.rb +16 -13
- data/lib/rpub/filesystem_source.rb +47 -0
- data/lib/rpub/media_type.rb +16 -0
- data/lib/rpub/preview.rb +29 -0
- data/lib/rpub/version.rb +1 -1
- data/lib/rpub/xml_file.rb +4 -1
- data/rpub.gemspec +6 -7
- data/spec/rpub/book_spec.rb +45 -45
- data/spec/rpub/chapter_spec.rb +87 -22
- data/spec/rpub/epub/container_spec.rb +3 -5
- data/spec/rpub/epub/content_spec.rb +62 -41
- data/spec/rpub/epub/cover_spec.rb +3 -5
- data/spec/rpub/epub/html_toc_spec.rb +8 -8
- data/spec/rpub/epub/toc_spec.rb +20 -22
- data/spec/rpub_spec.rb +1 -3
- data/spec/spec_helper.rb +28 -0
- data/support/config.yml +1 -0
- data/support/styles.css +3 -3
- metadata +131 -120
- data/lib/rpub/commander.rb +0 -23
- data/lib/rpub/commands/base.rb +0 -33
- data/lib/rpub/commands/help.rb +0 -37
- data/lib/rpub/commands/main.rb +0 -45
- data/lib/rpub/compilation_helpers.rb +0 -73
- data/lib/rpub/subclass_tracker.rb +0 -53
- data/spec/rpub/commands/clean_spec.rb +0 -46
- data/spec/rpub/commands/generate_spec.rb +0 -52
- data/spec/rpub/commands/main_spec.rb +0 -26
- data/spec/rpub/commands/package_spec.rb +0 -33
- data/spec/rpub/commands/preview_spec.rb +0 -43
@@ -0,0 +1,255 @@
|
|
1
|
+
@import url(https://fonts.googleapis.com/css?family=Lato:300italic,700italic,300,700);
|
2
|
+
|
3
|
+
body {
|
4
|
+
padding:50px;
|
5
|
+
font:14px/1.5 Lato, "Helvetica Neue", Helvetica, Arial, sans-serif;
|
6
|
+
color:#777;
|
7
|
+
font-weight:300;
|
8
|
+
}
|
9
|
+
|
10
|
+
h1, h2, h3, h4, h5, h6 {
|
11
|
+
color:#222;
|
12
|
+
margin:0 0 20px;
|
13
|
+
}
|
14
|
+
|
15
|
+
p, ul, ol, table, pre, dl {
|
16
|
+
margin:0 0 20px;
|
17
|
+
}
|
18
|
+
|
19
|
+
h1, h2, h3 {
|
20
|
+
line-height:1.1;
|
21
|
+
}
|
22
|
+
|
23
|
+
h1 {
|
24
|
+
font-size:28px;
|
25
|
+
}
|
26
|
+
|
27
|
+
h2 {
|
28
|
+
color:#393939;
|
29
|
+
}
|
30
|
+
|
31
|
+
h3, h4, h5, h6 {
|
32
|
+
color:#494949;
|
33
|
+
}
|
34
|
+
|
35
|
+
a {
|
36
|
+
color:#39c;
|
37
|
+
font-weight:400;
|
38
|
+
text-decoration:none;
|
39
|
+
}
|
40
|
+
|
41
|
+
a small {
|
42
|
+
font-size:11px;
|
43
|
+
color:#777;
|
44
|
+
margin-top:-0.6em;
|
45
|
+
display:block;
|
46
|
+
}
|
47
|
+
|
48
|
+
.wrapper {
|
49
|
+
width:860px;
|
50
|
+
margin:0 auto;
|
51
|
+
}
|
52
|
+
|
53
|
+
blockquote {
|
54
|
+
border-left:1px solid #e5e5e5;
|
55
|
+
margin:0;
|
56
|
+
padding:0 0 0 20px;
|
57
|
+
font-style:italic;
|
58
|
+
}
|
59
|
+
|
60
|
+
code, pre {
|
61
|
+
font-family:Monaco, Bitstream Vera Sans Mono, Lucida Console, Terminal;
|
62
|
+
color:#333;
|
63
|
+
font-size:12px;
|
64
|
+
}
|
65
|
+
|
66
|
+
pre {
|
67
|
+
padding:8px 15px;
|
68
|
+
background: #f8f8f8;
|
69
|
+
border-radius:5px;
|
70
|
+
border:1px solid #e5e5e5;
|
71
|
+
overflow-x: auto;
|
72
|
+
}
|
73
|
+
|
74
|
+
table {
|
75
|
+
width:100%;
|
76
|
+
border-collapse:collapse;
|
77
|
+
}
|
78
|
+
|
79
|
+
th, td {
|
80
|
+
text-align:left;
|
81
|
+
padding:5px 10px;
|
82
|
+
border-bottom:1px solid #e5e5e5;
|
83
|
+
}
|
84
|
+
|
85
|
+
dt {
|
86
|
+
color:#444;
|
87
|
+
font-weight:700;
|
88
|
+
}
|
89
|
+
|
90
|
+
th {
|
91
|
+
color:#444;
|
92
|
+
}
|
93
|
+
|
94
|
+
img {
|
95
|
+
max-width:100%;
|
96
|
+
}
|
97
|
+
|
98
|
+
header {
|
99
|
+
width:270px;
|
100
|
+
float:left;
|
101
|
+
position:fixed;
|
102
|
+
}
|
103
|
+
|
104
|
+
header ul {
|
105
|
+
list-style:none;
|
106
|
+
height:40px;
|
107
|
+
|
108
|
+
padding:0;
|
109
|
+
|
110
|
+
background: #eee;
|
111
|
+
background: -moz-linear-gradient(top, #f8f8f8 0%, #dddddd 100%);
|
112
|
+
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f8f8f8), color-stop(100%,#dddddd));
|
113
|
+
background: -webkit-linear-gradient(top, #f8f8f8 0%,#dddddd 100%);
|
114
|
+
background: -o-linear-gradient(top, #f8f8f8 0%,#dddddd 100%);
|
115
|
+
background: -ms-linear-gradient(top, #f8f8f8 0%,#dddddd 100%);
|
116
|
+
background: linear-gradient(top, #f8f8f8 0%,#dddddd 100%);
|
117
|
+
|
118
|
+
border-radius:5px;
|
119
|
+
border:1px solid #d2d2d2;
|
120
|
+
box-shadow:inset #fff 0 1px 0, inset rgba(0,0,0,0.03) 0 -1px 0;
|
121
|
+
width:270px;
|
122
|
+
}
|
123
|
+
|
124
|
+
header li {
|
125
|
+
width:89px;
|
126
|
+
float:left;
|
127
|
+
border-right:1px solid #d2d2d2;
|
128
|
+
height:40px;
|
129
|
+
}
|
130
|
+
|
131
|
+
header ul a {
|
132
|
+
line-height:1;
|
133
|
+
font-size:11px;
|
134
|
+
color:#999;
|
135
|
+
display:block;
|
136
|
+
text-align:center;
|
137
|
+
padding-top:6px;
|
138
|
+
height:40px;
|
139
|
+
}
|
140
|
+
|
141
|
+
strong {
|
142
|
+
color:#222;
|
143
|
+
font-weight:700;
|
144
|
+
}
|
145
|
+
|
146
|
+
header ul li + li {
|
147
|
+
width:88px;
|
148
|
+
border-left:1px solid #fff;
|
149
|
+
}
|
150
|
+
|
151
|
+
header ul li + li + li {
|
152
|
+
border-right:none;
|
153
|
+
width:89px;
|
154
|
+
}
|
155
|
+
|
156
|
+
header ul a strong {
|
157
|
+
font-size:14px;
|
158
|
+
display:block;
|
159
|
+
color:#222;
|
160
|
+
}
|
161
|
+
|
162
|
+
section {
|
163
|
+
width:500px;
|
164
|
+
float:right;
|
165
|
+
padding-bottom:50px;
|
166
|
+
}
|
167
|
+
|
168
|
+
small {
|
169
|
+
font-size:11px;
|
170
|
+
}
|
171
|
+
|
172
|
+
hr {
|
173
|
+
border:0;
|
174
|
+
background:#e5e5e5;
|
175
|
+
height:1px;
|
176
|
+
margin:0 0 20px;
|
177
|
+
}
|
178
|
+
|
179
|
+
footer {
|
180
|
+
width:270px;
|
181
|
+
float:left;
|
182
|
+
position:fixed;
|
183
|
+
bottom:50px;
|
184
|
+
}
|
185
|
+
|
186
|
+
@media print, screen and (max-width: 960px) {
|
187
|
+
|
188
|
+
div.wrapper {
|
189
|
+
width:auto;
|
190
|
+
margin:0;
|
191
|
+
}
|
192
|
+
|
193
|
+
header, section, footer {
|
194
|
+
float:none;
|
195
|
+
position:static;
|
196
|
+
width:auto;
|
197
|
+
}
|
198
|
+
|
199
|
+
header {
|
200
|
+
padding-right:320px;
|
201
|
+
}
|
202
|
+
|
203
|
+
section {
|
204
|
+
border:1px solid #e5e5e5;
|
205
|
+
border-width:1px 0;
|
206
|
+
padding:20px 0;
|
207
|
+
margin:0 0 20px;
|
208
|
+
}
|
209
|
+
|
210
|
+
header a small {
|
211
|
+
display:inline;
|
212
|
+
}
|
213
|
+
|
214
|
+
header ul {
|
215
|
+
position:absolute;
|
216
|
+
right:50px;
|
217
|
+
top:52px;
|
218
|
+
}
|
219
|
+
}
|
220
|
+
|
221
|
+
@media print, screen and (max-width: 720px) {
|
222
|
+
body {
|
223
|
+
word-wrap:break-word;
|
224
|
+
}
|
225
|
+
|
226
|
+
header {
|
227
|
+
padding:0;
|
228
|
+
}
|
229
|
+
|
230
|
+
header ul, header p.view {
|
231
|
+
position:static;
|
232
|
+
}
|
233
|
+
|
234
|
+
pre, code {
|
235
|
+
word-wrap:normal;
|
236
|
+
}
|
237
|
+
}
|
238
|
+
|
239
|
+
@media print, screen and (max-width: 480px) {
|
240
|
+
body {
|
241
|
+
padding:15px;
|
242
|
+
}
|
243
|
+
|
244
|
+
header ul {
|
245
|
+
display:none;
|
246
|
+
}
|
247
|
+
}
|
248
|
+
|
249
|
+
@media print {
|
250
|
+
body {
|
251
|
+
padding:0.4in;
|
252
|
+
font-size:12pt;
|
253
|
+
color:#444;
|
254
|
+
}
|
255
|
+
}
|
@@ -0,0 +1,31 @@
|
|
1
|
+
Feature: clean the working tree
|
2
|
+
As an author
|
3
|
+
I want to remove generated files
|
4
|
+
In order to return my working tree to a pristine state
|
5
|
+
|
6
|
+
Background:
|
7
|
+
Given a basic project
|
8
|
+
|
9
|
+
Scenario: preview file
|
10
|
+
Given an empty file named "preview.html"
|
11
|
+
When I successfully run `rpub clean`
|
12
|
+
Then the file "preview.html" should not exist
|
13
|
+
|
14
|
+
Scenario: book
|
15
|
+
Given an empty file named "untitled-book-0.0.0.epub"
|
16
|
+
When I successfully run `rpub clean`
|
17
|
+
Then the file "untitled-book-0.0.0.epub" should not exist
|
18
|
+
|
19
|
+
Scenario: dry run mode
|
20
|
+
Given an empty file named "preview.html"
|
21
|
+
And an empty file named "untitled-book-0.0.0.epub"
|
22
|
+
When I successfully run `rpub clean -d`
|
23
|
+
Then the output should contain "preview.html"
|
24
|
+
And the output should contain "untitled-book-0.0.0.epub"
|
25
|
+
And a file named "preview.html" should exist
|
26
|
+
And a file named "untitled-book-0.0.0.epub" should exist
|
27
|
+
|
28
|
+
Scenario: help
|
29
|
+
When I successfully run `rpub clean -h`
|
30
|
+
Then the output should contain "Clean up all generated files"
|
31
|
+
|
@@ -0,0 +1,49 @@
|
|
1
|
+
Feature: Compilation
|
2
|
+
As an author
|
3
|
+
I want to compile my contents into an epub file
|
4
|
+
So my audience can read it on his e-reader device
|
5
|
+
|
6
|
+
Background:
|
7
|
+
Given a file named "chapter1.md" with:
|
8
|
+
"""
|
9
|
+
# Hello, world
|
10
|
+
|
11
|
+
lorem ipsum
|
12
|
+
"""
|
13
|
+
And a file named "chapter2.markdown" with:
|
14
|
+
"""
|
15
|
+
# Goodbye, world
|
16
|
+
|
17
|
+
lorem ipsum
|
18
|
+
"""
|
19
|
+
|
20
|
+
Scenario: generate epub file
|
21
|
+
Given the default "config.yml" file
|
22
|
+
When I successfully run `rpub compile`
|
23
|
+
Then a file named "untitled-book-0.0.0.epub" should exist
|
24
|
+
And the archive "untitled-book-0.0.0.epub" should contain file "OEBPS/chapter-0-hello-world.html"
|
25
|
+
And the archive "untitled-book-0.0.0.epub" should contain file "OEBPS/chapter-1-goodbye-world.html"
|
26
|
+
|
27
|
+
Scenario: file versioning
|
28
|
+
Given the default "config.yml" file with:
|
29
|
+
| version | 1.2.3 |
|
30
|
+
| title | My book |
|
31
|
+
When I successfully run `rpub compile`
|
32
|
+
Then a file named "my-book-1.2.3.epub" should exist
|
33
|
+
|
34
|
+
@epubcheck
|
35
|
+
Scenario: valid epub file
|
36
|
+
Given the default "config.yml" file
|
37
|
+
When I successfully run `rpub compile`
|
38
|
+
And I run `epubcheck untitled-book-0.0.0.epub`
|
39
|
+
Then the output should contain "No errors or warnings detected"
|
40
|
+
|
41
|
+
Scenario: help
|
42
|
+
When I successfully run `rpub compile -h`
|
43
|
+
Then the stdout should contain "Compile your Markdown-formatted input files"
|
44
|
+
|
45
|
+
Scenario: overriding configuration
|
46
|
+
Given the default "config.yml" file
|
47
|
+
When I successfully run `mv config.yml settings.yml`
|
48
|
+
And I successfully run `rpub compile -c settings.yml`
|
49
|
+
Then a file named "untitled-book-0.0.0.epub" should exist
|
@@ -0,0 +1,51 @@
|
|
1
|
+
Feature: embedding assets
|
2
|
+
As an author
|
3
|
+
I want to include custom fonts and images
|
4
|
+
In order to spice up the look of my book
|
5
|
+
|
6
|
+
Background:
|
7
|
+
Given a file named "chapter2.md" with:
|
8
|
+
"""
|
9
|
+
# Chapter 2
|
10
|
+
|
11
|
+
Here comes an image:
|
12
|
+
|
13
|
+
![alt text](image.jpg)
|
14
|
+
|
15
|
+
## Subheading
|
16
|
+
|
17
|
+
Lorem ipsum
|
18
|
+
"""
|
19
|
+
And an empty file named "image.jpg"
|
20
|
+
|
21
|
+
Scenario: ignoring files
|
22
|
+
When I successfully run `rpub compile`
|
23
|
+
Then the archive "untitled-book-0.0.0.epub" should not contain file "OEBPS/README.md"
|
24
|
+
|
25
|
+
Scenario: embedding fonts
|
26
|
+
Given a file named "styles.css" with:
|
27
|
+
"""
|
28
|
+
@font-face {
|
29
|
+
font-family: Foo;
|
30
|
+
src: url('Foo.otf');
|
31
|
+
}
|
32
|
+
p {
|
33
|
+
font-family: Foo;
|
34
|
+
}
|
35
|
+
@font-face {
|
36
|
+
font-family: Bar;
|
37
|
+
src: url('Bar.ttf');
|
38
|
+
}
|
39
|
+
p {
|
40
|
+
font-family: Bar;
|
41
|
+
}
|
42
|
+
"""
|
43
|
+
And an empty file named "Foo.otf"
|
44
|
+
And an empty file named "Bar.ttf"
|
45
|
+
When I successfully run `rpub compile`
|
46
|
+
Then the archive "untitled-book-0.0.0.epub" should contain file "OEBPS/Foo.otf"
|
47
|
+
And the archive "untitled-book-0.0.0.epub" should contain file "OEBPS/Bar.ttf"
|
48
|
+
|
49
|
+
Scenario: embedding images
|
50
|
+
When I successfully run `rpub compile`
|
51
|
+
Then the archive "untitled-book-0.0.0.epub" should contain file "OEBPS/image.jpg"
|
@@ -0,0 +1,63 @@
|
|
1
|
+
Feature: Generate boilerplate files
|
2
|
+
As an author
|
3
|
+
I want to generate boilerplate files
|
4
|
+
So I can get writing quickly
|
5
|
+
|
6
|
+
Scenario: Help
|
7
|
+
When I successfully run `rpub generate -h`
|
8
|
+
Then the stdout should contain "Generate one or more standard files"
|
9
|
+
|
10
|
+
Scenario: Generate all
|
11
|
+
When I successfully run `rpub generate`
|
12
|
+
Then the default file "config.yml" should exist
|
13
|
+
And the default file "layout.html" should exist
|
14
|
+
And the default file "styles.css" should exist
|
15
|
+
|
16
|
+
Scenario: All but styles
|
17
|
+
When I successfully run `rpub generate --no-styles`
|
18
|
+
Then the default file "config.yml" should exist
|
19
|
+
And the default file "layout.html" should exist
|
20
|
+
And a file named "styles.css" should not exist
|
21
|
+
|
22
|
+
Scenario: All but layout
|
23
|
+
When I successfully run `rpub generate --no-layout`
|
24
|
+
Then the default file "config.yml" should exist
|
25
|
+
And a file named "layout.html" should not exist
|
26
|
+
And the default file "styles.css" should exist
|
27
|
+
|
28
|
+
Scenario: All but configuration
|
29
|
+
When I successfully run `rpub generate --no-config`
|
30
|
+
Then a file named "config.yml" should not exist
|
31
|
+
And the default file "layout.html" should exist
|
32
|
+
And the default file "styles.css" should exist
|
33
|
+
|
34
|
+
Scenario: Only styles
|
35
|
+
When I successfully run `rpub generate --styles`
|
36
|
+
Then a file named "config.yml" should not exist
|
37
|
+
And a file named "layout.html" should not exist
|
38
|
+
And the default file "styles.css" should exist
|
39
|
+
|
40
|
+
Scenario: Only layout
|
41
|
+
When I successfully run `rpub generate --layout`
|
42
|
+
Then a file named "config.yml" should not exist
|
43
|
+
And the default file "layout.html" should exist
|
44
|
+
And a file named "styles.css" should not exist
|
45
|
+
|
46
|
+
Scenario: Only configuration
|
47
|
+
When I successfully run `rpub generate --config`
|
48
|
+
Then the default file "config.yml" should exist
|
49
|
+
And a file named "layout.html" should not exist
|
50
|
+
And a file named "styles.css" should not exist
|
51
|
+
|
52
|
+
Scenario: Not overriding existing files
|
53
|
+
Given a file named "layout.html" with:
|
54
|
+
"""
|
55
|
+
Foo
|
56
|
+
"""
|
57
|
+
When I successfully run `rpub generate --layout`
|
58
|
+
Then the stderr should contain "Not overriding layout.html"
|
59
|
+
And the file "layout.html" should contain exactly:
|
60
|
+
"""
|
61
|
+
Foo
|
62
|
+
"""
|
63
|
+
|