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.
Files changed (71) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +23 -14
  3. data/LICENSE +22 -0
  4. data/README.md +82 -56
  5. data/bin/mint +47 -10
  6. data/bin/mint-epub +1 -4
  7. data/config/templates/base/style.css +187 -0
  8. data/config/templates/default/css/style.css +126 -79
  9. data/config/templates/default/layout.erb +10 -0
  10. data/config/templates/default/style.css +237 -0
  11. data/config/templates/garden/layout.erb +38 -0
  12. data/config/templates/garden/style.css +303 -0
  13. data/config/templates/newspaper/layout.erb +16 -0
  14. data/config/templates/nord/layout.erb +11 -0
  15. data/config/templates/nord/style.css +339 -0
  16. data/config/templates/nord-dark/layout.erb +11 -0
  17. data/config/templates/nord-dark/style.css +339 -0
  18. data/config/templates/protocol/layout.erb +9 -0
  19. data/config/templates/protocol/style.css +25 -0
  20. data/config/templates/zen/layout.erb +11 -0
  21. data/config/templates/zen/style.css +114 -0
  22. data/lib/mint/command_line.rb +253 -111
  23. data/lib/mint/css.rb +11 -4
  24. data/lib/mint/css_template.rb +37 -0
  25. data/lib/mint/document.rb +185 -43
  26. data/lib/mint/helpers.rb +50 -10
  27. data/lib/mint/layout.rb +2 -3
  28. data/lib/mint/markdown_template.rb +47 -0
  29. data/lib/mint/mint.rb +181 -114
  30. data/lib/mint/plugin.rb +3 -3
  31. data/lib/mint/plugins/epub.rb +1 -2
  32. data/lib/mint/resource.rb +19 -9
  33. data/lib/mint/style.rb +10 -14
  34. data/lib/mint/version.rb +1 -1
  35. data/lib/mint.rb +1 -0
  36. data/man/mint.1 +135 -0
  37. data/spec/cli/README.md +99 -0
  38. data/spec/cli/argument_parsing_spec.rb +207 -0
  39. data/spec/cli/bin_integration_spec.rb +348 -0
  40. data/spec/cli/configuration_management_spec.rb +363 -0
  41. data/spec/cli/full_workflow_integration_spec.rb +527 -0
  42. data/spec/cli/publish_workflow_spec.rb +368 -0
  43. data/spec/cli/template_management_spec.rb +300 -0
  44. data/spec/css_spec.rb +1 -1
  45. data/spec/document_spec.rb +102 -69
  46. data/spec/helpers_spec.rb +42 -42
  47. data/spec/mint_spec.rb +104 -80
  48. data/spec/plugin_spec.rb +86 -88
  49. data/spec/run_cli_tests.rb +95 -0
  50. data/spec/spec_helper.rb +8 -1
  51. data/spec/style_spec.rb +18 -16
  52. data/spec/support/cli_helpers.rb +169 -0
  53. data/spec/support/fixtures/content-2.md +16 -0
  54. data/spec/support/matchers.rb +1 -1
  55. metadata +116 -223
  56. data/config/syntax.yaml +0 -71
  57. data/config/templates/base/style.sass +0 -144
  58. data/config/templates/default/layout.haml +0 -8
  59. data/config/templates/default/style.sass +0 -36
  60. data/config/templates/protocol/layout.haml +0 -7
  61. data/config/templates/protocol/style.sass +0 -20
  62. data/config/templates/zen/css/style.css +0 -145
  63. data/config/templates/zen/layout.haml +0 -7
  64. data/config/templates/zen/style.sass +0 -24
  65. data/features/config.feature +0 -21
  66. data/features/plugins/epub.feature +0 -23
  67. data/features/publish.feature +0 -73
  68. data/features/support/env.rb +0 -15
  69. data/features/templates.feature +0 -79
  70. data/spec/command_line_spec.rb +0 -87
  71. data/spec/plugins/epub_spec.rb +0 -242
