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.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -26
  3. data/README.md +117 -37
  4. data/bin/mint +2 -81
  5. data/config/templates/base/navigation.css +136 -0
  6. data/config/templates/base/print.css +152 -0
  7. data/config/templates/{reset.css → base/reset.css} +1 -1
  8. data/config/templates/base/style.css +117 -137
  9. data/config/templates/base/utilities.css +136 -0
  10. data/config/templates/base/variables.css +124 -0
  11. data/config/templates/basic/style.css +151 -0
  12. data/config/templates/default/layout.erb +33 -3
  13. data/config/templates/default/style.css +95 -164
  14. data/config/templates/magazine/style.css +383 -0
  15. data/config/templates/nord/style.css +105 -220
  16. data/config/templates/nord-dark/style.css +82 -263
  17. data/lib/mint/commandline/parse.rb +144 -0
  18. data/lib/mint/commandline/publish.rb +46 -0
  19. data/lib/mint/commandline/run.rb +30 -0
  20. data/lib/mint/config.rb +162 -0
  21. data/lib/mint/{css.rb → css_dsl.rb} +9 -9
  22. data/lib/mint/css_parser.rb +45 -25
  23. data/lib/mint/document.rb +250 -365
  24. data/lib/mint/document_tree.rb +163 -0
  25. data/lib/mint/exceptions.rb +2 -3
  26. data/lib/mint/helpers.rb +23 -180
  27. data/lib/mint/layout.rb +26 -9
  28. data/lib/mint/renderers/css_renderer.rb +32 -0
  29. data/lib/mint/renderers/erb_renderer.rb +11 -0
  30. data/lib/mint/renderers/markdown_renderer.rb +45 -0
  31. data/lib/mint/style.rb +21 -31
  32. data/lib/mint/template.rb +30 -0
  33. data/lib/mint/version.rb +1 -1
  34. data/lib/mint/workspace.rb +171 -0
  35. data/lib/mint.rb +44 -12
  36. data/man/mint.1 +85 -44
  37. data/spec/cli/README.md +2 -2
  38. data/spec/cli/argument_parsing_spec.rb +89 -147
  39. data/spec/cli/bin_integration_spec.rb +23 -243
  40. data/spec/cli/full_workflow_integration_spec.rb +99 -442
  41. data/spec/cli/original_style_integration_spec.rb +58 -0
  42. data/spec/cli/publish_workflow_spec.rb +72 -70
  43. data/spec/commandline_path_integration_spec.rb +230 -0
  44. data/spec/config_file_integration_spec.rb +362 -0
  45. data/spec/{css_spec.rb → css_dsl_spec.rb} +7 -3
  46. data/spec/css_parser_spec.rb +59 -1
  47. data/spec/document_spec.rb +37 -242
  48. data/spec/flattened_path_spec.rb +150 -0
  49. data/spec/layout_spec.rb +42 -3
  50. data/spec/mint_spec.rb +22 -217
  51. data/spec/path_handling_spec.rb +237 -0
  52. data/spec/run_cli_tests.rb +1 -1
  53. data/spec/spec_helper.rb +3 -10
  54. data/spec/style_spec.rb +31 -56
  55. data/spec/support/cli_helpers.rb +7 -10
  56. data/spec/support/matchers.rb +1 -1
  57. data/spec/template_spec.rb +31 -0
  58. data/spec/workspace_spec.rb +177 -0
  59. metadata +75 -89
  60. data/bin/mint-epub +0 -20
  61. data/config/templates/garden/layout.erb +0 -38
  62. data/config/templates/garden/style.css +0 -303
  63. data/config/templates/nord/layout.erb +0 -11
  64. data/config/templates/nord-dark/layout.erb +0 -11
  65. data/config/templates/zen/layout.erb +0 -11
  66. data/config/templates/zen/style.css +0 -114
  67. data/lib/mint/command_line.rb +0 -360
  68. data/lib/mint/css_template.rb +0 -37
  69. data/lib/mint/markdown_template.rb +0 -47
  70. data/lib/mint/mint.rb +0 -313
  71. data/lib/mint/plugin.rb +0 -136
  72. data/lib/mint/plugins/epub.rb +0 -293
  73. data/lib/mint/resource.rb +0 -101
  74. data/plugins/templates/epub/layouts/container.haml +0 -5
  75. data/plugins/templates/epub/layouts/content.haml +0 -35
  76. data/plugins/templates/epub/layouts/layout.haml +0 -6
  77. data/plugins/templates/epub/layouts/title.haml +0 -11
  78. data/plugins/templates/epub/layouts/toc.haml +0 -26
  79. data/spec/cli/configuration_management_spec.rb +0 -363
  80. data/spec/cli/template_management_spec.rb +0 -300
  81. data/spec/helpers_spec.rb +0 -249
  82. data/spec/plugin_spec.rb +0 -449
  83. data/spec/resource_spec.rb +0 -135
