mint 0.7.4 → 0.8.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 +7 -0
- data/Gemfile +23 -14
- data/LICENSE +22 -0
- data/README.md +82 -56
- data/bin/mint +47 -10
- data/bin/mint-epub +1 -4
- data/config/templates/base/style.css +187 -0
- data/config/templates/default/css/style.css +126 -79
- data/config/templates/default/layout.erb +10 -0
- data/config/templates/default/style.css +237 -0
- data/config/templates/garden/layout.erb +38 -0
- data/config/templates/garden/style.css +303 -0
- data/config/templates/newspaper/layout.erb +16 -0
- data/config/templates/nord/layout.erb +11 -0
- data/config/templates/nord/style.css +339 -0
- data/config/templates/nord-dark/layout.erb +11 -0
- data/config/templates/nord-dark/style.css +339 -0
- data/config/templates/protocol/layout.erb +9 -0
- data/config/templates/protocol/style.css +25 -0
- data/config/templates/zen/layout.erb +11 -0
- data/config/templates/zen/style.css +114 -0
- data/lib/mint/command_line.rb +253 -111
- data/lib/mint/css.rb +11 -4
- data/lib/mint/css_template.rb +37 -0
- data/lib/mint/document.rb +185 -43
- data/lib/mint/helpers.rb +50 -10
- data/lib/mint/layout.rb +2 -3
- data/lib/mint/markdown_template.rb +47 -0
- data/lib/mint/mint.rb +181 -114
- data/lib/mint/plugin.rb +3 -3
- data/lib/mint/plugins/epub.rb +1 -2
- data/lib/mint/resource.rb +19 -9
- data/lib/mint/style.rb +10 -14
- data/lib/mint/version.rb +1 -1
- data/lib/mint.rb +1 -0
- data/man/mint.1 +135 -0
- data/spec/cli/README.md +99 -0
- data/spec/cli/argument_parsing_spec.rb +207 -0
- data/spec/cli/bin_integration_spec.rb +348 -0
- data/spec/cli/configuration_management_spec.rb +363 -0
- data/spec/cli/full_workflow_integration_spec.rb +527 -0
- data/spec/cli/publish_workflow_spec.rb +368 -0
- data/spec/cli/template_management_spec.rb +300 -0
- data/spec/css_spec.rb +1 -1
- data/spec/document_spec.rb +102 -69
- data/spec/helpers_spec.rb +42 -42
- data/spec/mint_spec.rb +104 -80
- data/spec/plugin_spec.rb +86 -88
- data/spec/run_cli_tests.rb +95 -0
- data/spec/spec_helper.rb +8 -1
- data/spec/style_spec.rb +18 -16
- data/spec/support/cli_helpers.rb +169 -0
- data/spec/support/fixtures/content-2.md +16 -0
- data/spec/support/matchers.rb +1 -1
- metadata +116 -223
- data/config/syntax.yaml +0 -71
- data/config/templates/base/style.sass +0 -144
- data/config/templates/default/layout.haml +0 -8
- data/config/templates/default/style.sass +0 -36
- data/config/templates/protocol/layout.haml +0 -7
- data/config/templates/protocol/style.sass +0 -20
- data/config/templates/zen/css/style.css +0 -145
- data/config/templates/zen/layout.haml +0 -7
- data/config/templates/zen/style.sass +0 -24
- data/features/config.feature +0 -21
- data/features/plugins/epub.feature +0 -23
- data/features/publish.feature +0 -73
- data/features/support/env.rb +0 -15
- data/features/templates.feature +0 -79
- data/spec/command_line_spec.rb +0 -87
- data/spec/plugins/epub_spec.rb +0 -242
data/spec/plugins/epub_spec.rb
DELETED
@@ -1,242 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
# Mimics the requirement to actually require plugins for
|
4
|
-
# them to be registered/work.
|
5
|
-
require "mint/plugins/epub"
|
6
|
-
|
7
|
-
module Mint
|
8
|
-
describe Document do
|
9
|
-
describe "#chapters" do
|
10
|
-
it "splits a document's final text into chapters and maps onto IDs" do
|
11
|
-
# TODO: Clean up these long lines
|
12
|
-
chapters = Document.new("content.md").chapters
|
13
|
-
chapters[0].should =~ /This is just a test.*Paragraph number two/m
|
14
|
-
chapters[1].should =~ /Third sentence.*Fourth sentence/m
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
describe EPub do
|
20
|
-
describe "#after_publish" do
|
21
|
-
let(:document) do
|
22
|
-
Document.new "content.md", :destination => "directory"
|
23
|
-
end
|
24
|
-
|
25
|
-
before do
|
26
|
-
document.publish!
|
27
|
-
document_length = File.read("directory/content.html").length
|
28
|
-
EPub.after_publish(document)
|
29
|
-
|
30
|
-
# We're going to consider a document successfully split
|
31
|
-
# if its two chapters are less than half of it's length,
|
32
|
-
# not including the DOCTYPE/HTML chrome that we introduce
|
33
|
-
# into each split document (~150 characters)
|
34
|
-
@target_length = document_length / 2 + 200
|
35
|
-
end
|
36
|
-
|
37
|
-
after do
|
38
|
-
FileUtils.rm_r "directory.epub"
|
39
|
-
end
|
40
|
-
|
41
|
-
it "does nothing if no destination is specified" do
|
42
|
-
invalid_document = Document.new "content.md"
|
43
|
-
lambda do
|
44
|
-
EPub.after_publish(invalid_document)
|
45
|
-
end.should raise_error(InvalidDocumentError)
|
46
|
-
end
|
47
|
-
|
48
|
-
it "replaces the monolithic published file with a packaged ePub file" do
|
49
|
-
File.exist?("directory/content.html").should be_false
|
50
|
-
File.exist?("directory.epub").should be_true
|
51
|
-
end
|
52
|
-
|
53
|
-
it "produces a valid ePub file" do
|
54
|
-
pending "need to integrate epubcheck script if found on system"
|
55
|
-
end
|
56
|
-
|
57
|
-
it "ensures all files were compressed using PKZIP" do
|
58
|
-
File.read("directory.epub")[0..1].should == "PK"
|
59
|
-
end
|
60
|
-
|
61
|
-
context "when the ePub file is unzipped" do
|
62
|
-
before do
|
63
|
-
# Copy instead of moving to make test cleanup more
|
64
|
-
# predictable in nested contexts.
|
65
|
-
FileUtils.cp "directory.epub", "directory.zip"
|
66
|
-
|
67
|
-
# I will later replace this with my own EPub.unzip! function
|
68
|
-
# but don't want to get too distracted now.
|
69
|
-
`unzip -o directory.zip -d directory`
|
70
|
-
|
71
|
-
# EPub.unzip! "directory.zip"
|
72
|
-
end
|
73
|
-
|
74
|
-
after do
|
75
|
-
FileUtils.rm_r "directory.zip"
|
76
|
-
FileUtils.rm_r "directory"
|
77
|
-
end
|
78
|
-
|
79
|
-
it "contains a META-INF directory" do
|
80
|
-
File.exist?("directory/META-INF/container.xml").should be_true
|
81
|
-
end
|
82
|
-
|
83
|
-
it "contains an OPS directory" do
|
84
|
-
File.exist?("directory/OPS").should be_true
|
85
|
-
end
|
86
|
-
|
87
|
-
it "contains a mimetype file" do
|
88
|
-
File.exist?("directory/mimetype").should be_true
|
89
|
-
File.read("directory/mimetype").chomp.should == "application/epub+zip"
|
90
|
-
end
|
91
|
-
|
92
|
-
it "contains a container file that points to the OPF file" do
|
93
|
-
File.exist?("directory/META-INF/container.xml").should be_true
|
94
|
-
end
|
95
|
-
|
96
|
-
it "contains an OPF manifest with book metadata" do
|
97
|
-
File.exist?("directory/OPS/content.opf").should be_true
|
98
|
-
end
|
99
|
-
|
100
|
-
it "contains an NCX file with book spine and TOC" do
|
101
|
-
File.exist?("directory/OPS/toc.ncx").should be_true
|
102
|
-
end
|
103
|
-
|
104
|
-
it "splits the document into chapters" do
|
105
|
-
chapter1 = File.read "directory/OPS/chapter-1.html"
|
106
|
-
chapter2 = File.read "directory/OPS/chapter-2.html"
|
107
|
-
|
108
|
-
chapter1.length.should < @target_length
|
109
|
-
chapter2.length.should < @target_length
|
110
|
-
end
|
111
|
-
|
112
|
-
it "creates a stylesheet for all pages"
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
describe "#split_on" do
|
117
|
-
it "returns a copy of the HTML text it is passed, grouping elements" do
|
118
|
-
Document.new("content.md").publish!
|
119
|
-
|
120
|
-
html_text = File.read "content.html"
|
121
|
-
html_document = Nokogiri::HTML.parse(html_text)
|
122
|
-
|
123
|
-
chapters = EPub.split_on(html_document, "h2")
|
124
|
-
|
125
|
-
expected_document = Nokogiri::HTML.parse <<-HTML
|
126
|
-
<div id="container">
|
127
|
-
<div>
|
128
|
-
<h2>Header</h2>
|
129
|
-
<p>This is just a test.</p>
|
130
|
-
<p>Paragraph number two.</p>
|
131
|
-
</div>
|
132
|
-
|
133
|
-
<div>
|
134
|
-
<h2>Header 2</h2>
|
135
|
-
<p>Third sentence.</p>
|
136
|
-
<p>Fourth sentence.</p>
|
137
|
-
</div>
|
138
|
-
</div>
|
139
|
-
HTML
|
140
|
-
|
141
|
-
expected_chapters = expected_document.search "div div"
|
142
|
-
|
143
|
-
cleanse(chapters).should == cleanse(expected_chapters)
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
|
-
describe "#zip!" do
|
148
|
-
before do
|
149
|
-
FileUtils.mkdir "directory"
|
150
|
-
|
151
|
-
files = {
|
152
|
-
first: "First content",
|
153
|
-
second: "Second content",
|
154
|
-
third: "Third content"
|
155
|
-
}
|
156
|
-
|
157
|
-
files.each do |name, content|
|
158
|
-
File.open "directory/#{name}", "w" do |f|
|
159
|
-
f << content
|
160
|
-
end
|
161
|
-
end
|
162
|
-
end
|
163
|
-
|
164
|
-
after do
|
165
|
-
Dir["directory*"].each {|dir| FileUtils.rm_r dir }
|
166
|
-
# FileUtils.rm "directory.zip"
|
167
|
-
# FileUtils.rm_r "directory"
|
168
|
-
end
|
169
|
-
|
170
|
-
# This is not a great test of Zip functionality,
|
171
|
-
# but I don't really care to spend time on this right now.
|
172
|
-
# Most of the details of the Zip file creation will be tested
|
173
|
-
# above.
|
174
|
-
it "compresses the named file into a directory" do
|
175
|
-
EPub.zip! "directory"
|
176
|
-
File.exist?("directory.zip").should be_true
|
177
|
-
end
|
178
|
-
|
179
|
-
it "accepts an extension parameter" do
|
180
|
-
EPub.zip! "directory", :extension => "epub"
|
181
|
-
File.exist?("directory.epub").should be_true
|
182
|
-
end
|
183
|
-
|
184
|
-
it "creates a mimetype entry if specified" do
|
185
|
-
pending "a more robust Zip testing strategy"
|
186
|
-
EPub.zip! "directory", :mimetype => "text/epub"
|
187
|
-
end
|
188
|
-
end
|
189
|
-
|
190
|
-
describe "#create!" do
|
191
|
-
before do
|
192
|
-
EPub.should_receive(:create_from_template!).and_return
|
193
|
-
end
|
194
|
-
|
195
|
-
it "accepts a block for configuration options" do
|
196
|
-
lambda do
|
197
|
-
EPub.create! do |file|
|
198
|
-
file.type = "container"
|
199
|
-
end
|
200
|
-
end.should_not raise_error
|
201
|
-
end
|
202
|
-
|
203
|
-
it "render a container file" do
|
204
|
-
EPub.should_receive(:container_defaults).once.and_return({})
|
205
|
-
EPub.create! do |file|
|
206
|
-
file.type = "container"
|
207
|
-
end
|
208
|
-
end
|
209
|
-
|
210
|
-
it "render a content file" do
|
211
|
-
EPub.should_receive(:content_defaults).once.and_return({})
|
212
|
-
EPub.create! do |file|
|
213
|
-
file.type = "content"
|
214
|
-
end
|
215
|
-
end
|
216
|
-
|
217
|
-
it "render a table of contents file" do
|
218
|
-
EPub.should_receive(:toc_defaults).once.and_return({})
|
219
|
-
EPub.create! do |file|
|
220
|
-
file.type = "toc"
|
221
|
-
end
|
222
|
-
end
|
223
|
-
|
224
|
-
it "defaults to a type of 'container'" do
|
225
|
-
EPub.should_receive(:container_defaults).once.and_return({})
|
226
|
-
EPub.create!
|
227
|
-
end
|
228
|
-
end
|
229
|
-
|
230
|
-
describe "#create_chapters!" do
|
231
|
-
it "calls #create_chapter! for each chapter" do
|
232
|
-
EPub.should_receive(:create_chapter!).once.ordered
|
233
|
-
EPub.should_receive(:create_chapter!).once.ordered
|
234
|
-
EPub.create_chapters! ["text1", "text2"]
|
235
|
-
end
|
236
|
-
end
|
237
|
-
|
238
|
-
def cleanse(dom)
|
239
|
-
dom.to_s.squeeze.chomp.gsub(/^\s/, "")
|
240
|
-
end
|
241
|
-
end
|
242
|
-
end
|