mint 0.8.1 → 0.10.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/Gemfile +1 -26
- data/README.md +117 -37
- data/bin/mint +2 -81
- data/config/templates/base/navigation.css +136 -0
- data/config/templates/base/print.css +152 -0
- data/config/templates/{reset.css → base/reset.css} +1 -1
- data/config/templates/base/style.css +117 -137
- data/config/templates/base/utilities.css +136 -0
- data/config/templates/base/variables.css +124 -0
- data/config/templates/basic/style.css +151 -0
- data/config/templates/default/layout.erb +33 -3
- data/config/templates/default/style.css +95 -164
- data/config/templates/magazine/style.css +383 -0
- data/config/templates/nord/style.css +105 -220
- data/config/templates/nord-dark/style.css +82 -263
- data/lib/mint/commandline/parse.rb +144 -0
- data/lib/mint/commandline/publish.rb +46 -0
- data/lib/mint/commandline/run.rb +30 -0
- data/lib/mint/config.rb +162 -0
- data/lib/mint/{css.rb → css_dsl.rb} +9 -9
- data/lib/mint/css_parser.rb +45 -25
- data/lib/mint/document.rb +250 -365
- data/lib/mint/document_tree.rb +163 -0
- data/lib/mint/exceptions.rb +2 -3
- data/lib/mint/helpers.rb +23 -180
- data/lib/mint/layout.rb +26 -9
- data/lib/mint/renderers/css_renderer.rb +32 -0
- data/lib/mint/renderers/erb_renderer.rb +11 -0
- data/lib/mint/renderers/markdown_renderer.rb +45 -0
- data/lib/mint/style.rb +21 -31
- data/lib/mint/template.rb +30 -0
- data/lib/mint/version.rb +1 -1
- data/lib/mint/workspace.rb +171 -0
- data/lib/mint.rb +44 -12
- data/man/mint.1 +85 -44
- data/spec/cli/README.md +2 -2
- data/spec/cli/argument_parsing_spec.rb +89 -147
- data/spec/cli/bin_integration_spec.rb +23 -243
- data/spec/cli/full_workflow_integration_spec.rb +99 -442
- data/spec/cli/original_style_integration_spec.rb +58 -0
- data/spec/cli/publish_workflow_spec.rb +72 -70
- data/spec/commandline_path_integration_spec.rb +230 -0
- data/spec/config_file_integration_spec.rb +362 -0
- data/spec/{css_spec.rb → css_dsl_spec.rb} +7 -3
- data/spec/css_parser_spec.rb +59 -1
- data/spec/document_spec.rb +37 -242
- data/spec/flattened_path_spec.rb +150 -0
- data/spec/layout_spec.rb +42 -3
- data/spec/mint_spec.rb +22 -217
- data/spec/path_handling_spec.rb +237 -0
- data/spec/run_cli_tests.rb +1 -1
- data/spec/spec_helper.rb +3 -10
- data/spec/style_spec.rb +31 -56
- data/spec/support/cli_helpers.rb +7 -10
- data/spec/support/matchers.rb +1 -1
- data/spec/template_spec.rb +31 -0
- data/spec/workspace_spec.rb +177 -0
- metadata +75 -89
- data/bin/mint-epub +0 -20
- data/config/templates/garden/layout.erb +0 -38
- data/config/templates/garden/style.css +0 -303
- data/config/templates/nord/layout.erb +0 -11
- data/config/templates/nord-dark/layout.erb +0 -11
- data/config/templates/zen/layout.erb +0 -11
- data/config/templates/zen/style.css +0 -114
- data/lib/mint/command_line.rb +0 -360
- data/lib/mint/css_template.rb +0 -37
- data/lib/mint/markdown_template.rb +0 -47
- data/lib/mint/mint.rb +0 -313
- data/lib/mint/plugin.rb +0 -136
- data/lib/mint/plugins/epub.rb +0 -293
- data/lib/mint/resource.rb +0 -101
- data/plugins/templates/epub/layouts/container.haml +0 -5
- data/plugins/templates/epub/layouts/content.haml +0 -35
- data/plugins/templates/epub/layouts/layout.haml +0 -6
- data/plugins/templates/epub/layouts/title.haml +0 -11
- data/plugins/templates/epub/layouts/toc.haml +0 -26
- data/spec/cli/configuration_management_spec.rb +0 -363
- data/spec/cli/template_management_spec.rb +0 -300
- data/spec/helpers_spec.rb +0 -249
- data/spec/plugin_spec.rb +0 -449
- data/spec/resource_spec.rb +0 -135
data/spec/document_spec.rb
CHANGED
@@ -2,260 +2,55 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
module Mint
|
4
4
|
describe Document do
|
5
|
-
#
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
# include our content
|
14
|
-
#
|
15
|
-
# This test doesn't cover any plugin transformations. Those
|
16
|
-
# transformations are covered in the Plugin spec.
|
17
|
-
its(:content) { is_expected.to match(/<p>This is just a test.<\/p>/) }
|
18
|
-
its(:metadata) { is_expected.to eq({ "metadata" => true }) }
|
19
|
-
|
20
|
-
# Render output
|
21
|
-
|
22
|
-
# This test doesn't cover any plugin transformations. Those
|
23
|
-
# transformations are covered in the Plugin spec.
|
24
|
-
it "renders its layout, injecting content inside" do
|
25
|
-
expect(document.render).to include(document.content)
|
26
|
-
expect(document.render).to include("<html")
|
27
|
-
expect(document.render).to include("</html>")
|
28
|
-
end
|
29
|
-
|
30
|
-
it "includes its stylesheet appropriately based on style mode" do
|
31
|
-
if document.style_mode == :external
|
32
|
-
expect(document.render).to include('<link rel="stylesheet"')
|
33
|
-
expect(document.render).not_to include("<style>")
|
34
|
-
else
|
35
|
-
expect(document.render).to include("<style>")
|
36
|
-
expect(document.render).to include("</style>")
|
5
|
+
describe "#transform_markdown_links" do
|
6
|
+
around(:each) do |example|
|
7
|
+
in_temp_dir do |dir|
|
8
|
+
@test_dir = dir
|
9
|
+
File.write("test.md", "# Test Document")
|
10
|
+
File.write("layout.erb", "<%= content %>")
|
11
|
+
File.write("style.css", "body { font-family: sans-serif; }")
|
12
|
+
example.run
|
37
13
|
end
|
38
14
|
end
|
39
15
|
|
40
|
-
# Mint output
|
41
|
-
|
42
|
-
# These tests doesn't cover any plugin transformations. Those
|
43
|
-
# transformations are covered in the Plugin spec.
|
44
|
-
it "writes its rendered style to #style_destination_file" do
|
45
|
-
document.publish!
|
46
|
-
if document.style_mode == :external
|
47
|
-
expect(document.style_destination_file_path).to exist
|
48
|
-
else
|
49
|
-
# For inline styles, no external file should be created
|
50
|
-
expect(document.style_destination_file_path).not_to exist
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
it "writes its rendered layout and content to #destination_file" do
|
55
|
-
document.publish!
|
56
|
-
expect(document.destination_file_path).to exist
|
57
|
-
content = File.read document.destination_file
|
58
|
-
expect(content).to eq(document.render)
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
context "when it's created with default options" do
|
63
|
-
let(:document) { Document.new @content_file }
|
64
|
-
|
65
|
-
subject { document }
|
66
|
-
its(:root) { is_expected.to eq(@tmp_dir) }
|
67
|
-
its(:destination) { is_expected.to be_nil }
|
68
|
-
its(:source) { is_expected.to eq("content.md") }
|
69
|
-
its(:style_destination) { is_expected.to be_nil }
|
70
|
-
|
71
|
-
it "has a style destination file in user tmp directory" do
|
72
|
-
expect(document.style_destination_file).to match(/\.config\/mint\/tmp\/style\.css$/)
|
73
|
-
end
|
74
|
-
|
75
|
-
it "has a style destination directory in user tmp directory" do
|
76
|
-
expect(document.style_destination_directory).to match(/\.config\/mint\/tmp$/)
|
77
|
-
end
|
78
|
-
|
79
|
-
its(:style_destination_file_path) do
|
80
|
-
is_expected.to eq(Pathname.new(document.style_destination_file))
|
81
|
-
end
|
82
|
-
|
83
|
-
its(:style_destination_directory_path) do
|
84
|
-
is_expected.to eq(Pathname.new(document.style_destination_directory))
|
85
|
-
end
|
86
|
-
|
87
|
-
its(:layout) { is_expected.to be_in_directory("default") }
|
88
|
-
its(:style) { is_expected.to be_in_directory("default") }
|
89
|
-
|
90
|
-
it "has a stylesheet path relative to user tmp directory" do
|
91
|
-
expect(document.stylesheet).to match(/\.config\/mint\/tmp\/style\.css$/)
|
92
|
-
end
|
93
|
-
|
94
|
-
it_should_behave_like "all documents"
|
95
|
-
end
|
96
|
-
|
97
|
-
context "when it's created with explicit destination directories" do
|
98
|
-
let(:document) { Document.new @content_file,
|
99
|
-
destination: "destination",
|
100
|
-
style_destination: "styles" }
|
101
|
-
|
102
|
-
subject { document }
|
103
|
-
its(:root) { is_expected.to eq(@tmp_dir) }
|
104
|
-
its(:destination) { is_expected.to eq("destination") }
|
105
|
-
its(:source) { is_expected.to eq("content.md") }
|
106
|
-
its(:style_destination) { is_expected.to eq("styles") }
|
107
|
-
|
108
|
-
its(:style_destination_file) do
|
109
|
-
is_expected.to eq("#{@tmp_dir}/destination/styles/style.css")
|
110
|
-
end
|
111
|
-
|
112
|
-
its(:style_destination_directory) do
|
113
|
-
is_expected.to eq("#{@tmp_dir}/destination/styles")
|
114
|
-
end
|
115
|
-
|
116
|
-
its(:style_destination_file_path) do
|
117
|
-
is_expected.to eq(Pathname.new(document.style_destination_file))
|
118
|
-
end
|
119
|
-
|
120
|
-
its(:style_destination_directory_path) do
|
121
|
-
is_expected.to eq(Pathname.new(document.style_destination_directory))
|
122
|
-
end
|
123
|
-
|
124
|
-
its(:layout) { is_expected.to be_in_directory("default") }
|
125
|
-
its(:style) { is_expected.to be_in_directory("default") }
|
126
|
-
|
127
|
-
it "has a stylesheet path relative to user tmp directory" do
|
128
|
-
expect(document.stylesheet).to match(/\.config\/mint\/tmp\/style\.css$/)
|
129
|
-
end
|
130
|
-
|
131
|
-
it_should_behave_like "all documents"
|
132
|
-
end
|
133
|
-
|
134
|
-
context "when it's created with an explicit root" do
|
135
|
-
let(:document) { Document.new @content_file,
|
136
|
-
root: "#{@tmp_dir}/alternative-root" }
|
137
|
-
|
138
|
-
subject { document }
|
139
|
-
its(:root) { is_expected.to eq("#{@tmp_dir}/alternative-root") }
|
140
|
-
it "preserves folder structure" do
|
141
|
-
expect(document.destination).to be_present
|
142
|
-
end
|
143
|
-
its(:source) { is_expected.to eq("content.md") }
|
144
|
-
its(:style_destination) { is_expected.to be_nil }
|
145
|
-
|
146
|
-
it "has appropriate style behavior based on style mode" do
|
147
|
-
if document.style_mode == :external
|
148
|
-
expect(document.style_destination_file).to match(/\.config\/mint\/tmp\/style\.css$/)
|
149
|
-
else
|
150
|
-
# For inline styles, the style_destination_file should still exist as a path
|
151
|
-
# but no actual file should be created during publish
|
152
|
-
expect(document.style_destination_file).to be_present
|
153
|
-
end
|
154
|
-
end
|
155
|
-
|
156
|
-
it "has appropriate style destination directory based on style mode" do
|
157
|
-
if document.style_mode == :external
|
158
|
-
expect(document.style_destination_directory).to match(/\.config\/mint\/tmp$/)
|
159
|
-
else
|
160
|
-
# For inline styles, still has a directory path but it's not used for external files
|
161
|
-
expect(document.style_destination_directory).to be_present
|
162
|
-
end
|
163
|
-
end
|
164
|
-
|
165
|
-
its(:style_destination_file_path) do
|
166
|
-
is_expected.to eq(Pathname.new(document.style_destination_file))
|
167
|
-
end
|
168
|
-
|
169
|
-
its(:style_destination_directory_path) do
|
170
|
-
is_expected.to eq(Pathname.new(document.style_destination_directory))
|
171
|
-
end
|
172
|
-
|
173
|
-
its(:layout) { is_expected.to be_in_directory("default") }
|
174
|
-
its(:style) { is_expected.to be_in_directory("default") }
|
175
|
-
|
176
|
-
it "has a stylesheet path relative to user tmp directory" do
|
177
|
-
expect(document.stylesheet).to match(/\.config\/mint\/tmp\/style\.css$/)
|
178
|
-
end
|
179
|
-
|
180
|
-
it_should_behave_like "all documents"
|
181
|
-
end
|
182
|
-
|
183
|
-
context "when it is created with a block" do
|
184
16
|
let(:document) do
|
185
|
-
Document.new
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
its(:source) { is_expected.to eq("content.md") }
|
198
|
-
its(:style_destination) { is_expected.to eq("styles") }
|
199
|
-
|
200
|
-
its(:style_destination_file) do
|
201
|
-
is_expected.to eq("#{@tmp_dir}/alternative-root/destination/styles/style.css")
|
202
|
-
end
|
203
|
-
|
204
|
-
its(:style_destination_directory) do
|
205
|
-
is_expected.to eq("#{@tmp_dir}/alternative-root/destination/styles")
|
206
|
-
end
|
207
|
-
|
208
|
-
its(:style_destination_file_path) do
|
209
|
-
is_expected.to eq(Pathname.new(document.style_destination_file))
|
17
|
+
Document.new(
|
18
|
+
working_directory: Pathname.new(@test_dir),
|
19
|
+
source_path: Pathname.new("test.md"),
|
20
|
+
destination_path: Pathname.new("test.html"),
|
21
|
+
destination_directory_path: Pathname.new("output"),
|
22
|
+
layout_path: Pathname.new("layout.erb"),
|
23
|
+
style_path: Pathname.new("style.css"),
|
24
|
+
style_destination_path: Pathname.new("output"),
|
25
|
+
style_mode: :inline,
|
26
|
+
insert_title_heading: false,
|
27
|
+
transform_links: proc {|basename| "#{basename}.html" }
|
28
|
+
)
|
210
29
|
end
|
211
30
|
|
212
|
-
|
213
|
-
|
31
|
+
it "transforms .md links to .html links" do
|
32
|
+
text = "Check out [this document](other.md) for more info."
|
33
|
+
result = document.transform_markdown_links(text) {|basename| "#{basename}.html" }
|
34
|
+
expect(result).to eq("Check out [this document](other.html) for more info.")
|
214
35
|
end
|
215
36
|
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
expect(document.stylesheet).to match(/\.config\/mint\/tmp\/style\.css$/)
|
221
|
-
end
|
222
|
-
|
223
|
-
it_should_behave_like "all documents"
|
224
|
-
end
|
225
|
-
|
226
|
-
context "when dealing with metadata" do
|
227
|
-
let(:text) { "metadata: true\n\nReal text" }
|
228
|
-
describe ".metadata_chunk" do
|
229
|
-
it "extracts, but does not parse, metadata from text" do
|
230
|
-
expect(Document.metadata_chunk(text)).to eq("metadata: true")
|
231
|
-
end
|
37
|
+
it "preserves absolute URLs unchanged" do
|
38
|
+
text = "Visit [our website](https://example.com/page.md) for details."
|
39
|
+
result = document.transform_markdown_links(text) {|basename| "#{basename}.html" }
|
40
|
+
expect(result).to eq("Visit [our website](https://example.com/page.md) for details.")
|
232
41
|
end
|
233
42
|
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
it "returns the empty string if a document has bad/no metadata" do
|
240
|
-
expect(Document.metadata_from("No metadata here")).to eq({})
|
241
|
-
end
|
242
|
-
|
243
|
-
it "handles a non-simple string that is also not YAML" do
|
244
|
-
expect(Document.metadata_from("# Non-simple string")).to eq({})
|
245
|
-
end
|
43
|
+
it "respects custom output file format via block" do
|
44
|
+
text = "See [document](file.md) here."
|
45
|
+
result = document.transform_markdown_links(text) {|basename| "#{basename}_converted.html" }
|
46
|
+
expect(result).to eq("See [document](file_converted.html) here.")
|
246
47
|
end
|
247
48
|
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
end
|
253
|
-
|
254
|
-
it "returns the entire text if no metadata is found" do
|
255
|
-
expect(Document.parse_metadata_from("No metadata here")).to eq(
|
256
|
-
[{}, "No metadata here"])
|
257
|
-
end
|
49
|
+
it "handles multiple links in same text" do
|
50
|
+
text = "Read [doc1](first.md) and [doc2](second.md)."
|
51
|
+
result = document.transform_markdown_links(text) {|basename| "#{basename}.html" }
|
52
|
+
expect(result).to eq("Read [doc1](first.html) and [doc2](second.html).")
|
258
53
|
end
|
259
54
|
end
|
260
55
|
end
|
261
|
-
end
|
56
|
+
end
|
@@ -0,0 +1,150 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe "Flattened Path Handling (explicit --no-preserve-structure)" do
|
4
|
+
context "in isolated environment" do
|
5
|
+
around(:each) do |example|
|
6
|
+
in_temp_dir do |dir|
|
7
|
+
@test_dir = dir
|
8
|
+
create_template_directory("default")
|
9
|
+
example.run
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "default flattened behavior" do
|
14
|
+
it "places files from nested directories directly in destination" do
|
15
|
+
FileUtils.mkdir_p(["docs/guides", "output"])
|
16
|
+
create_markdown_path("docs/guides/setup.md", "# Setup Guide")
|
17
|
+
|
18
|
+
config = Mint::Config.with_defaults(destination_directory: Pathname.new("output"), preserve_structure: false)
|
19
|
+
workspace = Mint::Workspace.new([Pathname.new("docs/guides/setup.md")], config)
|
20
|
+
workspace.publish!
|
21
|
+
|
22
|
+
# File should be flattened to output directory
|
23
|
+
expect(File.exist?("output/setup.html")).to be true
|
24
|
+
expect(File.exist?("output/docs/guides/setup.html")).to be false
|
25
|
+
end
|
26
|
+
|
27
|
+
it "handles multiple files from different nested levels" do
|
28
|
+
FileUtils.mkdir_p(["src", "src/components", "src/pages/admin", "build"])
|
29
|
+
|
30
|
+
create_markdown_path("src/readme.md", "# Project README")
|
31
|
+
create_markdown_path("src/components/button.md", "# Button Component")
|
32
|
+
create_markdown_path("src/pages/admin/dashboard.md", "# Admin Dashboard")
|
33
|
+
|
34
|
+
files = [
|
35
|
+
"src/readme.md",
|
36
|
+
"src/components/button.md",
|
37
|
+
"src/pages/admin/dashboard.md"
|
38
|
+
]
|
39
|
+
|
40
|
+
config = Mint::Config.with_defaults(destination_directory: Pathname.new("build"), preserve_structure: false)
|
41
|
+
|
42
|
+
workspace = Mint::Workspace.new(files.map {|f| Pathname.new(f) }, config)
|
43
|
+
workspace.publish!
|
44
|
+
|
45
|
+
# All files should be flattened to build directory
|
46
|
+
expect(File.exist?("build/readme.html")).to be true
|
47
|
+
expect(File.exist?("build/button.html")).to be true
|
48
|
+
expect(File.exist?("build/dashboard.html")).to be true
|
49
|
+
|
50
|
+
# Should not preserve directory structure
|
51
|
+
expect(File.exist?("build/src/readme.html")).to be false
|
52
|
+
expect(File.exist?("build/src/components/button.html")).to be false
|
53
|
+
expect(File.exist?("build/src/pages/admin/dashboard.html")).to be false
|
54
|
+
end
|
55
|
+
|
56
|
+
it "handles files with same basename from different directories" do
|
57
|
+
FileUtils.mkdir_p(["docs/v1", "docs/v2", "output"])
|
58
|
+
|
59
|
+
create_markdown_path("docs/v1/index.md", "# V1 Index")
|
60
|
+
create_markdown_path("docs/v2/index.md", "# V2 Index")
|
61
|
+
|
62
|
+
config = Mint::Config.with_defaults(destination_directory: Pathname.new("output"), preserve_structure: false)
|
63
|
+
|
64
|
+
# Process files separately to see collision behavior
|
65
|
+
workspace = Mint::Workspace.new([Pathname.new("docs/v1/index.md"), Pathname.new("docs/v2/index.md")], config)
|
66
|
+
workspace.publish!
|
67
|
+
|
68
|
+
# Only one index.html should exist (last one wins)
|
69
|
+
expect(File.exist?("output/index.html")).to be true
|
70
|
+
|
71
|
+
# Check that it's the V2 content (last one processed)
|
72
|
+
content = File.read("output/index.html")
|
73
|
+
expect(content).to include("V2 Index")
|
74
|
+
end
|
75
|
+
|
76
|
+
it "works with commandline batch processing" do
|
77
|
+
FileUtils.mkdir_p(["content/posts", "content/pages", "site"])
|
78
|
+
|
79
|
+
create_markdown_path("content/posts/article1.md", "# Article 1")
|
80
|
+
create_markdown_path("content/posts/article2.md", "# Article 2")
|
81
|
+
create_markdown_path("content/pages/about.md", "# About")
|
82
|
+
|
83
|
+
files = [
|
84
|
+
Pathname.new("content/posts/article1.md"),
|
85
|
+
Pathname.new("content/posts/article2.md"),
|
86
|
+
Pathname.new("content/pages/about.md")
|
87
|
+
]
|
88
|
+
|
89
|
+
config = Mint::Config.with_defaults(destination_directory: Pathname.new("site"), preserve_structure: false)
|
90
|
+
Mint::Commandline.publish!(files, config: config)
|
91
|
+
|
92
|
+
# All files flattened to site directory
|
93
|
+
expect(File.exist?("site/article1.html")).to be true
|
94
|
+
expect(File.exist?("site/article2.html")).to be true
|
95
|
+
expect(File.exist?("site/about.html")).to be true
|
96
|
+
|
97
|
+
# No nested structure
|
98
|
+
expect(File.exist?("site/content/posts/article1.html")).to be false
|
99
|
+
expect(File.exist?("site/content/pages/about.html")).to be false
|
100
|
+
end
|
101
|
+
|
102
|
+
it "works with different root and destination directories" do
|
103
|
+
FileUtils.mkdir_p(["source/docs", "public"])
|
104
|
+
|
105
|
+
create_markdown_path("source/docs/guide.md", "# User Guide")
|
106
|
+
|
107
|
+
config = Mint::Config.with_defaults(
|
108
|
+
working_directory: Pathname.new("source"),
|
109
|
+
destination_directory: Pathname.new("../public"),
|
110
|
+
preserve_structure: false
|
111
|
+
)
|
112
|
+
|
113
|
+
workspace = Mint::Workspace.new([Pathname.new("source/docs/guide.md")], config)
|
114
|
+
workspace.publish!
|
115
|
+
|
116
|
+
# File should be flattened in public directory
|
117
|
+
expect(File.exist?("public/guide.html")).to be true
|
118
|
+
expect(File.exist?("public/docs/guide.html")).to be false
|
119
|
+
end
|
120
|
+
|
121
|
+
it "maintains original behavior for files in root directory" do
|
122
|
+
FileUtils.mkdir_p("output")
|
123
|
+
create_markdown_path("index.md", "# Home Page")
|
124
|
+
|
125
|
+
config = Mint::Config.with_defaults(destination_directory: Pathname.new("output"), preserve_structure: false)
|
126
|
+
workspace = Mint::Workspace.new([Pathname.new("index.md")], config)
|
127
|
+
workspace.publish!
|
128
|
+
|
129
|
+
expect(File.exist?("output/index.html")).to be true
|
130
|
+
end
|
131
|
+
|
132
|
+
it "works with external style mode" do
|
133
|
+
FileUtils.mkdir_p(["docs", "site"])
|
134
|
+
create_markdown_path("docs/manual.md", "# Manual")
|
135
|
+
|
136
|
+
config = Mint::Config.with_defaults(
|
137
|
+
destination_directory: Pathname.new("site"),
|
138
|
+
style_mode: :external,
|
139
|
+
preserve_structure: false
|
140
|
+
)
|
141
|
+
|
142
|
+
Mint::Commandline.publish!([Pathname.new("docs/manual.md")], config: config)
|
143
|
+
|
144
|
+
expect(File.exist?("site/manual.html")).to be true # Flattened
|
145
|
+
expect(File.exist?("site/style.css")).to be true # Style in destination
|
146
|
+
expect(File.exist?("site/docs/manual.html")).to be false
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
data/spec/layout_spec.rb
CHANGED
@@ -1,6 +1,45 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
|
4
|
-
describe
|
3
|
+
describe Mint::Layout do
|
4
|
+
describe ".valid?" do
|
5
|
+
it "determines if a file is a valid layout file" do
|
6
|
+
expect(Mint::Layout.valid?(Pathname.new("layout.html"))).to be true
|
7
|
+
expect(Mint::Layout.valid?(Pathname.new("layout.erb"))).to be true
|
8
|
+
expect(Mint::Layout.valid?(Pathname.new("other.html"))).to be false
|
9
|
+
end
|
5
10
|
end
|
6
|
-
|
11
|
+
|
12
|
+
describe ".find_by_name" do
|
13
|
+
it "returns layout file path by template name" do
|
14
|
+
result = Mint::Layout.find_by_name("default")
|
15
|
+
if result
|
16
|
+
expect(result).to be_a(Pathname)
|
17
|
+
expect(Mint::Layout.valid?(result)).to be true
|
18
|
+
else
|
19
|
+
expect(result).to be_nil
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe ".find_in_directory" do
|
25
|
+
it "finds layout file in a specific directory" do
|
26
|
+
Dir.mktmpdir do |tmpdir|
|
27
|
+
template_dir = Pathname.new(tmpdir)
|
28
|
+
layout_file = template_dir + "layout.html"
|
29
|
+
layout_file.write("<html><%= content %></html>")
|
30
|
+
|
31
|
+
result = Mint::Layout.find_in_directory(template_dir)
|
32
|
+
expect(result).to eq(layout_file)
|
33
|
+
expect(Mint::Layout.valid?(result)).to be true
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
it "returns nil when no layout file exists" do
|
38
|
+
Dir.mktmpdir do |tmpdir|
|
39
|
+
template_dir = Pathname.new(tmpdir)
|
40
|
+
result = Mint::Layout.find_in_directory(template_dir)
|
41
|
+
expect(result).to be_nil
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|