@@ -12,514 +12,171 @@ RSpec.describe "Full CLI Workflow Integration" do
12
12
 
13
13
  describe "new user getting started" do
14
14
  it "can set up a new project from scratch" do
15
- # 1. Initialize configuration
16
- expect {
17
- Mint::CommandLine.set("author", "Test User", :local)
18
- Mint::CommandLine.set("layout", "clean", :local)
19
- }.not_to raise_error
20
-
21
- # 2. Create a custom template
22
- layout_content = <<~HTML
23
- <!DOCTYPE html>
24
- <html lang="en">
25
- <head>
26
- <meta charset="UTF-8">
27
- <title>My Site</title>
28
- <% if style %>
29
- <link rel="stylesheet" href="<%= style %>">
30
- <% end %>
31
- </head>
32
- <body>
33
- <header>
34
- <h1>My Site</h1>
35
- </header>
36
- <main>
37
- <%= content %>
38
- </main>
39
- <footer>
40
- <p>&copy; 2024 Test User</p>
41
- </footer>
42
- </body>
43
- </html>
44
- HTML
45
-
46
- create_template_file("my-layout.erb", :layout, layout_content)
47
- Mint::CommandLine.install("my-layout.erb", "clean", :local)
48
-
49
- # 3. Create some content
50
- create_markdown_file("index.md", <<~MARKDOWN
15
+ # 1. Create configuration file manually (since set command was removed)
16
+ FileUtils.mkdir_p(".mint")
17
+ File.write(".mint/config.toml", <<~TOML)
18
+ layout = "default"
19
+ style = "default"
20
+ destination = "output"
21
+ TOML
22
+
23
+ # 2. Create content files
24
+ create_markdown_path("index.md", <<~MARKDOWN)
51
25
  # Welcome to My Site
52
26
 
53
- This is the homepage of my new site.
27
+ This is my new project built with Mint.
54
28
 
55
29
  ## Features
56
-
57
- - Clean design
58
- - Easy to maintain
59
- - Fast loading
60
-
61
- Check out my [about page](about.html).
30
+ - Simple Markdown processing
31
+ - Clean HTML output
32
+ - Customizable templates
62
33
  MARKDOWN
63
- )
64
34
 
65
- create_markdown_file("about.md", <<~MARKDOWN
66
- # About Me
67
-
68
- I'm a developer who loves simple, clean websites.
69
-
70
- ## Contact
71
-
72
- - Email: test@example.com
73
- - GitHub: @testuser
74
- MARKDOWN
75
- )
35
+ create_markdown_path("about.md", "# About\n\nThis is the about page.")
76
36
 
77
- # 4. Publish the site
37
+ # 3. Create output directory and publish
38
+ FileUtils.mkdir_p("output")
39
+ config = Mint::Config.with_defaults(destination_directory: Pathname.new("output"))
40
+
78
41
  expect {
79
- Mint::CommandLine.publish!(["index.md", "about.md"], {})
42
+ Mint::Commandline.publish!([Pathname.new("index.md"), Pathname.new("about.md")], config: config)
80
43
  }.not_to raise_error
81
44
 
82
- # 5. Verify everything worked
83
- expect(File.exist?("index.html")).to be true
84
- expect(File.exist?("about.html")).to be true
85
-
86
- index_content = File.read("index.html")
87
- expect(index_content).to include("<h1>My Site</h1>") # header
88
- expect(index_content).to include("Welcome to My Site") # content
89
- expect(index_content).to include("Test User") # footer
90
- expect(index_content).to include("about.html") # link
45
+ # 4. Verify output
46
+ expect(File.exist?("output/index.html")).to be true
47
+ expect(File.exist?("output/about.html")).to be true
91
48
 
