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
@@ -0,0 +1,362 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe "Config File Integration" do
|
4
|
+
include CLIHelpers
|
5
|
+
|
6
|
+
|
7
|
+
describe "TOML config file support" do
|
8
|
+
context "with local config file" do
|
9
|
+
# Note: Tests run in tmp directory from spec_helper
|
10
|
+
|
11
|
+
before do
|
12
|
+
FileUtils.mkdir_p(".mint") # Ensure directory exists for each test
|
13
|
+
end
|
14
|
+
|
15
|
+
after do
|
16
|
+
cleanup_test_files("*.html", "*.css")
|
17
|
+
# Don't clean up .mint directory - let spec_helper handle it
|
18
|
+
end
|
19
|
+
|
20
|
+
it "loads template option from config file" do
|
21
|
+
File.write(".mint/config.toml", <<~TOML)
|
22
|
+
template = "custom"
|
23
|
+
TOML
|
24
|
+
|
25
|
+
command, config, files, help = Mint::Commandline.parse!(["publish", "test.md"])
|
26
|
+
|
27
|
+
expect(config.layout_name).to eq("custom")
|
28
|
+
expect(config.style_name).to eq("custom")
|
29
|
+
end
|
30
|
+
|
31
|
+
it "loads layout option from config file" do
|
32
|
+
File.write(".mint/config.toml", <<~TOML)
|
33
|
+
layout = "minimal"
|
34
|
+
TOML
|
35
|
+
|
36
|
+
command, config, files, help = Mint::Commandline.parse!(["publish", "test.md"])
|
37
|
+
|
38
|
+
expect(config.layout_name).to eq("minimal")
|
39
|
+
end
|
40
|
+
|
41
|
+
it "loads style option from config file" do
|
42
|
+
File.write(".mint/config.toml", <<~TOML)
|
43
|
+
style = "dark"
|
44
|
+
TOML
|
45
|
+
|
46
|
+
command, config, files, help = Mint::Commandline.parse!(["publish", "test.md"])
|
47
|
+
|
48
|
+
expect(config.style_name).to eq("dark")
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
it "loads output-file option from config file" do
|
53
|
+
File.write(".mint/config.toml", <<~TOML)
|
54
|
+
output-file = "%{ext}_custom.%{ext}"
|
55
|
+
TOML
|
56
|
+
|
57
|
+
command, config, files, help = Mint::Commandline.parse!(["publish", "test.md"])
|
58
|
+
|
59
|
+
expect(config.output_file_format).to eq("%{ext}_custom.%{ext}")
|
60
|
+
end
|
61
|
+
|
62
|
+
it "loads destination option from config file" do
|
63
|
+
File.write(".mint/config.toml", <<~TOML)
|
64
|
+
destination = "build"
|
65
|
+
TOML
|
66
|
+
|
67
|
+
command, config, files, help = Mint::Commandline.parse!(["publish", "test.md"])
|
68
|
+
|
69
|
+
expect(config.destination_directory).to eq(Pathname.new("build"))
|
70
|
+
end
|
71
|
+
|
72
|
+
it "loads style-mode option from config file" do
|
73
|
+
File.write(".mint/config.toml", <<~TOML)
|
74
|
+
style-mode = "external"
|
75
|
+
TOML
|
76
|
+
|
77
|
+
command, config, files, help = Mint::Commandline.parse!(["publish", "test.md"])
|
78
|
+
|
79
|
+
expect(config.style_mode).to eq(:external)
|
80
|
+
end
|
81
|
+
|
82
|
+
it "loads style-destination option from config file" do
|
83
|
+
File.write(".mint/config.toml", <<~TOML)
|
84
|
+
style-destination = "assets/css"
|
85
|
+
TOML
|
86
|
+
|
87
|
+
command, config, files, help = Mint::Commandline.parse!(["publish", "test.md"])
|
88
|
+
|
89
|
+
expect(config.style_destination_directory).to eq("assets/css")
|
90
|
+
end
|
91
|
+
|
92
|
+
it "loads preserve-structure option from config file" do
|
93
|
+
File.write(".mint/config.toml", <<~TOML)
|
94
|
+
preserve-structure = true
|
95
|
+
TOML
|
96
|
+
|
97
|
+
command, config, files, help = Mint::Commandline.parse!(["publish", "test.md"])
|
98
|
+
|
99
|
+
expect(config.preserve_structure).to be true
|
100
|
+
end
|
101
|
+
|
102
|
+
it "loads navigation option from config file" do
|
103
|
+
File.write(".mint/config.toml", <<~TOML)
|
104
|
+
navigation = true
|
105
|
+
TOML
|
106
|
+
|
107
|
+
command, config, files, help = Mint::Commandline.parse!(["publish", "test.md"])
|
108
|
+
|
109
|
+
expect(config.navigation).to be true
|
110
|
+
end
|
111
|
+
|
112
|
+
|
113
|
+
it "loads navigation-depth option from config file" do
|
114
|
+
File.write(".mint/config.toml", <<~TOML)
|
115
|
+
navigation-depth = 5
|
116
|
+
TOML
|
117
|
+
|
118
|
+
command, config, files, help = Mint::Commandline.parse!(["publish", "test.md"])
|
119
|
+
|
120
|
+
expect(config.navigation_depth).to eq(5)
|
121
|
+
end
|
122
|
+
|
123
|
+
it "loads navigation-title option from config file" do
|
124
|
+
File.write(".mint/config.toml", <<~TOML)
|
125
|
+
navigation-title = "Custom Navigation"
|
126
|
+
TOML
|
127
|
+
|
128
|
+
command, config, files, help = Mint::Commandline.parse!(["publish", "test.md"])
|
129
|
+
|
130
|
+
expect(config.navigation_title).to eq("Custom Navigation")
|
131
|
+
end
|
132
|
+
|
133
|
+
it "loads autodrop option from config file" do
|
134
|
+
File.write(".mint/config.toml", <<~TOML)
|
135
|
+
autodrop = false
|
136
|
+
TOML
|
137
|
+
|
138
|
+
command, config, files, help = Mint::Commandline.parse!(["publish", "test.md"])
|
139
|
+
|
140
|
+
expect(config.autodrop).to be false
|
141
|
+
end
|
142
|
+
|
143
|
+
it "loads insert-title-heading option from config file" do
|
144
|
+
File.write(".mint/config.toml", <<~TOML)
|
145
|
+
insert-title-heading = true
|
146
|
+
TOML
|
147
|
+
|
148
|
+
command, config, files, help = Mint::Commandline.parse!(["publish", "test.md"])
|
149
|
+
|
150
|
+
expect(config.insert_title_heading).to be true
|
151
|
+
end
|
152
|
+
|
153
|
+
it "loads multiple options from config file" do
|
154
|
+
File.write(".mint/config.toml", <<~TOML)
|
155
|
+
template = "blog"
|
156
|
+
destination = "public"
|
157
|
+
style-mode = "external"
|
158
|
+
preserve-structure = true
|
159
|
+
navigation = true
|
160
|
+
navigation-depth = 2
|
161
|
+
insert-title-heading = true
|
162
|
+
TOML
|
163
|
+
|
164
|
+
command, config, files, help = Mint::Commandline.parse!(["publish", "test.md"])
|
165
|
+
|
166
|
+
expect(config.layout_name).to eq("blog")
|
167
|
+
expect(config.style_name).to eq("blog")
|
168
|
+
expect(config.destination_directory).to eq(Pathname.new("public"))
|
169
|
+
expect(config.style_mode).to eq(:external)
|
170
|
+
expect(config.preserve_structure).to be true
|
171
|
+
expect(config.navigation).to be true
|
172
|
+
expect(config.navigation_depth).to eq(2)
|
173
|
+
expect(config.insert_title_heading).to be true
|
174
|
+
end
|
175
|
+
|
176
|
+
context "command-line options override config file" do
|
177
|
+
before do
|
178
|
+
File.write(".mint/config.toml", <<~TOML)
|
179
|
+
template = "config"
|
180
|
+
destination = "config-dest"
|
181
|
+
style-mode = "external"
|
182
|
+
preserve-structure = true
|
183
|
+
navigation-depth = 5
|
184
|
+
TOML
|
185
|
+
end
|
186
|
+
|
187
|
+
it "command-line template overrides config file template" do
|
188
|
+
command, config, files, help = Mint::Commandline.parse!(["publish", "--template", "cli", "test.md"])
|
189
|
+
|
190
|
+
expect(config.layout_name).to eq("cli")
|
191
|
+
expect(config.style_name).to eq("cli")
|
192
|
+
end
|
193
|
+
|
194
|
+
it "command-line layout overrides config file template layout" do
|
195
|
+
command, config, files, help = Mint::Commandline.parse!(["publish", "--layout", "cli-layout", "test.md"])
|
196
|
+
|
197
|
+
expect(config.layout_name).to eq("cli-layout")
|
198
|
+
expect(config.style_name).to eq("config") # should still use config for style
|
199
|
+
end
|
200
|
+
|
201
|
+
it "command-line destination overrides config file destination" do
|
202
|
+
command, config, files, help = Mint::Commandline.parse!(["publish", "--destination", "cli-dest", "test.md"])
|
203
|
+
|
204
|
+
expect(config.destination_directory).to eq(Pathname.new("cli-dest"))
|
205
|
+
end
|
206
|
+
|
207
|
+
it "command-line style-mode overrides config file style-mode" do
|
208
|
+
command, config, files, help = Mint::Commandline.parse!(["publish", "--style-mode", "inline", "test.md"])
|
209
|
+
|
210
|
+
expect(config.style_mode).to eq(:inline)
|
211
|
+
end
|
212
|
+
|
213
|
+
it "command-line preserve-structure overrides config file preserve-structure" do
|
214
|
+
command, config, files, help = Mint::Commandline.parse!(["publish", "test.md"])
|
215
|
+
|
216
|
+
expect(config.preserve_structure).to be true # from config
|
217
|
+
end
|
218
|
+
|
219
|
+
it "command-line navigation-depth overrides config file navigation-depth" do
|
220
|
+
command, config, files, help = Mint::Commandline.parse!(["publish", "--navigation-depth", "3", "test.md"])
|
221
|
+
|
222
|
+
expect(config.navigation_depth).to eq(3)
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
context "--no- flags override config file boolean values" do
|
227
|
+
before do
|
228
|
+
File.write(".mint/config.toml", <<~TOML)
|
229
|
+
preserve-structure = true
|
230
|
+
navigation = true
|
231
|
+
insert-title-heading = true
|
232
|
+
TOML
|
233
|
+
end
|
234
|
+
|
235
|
+
it "--no-preserve-structure overrides config file preserve-structure=true" do
|
236
|
+
command, config, files, help = Mint::Commandline.parse!(["publish", "--no-preserve-structure", "test.md"])
|
237
|
+
|
238
|
+
expect(config.preserve_structure).to be false
|
239
|
+
end
|
240
|
+
|
241
|
+
it "--no-navigation overrides config file navigation=true" do
|
242
|
+
command, config, files, help = Mint::Commandline.parse!(["publish", "--no-navigation", "test.md"])
|
243
|
+
|
244
|
+
expect(config.navigation).to be false
|
245
|
+
end
|
246
|
+
|
247
|
+
it "--no-insert-title-heading overrides config file insert-title-heading=true" do
|
248
|
+
command, config, files, help = Mint::Commandline.parse!(["publish", "--no-insert-title-heading", "test.md"])
|
249
|
+
|
250
|
+
expect(config.insert_title_heading).to be false
|
251
|
+
end
|
252
|
+
|
253
|
+
it "positive flags still work to override config file false values" do
|
254
|
+
File.write(".mint/config.toml", <<~TOML)
|
255
|
+
preserve-structure = false
|
256
|
+
navigation = false
|
257
|
+
insert-title-heading = false
|
258
|
+
TOML
|
259
|
+
|
260
|
+
command, config, files, help = Mint::Commandline.parse!(["publish", "--preserve-structure", "--navigation", "--insert-title-heading", "test.md"])
|
261
|
+
|
262
|
+
expect(config.preserve_structure).to be true
|
263
|
+
expect(config.navigation).to be true
|
264
|
+
expect(config.insert_title_heading).to be true
|
265
|
+
end
|
266
|
+
|
267
|
+
it "combines positive and negative flags" do
|
268
|
+
command, config, files, help = Mint::Commandline.parse!(["publish", "--preserve-structure", "--no-navigation", "test.md"])
|
269
|
+
|
270
|
+
expect(config.preserve_structure).to be true # overridden by CLI flag
|
271
|
+
expect(config.navigation).to be false # overridden by --no- flag
|
272
|
+
expect(config.insert_title_heading).to be true # from config file
|
273
|
+
end
|
274
|
+
end
|
275
|
+
|
276
|
+
it "handles boolean values correctly" do
|
277
|
+
File.write(".mint/config.toml", <<~TOML)
|
278
|
+
preserve-structure = false
|
279
|
+
navigation = false
|
280
|
+
insert-title-heading = false
|
281
|
+
TOML
|
282
|
+
|
283
|
+
command, config, files, help = Mint::Commandline.parse!(["publish", "test.md"])
|
284
|
+
|
285
|
+
expect(config.preserve_structure).to be false
|
286
|
+
expect(config.navigation).to be false
|
287
|
+
expect(config.insert_title_heading).to be false
|
288
|
+
end
|
289
|
+
|
290
|
+
it "handles integer values correctly" do
|
291
|
+
File.write(".mint/config.toml", <<~TOML)
|
292
|
+
navigation-depth = 10
|
293
|
+
TOML
|
294
|
+
|
295
|
+
command, config, files, help = Mint::Commandline.parse!(["publish", "test.md"])
|
296
|
+
|
297
|
+
expect(config.navigation_depth).to eq(10)
|
298
|
+
end
|
299
|
+
|
300
|
+
it "handles missing config file gracefully" do
|
301
|
+
command, config, files, help = Mint::Commandline.parse!(["publish", "test.md"])
|
302
|
+
|
303
|
+
expect(config.layout_name).to eq("default")
|
304
|
+
expect(config.style_name).to eq("default")
|
305
|
+
expect(config.preserve_structure).to be true
|
306
|
+
expect(config.navigation).to be false
|
307
|
+
end
|
308
|
+
|
309
|
+
it "handles empty config file gracefully" do
|
310
|
+
File.write(".mint/config.toml", "")
|
311
|
+
|
312
|
+
command, config, files, help = Mint::Commandline.parse!(["publish", "test.md"])
|
313
|
+
|
314
|
+
expect(config.layout_name).to eq("default")
|
315
|
+
expect(config.style_name).to eq("default")
|
316
|
+
end
|
317
|
+
|
318
|
+
it "handles config file with comments" do
|
319
|
+
File.write(".mint/config.toml", <<~TOML)
|
320
|
+
# This is a comment
|
321
|
+
template = "documented" # inline comment
|
322
|
+
|
323
|
+
# Another section
|
324
|
+
destination = "output" # destination comment
|
325
|
+
TOML
|
326
|
+
|
327
|
+
command, config, files, help = Mint::Commandline.parse!(["publish", "test.md"])
|
328
|
+
|
329
|
+
expect(config.layout_name).to eq("documented")
|
330
|
+
expect(config.style_name).to eq("documented")
|
331
|
+
expect(config.destination_directory).to eq(Pathname.new("output"))
|
332
|
+
end
|
333
|
+
end
|
334
|
+
|
335
|
+
context "config file scope priority" do
|
336
|
+
before do
|
337
|
+
FileUtils.mkdir_p(".mint")
|
338
|
+
FileUtils.mkdir_p(File.expand_path("~/.config/mint"))
|
339
|
+
end
|
340
|
+
|
341
|
+
after do
|
342
|
+
cleanup_test_files(".mint", File.expand_path("~/.config/mint/config.toml"))
|
343
|
+
end
|
344
|
+
|
345
|
+
it "local config overrides user config" do
|
346
|
+
File.write(File.expand_path("~/.config/mint/config.toml"), <<~TOML)
|
347
|
+
template = "user"
|
348
|
+
destination = "user-dest"
|
349
|
+
TOML
|
350
|
+
|
351
|
+
File.write(".mint/config.toml", <<~TOML)
|
352
|
+
template = "local"
|
353
|
+
TOML
|
354
|
+
|
355
|
+
command, config, files, help = Mint::Commandline.parse!(["publish", "test.md"])
|
356
|
+
|
357
|
+
expect(config.layout_name).to eq("local") # local overrides user
|
358
|
+
expect(config.destination_directory).to eq(Pathname.new("user-dest")) # user config still applies for non-overridden values
|
359
|
+
end
|
360
|
+
end
|
361
|
+
end
|
362
|
+
end
|
@@ -31,15 +31,19 @@ module Mint
|
|
31
31
|
# "Bullet: checkbox.png" => "li { list-style-image: url(checkbox.png) }",
|
32
32
|
}
|
33
33
|
|
34
|
-
table.each do |human,
|
35
|
-
|
34
|
+
table.each do |human, expected|
|
35
|
+
key, value = human.split(":").map(&:strip)
|
36
|
+
actual = CSS.stylify(key, value)
|
37
|
+
expect(actual).to eq(expected), "Expected '#{human}' to produce '#{expected}', got '#{actual}'"
|
36
38
|
end
|
37
39
|
end
|
38
40
|
end
|
39
41
|
|
40
42
|
describe ".parse" do
|
41
43
|
it "transforms a map of human-readable styles into a CSS string" do
|
42
|
-
|
44
|
+
result = CSS.parse({ "Font" => "Helvetica" })
|
45
|
+
expect(result).to include("container")
|
46
|
+
expect(result).to include("font-family: Helvetica")
|
43
47
|
end
|
44
48
|
end
|
45
49
|
end
|
data/spec/css_parser_spec.rb
CHANGED
@@ -39,6 +39,31 @@ describe Mint::CssParser do
|
|
39
39
|
imports = Mint::CssParser.extract_imports(css)
|
40
40
|
expect(imports).to eq([])
|
41
41
|
end
|
42
|
+
|
43
|
+
it "ignores commented out @import statements" do
|
44
|
+
css = <<~CSS
|
45
|
+
/* @import "commented.css"; */
|
46
|
+
@import "active.css";
|
47
|
+
body {
|
48
|
+
/* @import url("also-commented.css"); */
|
49
|
+
margin: 0;
|
50
|
+
}
|
51
|
+
CSS
|
52
|
+
imports = Mint::CssParser.extract_imports(css)
|
53
|
+
expect(imports).to eq(["active.css"])
|
54
|
+
end
|
55
|
+
|
56
|
+
it "ignores multi-line commented imports" do
|
57
|
+
css = <<~CSS
|
58
|
+
/*
|
59
|
+
* @import "multi-line-comment.css";
|
60
|
+
* @import 'another-commented.css';
|
61
|
+
*/
|
62
|
+
@import "valid.css";
|
63
|
+
CSS
|
64
|
+
imports = Mint::CssParser.extract_imports(css)
|
65
|
+
expect(imports).to eq(["valid.css"])
|
66
|
+
end
|
42
67
|
end
|
43
68
|
|
44
69
|
describe ".resolve_css_files" do
|
@@ -90,7 +115,7 @@ describe Mint::CssParser do
|
|
90
115
|
File.write(reset_css, "* { box-sizing: border-box; }")
|
91
116
|
|
92
117
|
css_files = Mint::CssParser.resolve_css_files(main_css, html_output)
|
93
|
-
expect(css_files).to eq(["../css/
|
118
|
+
expect(css_files).to eq(["../css/reset.css", "../css/main.css"])
|
94
119
|
end
|
95
120
|
|
96
121
|
it "ignores non-existent imported files" do
|
@@ -120,6 +145,39 @@ describe Mint::CssParser do
|
|
120
145
|
css_files = Mint::CssParser.resolve_css_files(main_scss, html_output)
|
121
146
|
expect(css_files).to eq(["../scss/main.scss"])
|
122
147
|
end
|
148
|
+
|
149
|
+
it "places imported CSS files before main CSS file for correct cascade order" do
|
150
|
+
# Create directory structure:
|
151
|
+
# temp_dir/
|
152
|
+
# css/
|
153
|
+
# base.css (imports reset.css and fonts.css)
|
154
|
+
# reset.css
|
155
|
+
# fonts.css
|
156
|
+
# output/
|
157
|
+
# index.html
|
158
|
+
|
159
|
+
css_dir = File.join(temp_dir, "css")
|
160
|
+
output_dir = File.join(temp_dir, "output")
|
161
|
+
FileUtils.mkdir_p([css_dir, output_dir])
|
162
|
+
|
163
|
+
base_css = File.join(css_dir, "base.css")
|
164
|
+
reset_css = File.join(css_dir, "reset.css")
|
165
|
+
fonts_css = File.join(css_dir, "fonts.css")
|
166
|
+
html_output = File.join(output_dir, "index.html")
|
167
|
+
|
168
|
+
File.write(base_css, '@import "reset.css"; @import "fonts.css"; body { margin: 0; }')
|
169
|
+
File.write(reset_css, "* { box-sizing: border-box; }")
|
170
|
+
File.write(fonts_css, "@font-face { font-family: 'MyFont'; }")
|
171
|
+
|
172
|
+
css_files = Mint::CssParser.resolve_css_files(base_css, html_output)
|
173
|
+
|
174
|
+
# Imports should come first, then the main file
|
175
|
+
expect(css_files).to eq([
|
176
|
+
"../css/reset.css",
|
177
|
+
"../css/fonts.css",
|
178
|
+
"../css/base.css"
|
179
|
+
])
|
180
|
+
end
|
123
181
|
end
|
124
182
|
|
125
183
|
describe ".generate_link_tags" do
|