mint 0.7.4 → 0.8.1

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 (70) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +23 -14
  3. data/LICENSE +22 -0
  4. data/README.md +68 -79
  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/layout.erb +10 -0
  9. data/config/templates/default/style.css +237 -0
  10. data/config/templates/garden/layout.erb +38 -0
  11. data/config/templates/garden/style.css +303 -0
  12. data/config/templates/nord/layout.erb +11 -0
  13. data/config/templates/nord/style.css +339 -0
  14. data/config/templates/nord-dark/layout.erb +11 -0
  15. data/config/templates/nord-dark/style.css +339 -0
  16. data/config/templates/zen/layout.erb +11 -0
  17. data/config/templates/zen/style.css +114 -0
  18. data/lib/mint/command_line.rb +253 -111
  19. data/lib/mint/css.rb +11 -4
  20. data/lib/mint/css_parser.rb +76 -0
  21. data/lib/mint/css_template.rb +37 -0
  22. data/lib/mint/document.rb +203 -43
  23. data/lib/mint/helpers.rb +50 -10
  24. data/lib/mint/layout.rb +2 -3
  25. data/lib/mint/markdown_template.rb +47 -0
  26. data/lib/mint/mint.rb +181 -114
  27. data/lib/mint/plugin.rb +3 -3
  28. data/lib/mint/plugins/epub.rb +1 -2
  29. data/lib/mint/resource.rb +19 -9
  30. data/lib/mint/style.rb +10 -14
  31. data/lib/mint/version.rb +1 -1
  32. data/lib/mint.rb +1 -0
  33. data/man/mint.1 +135 -0
  34. data/spec/cli/README.md +99 -0
  35. data/spec/cli/argument_parsing_spec.rb +237 -0
  36. data/spec/cli/bin_integration_spec.rb +348 -0
  37. data/spec/cli/configuration_management_spec.rb +363 -0
  38. data/spec/cli/full_workflow_integration_spec.rb +527 -0
  39. data/spec/cli/publish_workflow_spec.rb +368 -0
  40. data/spec/cli/template_management_spec.rb +300 -0
  41. data/spec/css_parser_spec.rb +149 -0
  42. data/spec/css_spec.rb +1 -1
  43. data/spec/document_spec.rb +102 -69
  44. data/spec/helpers_spec.rb +42 -42
  45. data/spec/mint_spec.rb +104 -80
  46. data/spec/plugin_spec.rb +141 -143
  47. data/spec/run_cli_tests.rb +95 -0
  48. data/spec/spec_helper.rb +8 -1
  49. data/spec/style_spec.rb +18 -16
  50. data/spec/support/cli_helpers.rb +169 -0
  51. data/spec/support/fixtures/content-2.md +16 -0
  52. data/spec/support/matchers.rb +1 -1
  53. metadata +116 -224
  54. data/config/syntax.yaml +0 -71
  55. data/config/templates/base/style.sass +0 -144
  56. data/config/templates/default/css/style.css +0 -158
  57. data/config/templates/default/layout.haml +0 -8
  58. data/config/templates/default/style.sass +0 -36
  59. data/config/templates/protocol/layout.haml +0 -7
  60. data/config/templates/protocol/style.sass +0 -20
  61. data/config/templates/zen/css/style.css +0 -145
  62. data/config/templates/zen/layout.haml +0 -7
  63. data/config/templates/zen/style.sass +0 -24
  64. data/features/config.feature +0 -21
  65. data/features/plugins/epub.feature +0 -23
  66. data/features/publish.feature +0 -73
  67. data/features/support/env.rb +0 -15
  68. data/features/templates.feature +0 -79
  69. data/spec/command_line_spec.rb +0 -87
  70. data/spec/plugins/epub_spec.rb +0 -242
data/spec/style_spec.rb CHANGED
@@ -6,12 +6,12 @@ module Mint
6
6
  let(:style) { Style.new @static_style_file }
7
7
  subject { style }
8
8
 
9
- its(:destination) { should be_nil }
10
- its(:destination_file) { should == "#{@tmp_dir}/static.css" }
9
+ its(:destination) { is_expected.to be_nil }
10
+ its(:destination_file) { is_expected.to eq("#{@tmp_dir}/static.css") }
11
11
 
12
- it { should_not be_rendered }
12
+ it { is_expected.to be_rendered }
13
13
  it "'renders' itself verbatim" do
14
- style.render.should == File.read(@static_style_file)
14
+ expect(style.render).to eq(File.read(@static_style_file))
15
15
  end
16
16
  end
17
17
 
@@ -19,13 +19,13 @@ module Mint
19
19
  let(:style) { Style.new @dynamic_style_file }
20
20
  subject { style }
21
21
 
22
- its(:destination) { should be_nil }
23
- its(:destination_file) { should == "#{@tmp_dir}/dynamic.css" }
22
+ its(:destination) { is_expected.to be_nil }
23
+ its(:destination_file) { is_expected.to eq("#{@tmp_dir}/dynamic.css") }
24
24
 
25
- it { should be_rendered }
26
- it "renders itself from a templating language to Html" do
27
- style.render.gsub("\n", " ").should ==
28
- File.read(@static_style_file).gsub("\n", " ")
25
+ it { is_expected.to be_rendered }
26
+ it "renders itself from a templating language to CSS" do
27
+ expect(style.render.gsub("\n", " ").strip).to eq(
28
+ File.read(@static_style_file).gsub("\n", " ").strip)
29
29
  end
30
30
  end
31
31
 
@@ -34,9 +34,9 @@ module Mint
34
34
  :destination => "destination" }
35
35
  subject { style }
36
36
 
37
- its(:destination) { should == "destination" }
37
+ its(:destination) { is_expected.to eq("destination") }
38
38
  its(:destination_file) do
39
- should == "#{@tmp_dir}/destination/static.css"
39
+ is_expected.to eq("#{@tmp_dir}/destination/static.css")
40
40
  end
41
41
  end
42
42
 
@@ -55,12 +55,14 @@ module Mint
55
55
  # end
56
56
 
57
57
  context "when it's created from a dynamic template file" do
58
- let(:style) { Style.new(Mint.lookup_template(:default, :style)) }
58
+ let(:style) { Style.new(Mint.lookup_style("default")) }
59
59
  subject { style }
60
60
 
61
- its(:destination) { should == "css" }
62
- its(:destination_file) do
63
- should == "#{Mint.root}/config/templates/default/css/style.css"
61
+ it "has destination in user tmp directory" do
62
+ expect(style.destination).to match(/\.config\/mint\/tmp$/)
63
+ end
64
+ it "has destination file in user tmp directory" do
65
+ expect(style.destination_file).to match(/\.config\/mint\/tmp\/style\.css$/)
64
66
  end
65
67
  end
66
68
  end
@@ -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|