92
- about_content = File.read("about.html")
93
- expect(about_content).to include("About Me")
94
- expect(about_content).to include("test@example.com")
49
+ # Check content
50
+ index_content = File.read("output/index.html")
51
+ expect(index_content).to include("<h1>Welcome to My Site</h1>")
52
+ expect(index_content).to include("<h2>Features</h2>")
95
53
  end
96
54
  end
97
55
 
98
56
  describe "documentation site workflow" do
99
57
  it "can build a multi-page documentation site" do
100
- # Create a documentation structure
101
- FileUtils.mkdir_p("docs/guides")
102
- FileUtils.mkdir_p("docs/api")
103
- FileUtils.mkdir_p("build")
104
-
105
- # Create navigation template
106
- nav_layout = <<~ERB
107
- <!DOCTYPE html>
108
- <html>
109
- <head>
110
- <title>Documentation</title>
111
- <style>
112
- body { font-family: sans-serif; margin: 0; }
113
- .container { display: flex; }
114
- .sidebar { width: 200px; background: #f5f5f5; padding: 1rem; }
115
- .content { flex: 1; padding: 1rem; }
116
- .nav-link { display: block; margin: 0.5rem 0; }
117
- </style>
118
- </head>
119
- <body>
120
- <div class="container">
121
- <nav class="sidebar">
122
- <h3>Documentation</h3>
123
- <% if defined?(all_files) && all_files %>
124
- <% all_files.each do |file| %>
125
- <% name = File.basename(file, '.md') %>
126
- <% path = file.gsub('.md', '.html') %>
127
- <a href="<%= path %>" class="nav-link"><%= name.tr('-', ' ').capitalize %></a>
128
- <% end %>
129
- <% end %>
130
- </nav>
131
- <main class="content">
132
- <%= content %>
133
- </main>
134
- </div>
135
- </body>
136
- </html>
137
- ERB
138
-
139
- FileUtils.mkdir_p(".mint/templates/docs")
140
- File.write(".mint/templates/docs/layout.erb", nav_layout)
141
-
142
- # Create documentation content
143
- create_markdown_file("docs/index.md", <<~MARKDOWN
144
- # Project Documentation
145
-
146
- Welcome to our comprehensive documentation.
147
-
148
- ## Getting Started
149
-
150
- See our [installation guide](guides/installation.html) to get up and running.
151
- MARKDOWN
152
- )
153
-
154
- create_markdown_file("docs/guides/installation.md", <<~MARKDOWN
155
- # Installation Guide
156
-
157
- ## Prerequisites
158
-
159
- - Ruby 2.7+
160
- - Git
161
-
162
- ## Steps
163
-
164
- 1. Clone the repository
165
- 2. Run `bundle install`
166
- 3. Run `mint publish`
167
- MARKDOWN
58
+ # Set up configuration for documentation
59
+ config = Mint::Config.with_defaults(
60
+ layout_name: "default",
61
+ style_name: "default",
62
+ destination_directory: Pathname.new("docs"),
63
+ preserve_structure: true # Preserve source structure
168
64
  )
169
65
 
170
- create_markdown_file("docs/api/overview.md", <<~MARKDOWN
171
- # API Overview
172
-
173
- Our API provides REST endpoints for all major operations.
174
-
175
- ## Authentication
176
-
177
- All requests require an API key in the header.
178
- MARKDOWN
179
- )
180
-
181
- # Configure for documentation
182
- Mint::CommandLine.set("layout", "docs", :local)
183
- Mint::CommandLine.set("destination", "build", :local)
66
+ # Create documentation structure
67
+ FileUtils.mkdir_p(["source/guides", "source/api", "docs"])
68
+
69
+ create_markdown_path("source/index.md", "# Documentation\n\nWelcome to our docs!")
70
+ create_markdown_path("source/guides/getting-started.md", "# Getting Started\n\nInstallation guide.")
71
+ create_markdown_path("source/guides/advanced.md", "# Advanced Usage\n\nAdvanced features.")
72
+ create_markdown_path("source/api/reference.md", "# API Reference\n\nComplete API docs.")
184
73
 
185
74
  # Publish all documentation
186
- files = ["docs/index.md", "docs/guides/installation.md", "docs/api/overview.md"]
187
- Mint::CommandLine.publish!(files, { recursive: false })
75
+ md_files = Dir.glob("source/**/*.md").map {|f| Pathname.new(f) }
76
+ expect {
77
+ Mint::Commandline.publish!(md_files, config: config)
78
+ }.not_to raise_error
188
79
 
189
- # Verify the documentation site
190
- expect(File.exist?("build/docs/index.html")).to be true
191
- expect(File.exist?("build/docs/guides/installation.html")).to be true
192
- expect(File.exist?("build/docs/api/overview.html")).to be true
80
+ # Verify structure is maintained (with autodrop applied)
81
+ expect(File.exist?("docs/index.html")).to be true
82
+ expect(File.exist?("docs/guides/getting-started.html")).to be true
83
+ expect(File.exist?("docs/guides/advanced.html")).to be true
84
+ expect(File.exist?("docs/api/reference.html")).to be true
193
85
 
194
- index_content = File.read("build/docs/index.html")
195
- expect(index_content).to include("Documentation") # nav
196
- expect(index_content).to include("installation") # nav link
197
- expect(index_content).to include("Project Documentation") # content
86
+ # Verify content
87
+ index_content = File.read("docs/index.html")
88
+ expect(index_content).to include("Welcome to our docs!")
198
89
  end
199
90
  end
200
91
 
201
92
  describe "blog workflow" do
202
93
  it "can manage a simple blog" do
203
- # Create blog structure
204
- FileUtils.mkdir_p("posts")
205
- FileUtils.mkdir_p("output")
206
-
207
- # Create blog template
208
- blog_layout = <<~ERB
209
- <!DOCTYPE html>
210
- <html>
211
- <head>
212
- <title>My Blog</title>
213
- <meta name="viewport" content="width=device-width, initial-scale=1">
214
- <style>
215
- body {
216
- max-width: 800px;
217
- margin: 0 auto;
218
- padding: 2rem;
219
- font-family: Georgia, serif;
220
- line-height: 1.6;
221
- }
222
- .header { border-bottom: 1px solid #eee; margin-bottom: 2rem; }
223
- .post-meta { color: #666; font-size: 0.9em; margin-bottom: 1rem; }
224
- .back-link { margin-top: 2rem; }
225
- </style>
226
- </head>
227
- <body>
228
- <header class="header">
229
- <h1><a href="index.html">My Blog</a></h1>
230
- </header>
231
- <article>
232
- <%= content %>
233
- </article>
234
- <div class="back-link">
235
- <a href="index.html">&larr; Back to all posts</a>
236
- </div>
237
- </body>
238
- </html>
239
- ERB
240
-
241
- FileUtils.mkdir_p(".mint/templates/blog")
242
- File.write(".mint/templates/blog/layout.erb", blog_layout)
243
-
244
- # Create blog posts
245
- create_markdown_file("posts/2024-01-15-first-post.md", <<~MARKDOWN
246
- # My First Blog Post
247
-
248
- <div class="post-meta">January 15, 2024</div>
249
-
250
- Welcome to my new blog! I'm excited to share my thoughts on:
251
-
252
- - Web development
253
- - Ruby programming
254
- - Life and code
255
-
256
- Stay tuned for more posts!
257
- MARKDOWN
94
+ # Set up blog configuration
95
+ config = Mint::Config.with_defaults(
96
+ layout_name: "default",
97
+ destination_directory: Pathname.new("blog"),
98
+ preserve_structure: true # Preserve posts/ structure
258
99
  )
259
100
 
260
- create_markdown_file("posts/2024-01-20-learning-mint.md", <<~MARKDOWN
261
- # Learning Mint for Static Sites
262
-
263
- <div class="post-meta">January 20, 2024</div>
264
-
265
- I've been exploring Mint for generating static sites. Here's what I've learned:
266
-
267
- ## Why Static Sites?
268
-
269
- - Fast loading
270
- - Easy hosting
271
- - Version control friendly
272
-
273
- ## Getting Started with Mint
274
-
275
- The process is straightforward...
276
- MARKDOWN
277
- )
278
-
279
- # Create an index page
280
- create_markdown_file("index.md", <<~MARKDOWN
281
- # Welcome to My Blog
282
-
283
- Recent posts:
284
-
285
- - [Learning Mint for Static Sites](posts/2024-01-20-learning-mint.html) - January 20, 2024
286
- - [My First Blog Post](posts/2024-01-15-first-post.html) - January 15, 2024
287
- MARKDOWN
288
- )
289
-
290
- # Configure and publish
291
- Mint::CommandLine.configure({
292
- "layout" => "blog",
293
- "destination" => "output"
294
- }, :local)
295
-
296
- # Publish all content
297
- files = Dir.glob("posts/*.md") + ["index.md"]
298
- Mint::CommandLine.publish!(files, {})
299
-
300
- # Verify blog structure
301
- expect(File.exist?("output/index.html")).to be true
302
- expect(File.exist?("output/posts/2024-01-15-first-post.html")).to be true
303
- expect(File.exist?("output/posts/2024-01-20-learning-mint.html")).to be true
304
-
305
- # Check content
306
- index_content = File.read("output/index.html")
307
- expect(index_content).to include("My Blog")
308
- expect(index_content).to include("Recent posts")
309
-
310
- post_content = File.read("output/posts/2024-01-15-first-post.html")
311
- expect(post_content).to include("My First Blog Post")
312
- expect(post_content).to include("January 15, 2024")
313
- expect(post_content).to include("Back to all posts")
314
- end
315
- end
316
-
317
- describe "team collaboration workflow" do
318
- it "supports shared templates and configuration" do
319
- # Simulate a team setup with shared templates
320
-
321
- # 1. Set up shared template (simulating user scope)
322
- shared_template = <<~ERB
323
- <!DOCTYPE html>
324
- <html>
325
- <head>
326
- <title>Company Documentation</title>
327
- <style>
328
- body { font-family: 'Helvetica', sans-serif; }
329
- .company-header { background: #003366; color: white; padding: 1rem; }
330
- .content { padding: 2rem; }
331
- </style>
332
- </head>
333
- <body>
334
- <header class="company-header">
335
- <h1>Acme Corp Documentation</h1>
336
- </header>
337
- <div class="content">
338
- <%= content %>
339
- </div>
340
- </body>
341
- </html>
342
- ERB
343
-
344
- # Create company template
345
- FileUtils.mkdir_p(".mint/templates/company")
346
- File.write(".mint/templates/company/layout.erb", shared_template)
347
-
348
- # 2. Individual developer customizes local config
349
- Mint::CommandLine.configure({
350
- "layout" => "company",
351
- "author" => "Alice Developer",
352
- "destination" => "team-docs"
353
- }, :local)
354
-
355
- # 3. Create team documentation
356
- FileUtils.mkdir_p("team-docs")
357
-
358
- create_markdown_file("project-overview.md", <<~MARKDOWN
359
- # Project Overview
360
-
361
- ## Architecture
362
-
363
- Our system consists of three main components:
364
-
365
- 1. Frontend (React)
366
- 2. Backend (Rails API)
367
- 3. Database (PostgreSQL)
368
-
369
- ## Deployment
370
-
371
- We use Docker for containerization and deploy to AWS.
372
- MARKDOWN
373
- )
374
-
375
- # 4. Publish with team template
376
- Mint::CommandLine.publish!(["project-overview.md"], {})
377
-
378
- # 5. Verify team branding is applied
379
- expect(File.exist?("team-docs/project-overview.html")).to be true
101
+ # Create blog structure
102
+ FileUtils.mkdir_p(["posts", "blog"])
380
103
 
381
- content = File.read("team-docs/project-overview.html")
382
- expect(content).to include("Acme Corp Documentation")
383
- expect(content).to include("company-header")
384
- expect(content).to include("Project Overview")
385
- end
386
- end
387
-
388
- describe "migration and maintenance workflows" do
389
- it "can migrate templates and preserve content" do
390
- # Start with old template
391
- old_template = "<html><body><%= content %></body></html>"
392
- create_template_file("old.erb", :layout, old_template)
393
- Mint::CommandLine.install("old.erb", "v1", :local)
394
-
395
- # Create content with old template
396
- create_markdown_file("document.md", "# My Document\n\nContent here.")
397
- Mint::CommandLine.publish!(["document.md"], { layout: "v1" })
398
-
399
- old_content = File.read("document.html")
400
- expect(old_content).to include("My Document")
104
+ create_markdown_path("index.md", "# My Blog\n\nWelcome to my thoughts!")
105
+ create_markdown_path("posts/2023-01-01-hello-world.md", "# Hello World\n\nMy first post.")
106
+ create_markdown_path("posts/2023-02-15-update.md", "# February Update\n\nWhat I've been up to.")
401
107
 
402
- # Create new, improved template
403
- new_template = <<~ERB
404
- <!DOCTYPE html>
405
- <html lang="en">
406
- <head>
407
- <meta charset="UTF-8">
408
- <title>Documentation</title>
409
- </head>
410
- <body>
411
- <div class="container">
412
- <%= content %>
413
- </div>
414
- </body>
415
- </html>
416
- ERB
417
-
418
- create_template_file("new.erb", :layout, new_template)
419
- Mint::CommandLine.install("new.erb", "v2", :local)
420
-
421
- # Migrate to new template
422
- Mint::CommandLine.publish!(["document.md"], { layout: "v2" })
108
+ # Publish blog
109
+ blog_files = [Pathname.new("index.md")] + Dir.glob("posts/*.md").map {|f| Pathname.new(f) }
110
+ expect {
111
+ Mint::Commandline.publish!(blog_files, config: config)
112
+ }.not_to raise_error
423
113
 
424
- new_content = File.read("document.html")
425
- expect(new_content).to include("My Document") # content preserved
426
- expect(new_content).to include("<!DOCTYPE html>") # new template features
427
- expect(new_content).to include("container") # new styling
114
+ # Verify blog structure
115
+ expect(File.exist?("blog/index.html")).to be true
116
+ expect(File.exist?("blog/posts/2023-01-01-hello-world.html")).to be true
117
+ expect(File.exist?("blog/posts/2023-02-15-update.html")).to be true
428
118
  end
429
119
  end
430
120
 
431
121
  describe "error recovery workflows" do
432
122
  it "can recover from and fix common mistakes" do
433
- # 1. Try to use non-existent template (common mistake)
434
- create_markdown_file("test.md", "# Test")
123
+ create_markdown_path("test.md", "# Test")
435
124
 
125
+ # Test error when nonexistent style is specified
436
126
  expect {
437
- Mint::CommandLine.publish!(["test.md"], { layout: "nonexistent" })
438
- }.to raise_error(Mint::TemplateNotFoundException)
439
-
440
- # 2. Create the missing template
441
- allow(STDIN).to receive(:gets).and_return("y\n") # auto-create
442
- silence_output do
443
- mock_editor do
444
- Mint::CommandLine.edit("nonexistent", :layout, :local)
445
- end
446
- end
127
+ Mint::Commandline.publish!([Pathname.new("test.md")], config: Mint::Config.with_defaults(style_name: "nonexistent"))
128
+ }.to raise_error(Mint::StyleNotFoundException)
447
129
 
448
- # 3. Now publishing should work
130
+ # Recovery: Use existing layout
449
131
  expect {
450
- Mint::CommandLine.publish!(["test.md"], { layout: "nonexistent" })
132
+ Mint::Commandline.publish!([Pathname.new("test.md")], config: Mint::Config.with_defaults(layout_name: "default"))
451
133
  }.not_to raise_error
452
134
 
453
135
  expect(File.exist?("test.html")).to be true
454
136
  end
455
137
 
456
138
  it "handles corrupted configuration gracefully" do
457
- # Create corrupted config
139
+ # Create corrupted config file
458
140
  FileUtils.mkdir_p(".mint")
459
- File.write(".mint/config.yaml", "invalid: yaml: content: [")
141
+ File.write(".mint/config.toml", "invalid = toml content [")
460
142
 
461
- # Should still be able to set new config
143
+ create_markdown_path("test.md", "# Test")
144
+
145
+ # Should still work with explicit config
462
146
  expect {
463
- Mint::CommandLine.set("layout", "recovery", :local)
147
+ Mint::Commandline.publish!([Pathname.new("test.md")], config: Mint::Config.defaults)
464
148
  }.not_to raise_error
465
149
 
466
- # Config should now be valid
467
- config = YAML.load_file(".mint/config.yaml")
468
- expect(config["layout"]).to eq("recovery")
150
+ expect(File.exist?("test.html")).to be true
469
151
  end
470
152
  end
471
153
 
472
154
  describe "performance with large projects" do
473
155
  it "handles many files efficiently" do
474
- # Create a larger number of files
475
- FileUtils.mkdir_p("large-project")
476
- setup_basic_config
477
- create_template_directory("default")
478
-
156
+ # Create many files
479
157
  files = []
480
- 20.times do |i|
481
- file = "large-project/page-#{i.to_s.rjust(3, '0')}.md"
482
- content = <<~MARKDOWN
483
- # Page #{i}
484
-
485
- This is page number #{i} in our large project.
486
-
487
- ## Content
488
-
489
- #{'Lorem ipsum dolor sit amet. ' * 10}
490
-
491
- ## Links
492
-
493
- - [Previous](page-#{'%03d' % (i-1)}.html) #{i > 0 ? '' : '(none)'}
494
- - [Next](page-#{'%03d' % (i+1)}.html) #{i < 19 ? '' : '(none)'}
495
- MARKDOWN
496
-
497
- create_markdown_file(file, content)
498
- files << file
158
+ (1..50).each do |i|
159
+ filename = "doc#{i}.md"
160
+ create_markdown_path(filename, "# Document #{i}\n\nContent for document #{i}.")
161
+ files << Pathname.new(filename)
499
162
  end
500
163
 
501
- # Publish all files and measure time
164
+ config = Mint::Config.defaults
165
+
166
+ # Measure performance
502
167
  start_time = Time.now
503
-
504
168
  expect {
505
- Mint::CommandLine.publish!(files, {})
169
+ Mint::Commandline.publish!(files, config: config)
506
170
  }.not_to raise_error
507
-
508
171
  end_time = Time.now
509
- duration = end_time - start_time
510
172
 
511
- # Verify all files were created
512
- 20.times do |i|
513
- expect(File.exist?("large-project/page-#{'%03d' % i}.html")).to be true
514
- end
515
-
516
- # Should complete in reasonable time (adjust as needed)
517
- expect(duration).to be < 10.0
173
+ # Should complete in reasonable time (less than 30 seconds for 50 files)
174
+ expect(end_time - start_time).to be < 30
518
175
 
519
- # Verify content quality isn't compromised
520
- sample_content = File.read("large-project/page-010.html")
521
- expect(sample_content).to include("Page 10")
522
- expect(sample_content).to include("Lorem ipsum")
176
+ # Verify all files were processed
177
+ (1..50).each do |i|
178
+ expect(File.exist?("doc#{i}.html")).to be true
179
+ end
523
180
  end
524
181
  end
525
182
  end
@@ -0,0 +1,58 @@
1
+ require "spec_helper"
2
+
3
+ describe "Original style mode integration" 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 "with --style-mode original" do
14
+ it "works with built-in templates in original mode" do
15
+ create_markdown_path("test.md", "# Test Document\n\nThis is a test.")
16
+
17
+ # Create output directory structure
18
+ Dir.chdir(@test_dir) do
19
+ config = Mint::Config.with_defaults(
20
+ style_mode: :original,
21
+ layout_name: "default",
22
+ style_name: "default"
23
+ )
24
+
25
+ expect {
26
+ Mint::Commandline.publish!([Pathname.new("test.md")], config: config)
27
+ }.not_to raise_error
28
+
29
+ expect(File.exist?("test.html")).to be true
30
+
31
+ content = File.read("test.html")
32
+ expect(content).to include("<h1>Test Document</h1>")
33
+ expect(content).to include("<p>This is a test.</p>")
34
+ end
35
+ end
36
+
37
+ it "correctly outputs original style mode with different templates" do
38
+ create_markdown_path("test.md", "# Nord Test\n\nTesting with Nord theme.")
39
+ create_template_directory("nord")
40
+
41
+ Dir.chdir(@test_dir) do
42
+ config = Mint::Config.with_defaults(
43
+ style_mode: :original,
44
+ layout_name: "nord",
45
+ style_name: "nord"
46
+ )
47
+
48
+ # Should work with any template that exists, or fall back gracefully
49
+ expect {
50
+ Mint::Commandline.publish!([Pathname.new("test.md")], config: config)
51
+ }.not_to raise_error
52
+
53
+ expect(File.exist?("test.html")).to be true
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end