@@ -0,0 +1,169 @@
1
+ require 'open3'
2
+ require 'tmpdir'
3
+ require 'stringio'
4
+ require 'fileutils'
5
+ require 'ostruct'
6
+
7
+ module CLIHelpers
8
+ # Capture stdout/stderr from a block
9
+ def capture_output
10
+ old_stdout = $stdout
11
+ old_stderr = $stderr
12
+ $stdout = stdout = StringIO.new
13
+ $stderr = stderr = StringIO.new
14
+ yield
15
+ [stdout.string, stderr.string]
16
+ ensure
17
+ $stdout = old_stdout
18
+ $stderr = old_stderr
19
+ end
20
+
21
+ # Run a command and capture its output
22
+ def run_command(env_or_command, *args)
23
+ if env_or_command.is_a?(Hash)
24
+ # First argument is environment variables
25
+ env = env_or_command
26
+ command = args.shift
27
+ stdout, stderr, status = Open3.capture3(env, command, *args)
28
+ else
29
+ # First argument is the command
30
+ command = env_or_command
31
+ stdout, stderr, status = Open3.capture3(command, *args)
32
+ end
33
+
34
+ OpenStruct.new(
35
+ stdout: stdout,
36
+ stderr: stderr,
37
+ status: status,
38
+ success?: status.success?,
39
+ exit_code: status.exitstatus
40
+ )
41
+ end
42
+
43
+ # Create a temporary directory and run the block inside it
44
+ def in_temp_dir
45
+ Dir.mktmpdir("mint-test-") do |dir|
46
+ old_dir = Dir.pwd
47
+ Dir.chdir(dir)
48
+ yield(dir)
49
+ ensure
50
+ Dir.chdir(old_dir) if old_dir
51
+ end
52
+ end
53
+
54
+ # Create a sample markdown file with content
55
+ def create_markdown_file(name = "test.md", content = "# Test\n\nHello world!")
56
+ File.write(name, content)
57
+ name
58
+ end
59
+
60
+ # Create a sample template file
61
+ def create_template_file(name, type = :layout, content = nil)
62
+ content ||= case type
63
+ when :layout
64
+ "<!DOCTYPE html>\n<html><body><%= yield %></body></html>"
65
+ when :style
66
+ "body { font-family: sans-serif; }"
67
+ end
68
+
69
+ File.write(name, content)
70
+ name
71
+ end
72
+
73
+ # Create a complete template directory structure
74
+ def create_template_directory(name, with_layout: true, with_style: true)
75
+ template_dir = ".mint/templates/#{name}"
76
+ FileUtils.mkdir_p(template_dir)
77
+
78
+ if with_layout
79
+ File.write("#{template_dir}/layout.erb",
80
+ "<!DOCTYPE html>\n<html><head><title>Test Document</title></head>" +
81
+ "<body><%= content %></body></html>")
82
+ end
83
+
84
+ if with_style
85
+ File.write("#{template_dir}/style.css",
86
+ "body { margin: 2em; font-family: sans-serif; }")
87
+ end
88
+
89
+ template_dir
90
+ end
91
+
92
+ # Verify file exists and has expected content
93
+ def verify_file_content(file, expected_content = nil, &block)
94
+ expect(File.exist?(file)).to be true
95
+ content = File.read(file)
96
+ if expected_content
97
+ expect(content).to include(expected_content)
98
+ end
99
+ block.call(content) if block_given?
100
+ content
101
+ end
102
+
103
+ # Clean up common files created during tests
104
+ def cleanup_test_files(*patterns)
105
+ patterns.each do |pattern|
106
+ Dir.glob(pattern).each do |file|
107
+ FileUtils.rm_rf(file)
108
+ end
109
+ end
110
+ end
111
+
112
+ # Set up a minimal mint configuration
113
+ def setup_basic_config(scope = :local)
114
+ config_dir = case scope
115
+ when :local then ".mint"
116
+ when :user then File.expand_path("~/.config/mint")
117
+ when :global then "#{Mint::ROOT}/config"
118
+ end
119
+
120
+ FileUtils.mkdir_p(config_dir)
121
+ config_file = "#{config_dir}/config.yaml"
122
+
123
+ basic_config = {
124
+ 'layout' => 'default',
125
+ 'style' => 'default',
126
+ 'destination' => nil
127
+ }
128
+
129
+ File.write(config_file, basic_config.to_yaml)
130
+ config_file
131
+ end
132
+
133
+ # Mock editor for testing edit functionality
134
+ def mock_editor(command = "true") # Use 'true' instead of 'echo' to be silent
135
+ original_editor = ENV['EDITOR']
136
+ ENV['EDITOR'] = command
137
+ yield
138
+ ensure
139
+ if original_editor
140
+ ENV['EDITOR'] = original_editor
141
+ else
142
+ ENV.delete('EDITOR')
143
+ end
144
+ end
145
+
146
+ # Suppress all output during test execution
147
+ def silence_output
148
+ original_stdout = $stdout
149
+ original_stderr = $stderr
150
+ $stdout = StringIO.new
151
+ $stderr = StringIO.new
152
+ yield
153
+ ensure
154
+ $stdout = original_stdout
155
+ $stderr = original_stderr
156
+ end
157
+
158
+ # Assert that a command would abort with specific message
159
+ def expect_abort_with_message(message)
160
+ expect { yield }.to raise_error(SystemExit) do |error|
161
+ # Capture the abort message (this is a bit tricky with Ruby's abort)
162
+ expect(error.message).to include(message) if error.message
163
+ end
164
+ end
165
+ end
166
+
167
+ RSpec.configure do |config|
168
+ config.include CLIHelpers
169
+ end
@@ -0,0 +1,16 @@
1
+ ---
2
+ metadata: true
3
+
4
+ Header 3
5
+ ------
6
+
7
+ This is just a test.
8
+
9
+ Paragraph number two.
10
+
11
+ Header 4
12
+ --------
13
+
14
+ Third sentence.
15
+
16
+ Fourth sentence.
@@ -7,7 +7,7 @@ RSpec::Matchers.define :be_path do |name|
7
7
  end
8
8
 
9
9
  RSpec::Matchers.define :be_in_template do |name|
10
- match {|file| file =~ /#{Mint.root}.*#{name}/ }
10
+ match {|file| file =~ /#{Mint::ROOT}.*#{name}/ }
11
11
  end
12
12
 
13
13
  RSpec::Matchers.define :be_a_template do |name|