mint 0.7.3 → 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.
- checksums.yaml +7 -0
- data/Gemfile +23 -14
- data/LICENSE +22 -0
- data/README.md +82 -56
- data/bin/mint +47 -10
- data/bin/mint-epub +1 -4
- data/config/templates/base/style.css +187 -0
- data/config/templates/default/css/style.css +126 -79
- data/config/templates/default/layout.erb +10 -0
- data/config/templates/default/style.css +237 -0
- data/config/templates/garden/layout.erb +38 -0
- data/config/templates/garden/style.css +303 -0
- data/config/templates/newspaper/layout.erb +16 -0
- data/config/templates/nord/layout.erb +11 -0
- data/config/templates/nord/style.css +339 -0
- data/config/templates/nord-dark/layout.erb +11 -0
- data/config/templates/nord-dark/style.css +339 -0
- data/config/templates/protocol/layout.erb +9 -0
- data/config/templates/protocol/style.css +25 -0
- data/config/templates/zen/layout.erb +11 -0
- data/config/templates/zen/style.css +114 -0
- data/lib/mint/command_line.rb +253 -111
- data/lib/mint/css.rb +11 -4
- data/lib/mint/css_template.rb +37 -0
- data/lib/mint/document.rb +193 -43
- data/lib/mint/helpers.rb +50 -10
- data/lib/mint/layout.rb +2 -3
- data/lib/mint/markdown_template.rb +47 -0
- data/lib/mint/mint.rb +181 -114
- data/lib/mint/plugin.rb +3 -3
- data/lib/mint/plugins/epub.rb +1 -2
- data/lib/mint/resource.rb +19 -9
- data/lib/mint/style.rb +10 -14
- data/lib/mint/version.rb +1 -1
- data/lib/mint.rb +1 -0
- data/man/mint.1 +135 -0
- data/spec/cli/README.md +99 -0
- data/spec/cli/argument_parsing_spec.rb +207 -0
- data/spec/cli/bin_integration_spec.rb +348 -0
- data/spec/cli/configuration_management_spec.rb +363 -0
- data/spec/cli/full_workflow_integration_spec.rb +527 -0
- data/spec/cli/publish_workflow_spec.rb +368 -0
- data/spec/cli/template_management_spec.rb +300 -0
- data/spec/css_spec.rb +1 -1
- data/spec/document_spec.rb +105 -68
- data/spec/helpers_spec.rb +42 -42
- data/spec/mint_spec.rb +104 -80
- data/spec/plugin_spec.rb +86 -88
- data/spec/run_cli_tests.rb +95 -0
- data/spec/spec_helper.rb +8 -1
- data/spec/style_spec.rb +18 -16
- data/spec/support/cli_helpers.rb +169 -0
- data/spec/support/fixtures/content-2.md +16 -0
- data/spec/support/matchers.rb +1 -1
- metadata +145 -167
- data/config/syntax.yaml +0 -71
- data/config/templates/base/style.sass +0 -144
- data/config/templates/default/layout.haml +0 -8
- data/config/templates/default/style.sass +0 -36
- data/config/templates/protocol/layout.haml +0 -7
- data/config/templates/protocol/style.sass +0 -20
- data/config/templates/zen/css/style.css +0 -145
- data/config/templates/zen/layout.haml +0 -7
- data/config/templates/zen/style.sass +0 -24
- data/features/config.feature +0 -21
- data/features/plugins/epub.feature +0 -23
- data/features/publish.feature +0 -73
- data/features/support/env.rb +0 -15
- data/features/templates.feature +0 -79
- data/spec/command_line_spec.rb +0 -87
- data/spec/plugins/epub_spec.rb +0 -242
data/spec/mint_spec.rb
CHANGED
@@ -3,21 +3,9 @@ require "spec_helper"
|
|
3
3
|
describe Mint do
|
4
4
|
subject { Mint }
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
style: "default",
|
10
|
-
destination: nil,
|
11
|
-
style_destination: nil
|
12
|
-
}
|
13
|
-
end
|
14
|
-
|
15
|
-
its(:directories) { should == { templates: "templates" } }
|
16
|
-
its(:files) { should == { syntax: "syntax.yaml", defaults: "defaults.yaml" } }
|
17
|
-
|
18
|
-
describe ".root" do
|
19
|
-
it "returns the root of the Mint gem as a string" do
|
20
|
-
Mint.root.should == File.expand_path("../../../mint", __FILE__)
|
6
|
+
describe "::ROOT" do
|
7
|
+
it "contains the root of the Mint gem as a string" do
|
8
|
+
expect(Mint::ROOT).to eq(File.expand_path("../..", __FILE__))
|
21
9
|
end
|
22
10
|
end
|
23
11
|
|
@@ -26,19 +14,19 @@ describe Mint do
|
|
26
14
|
files.map {|file| Pathname.new(file) }
|
27
15
|
end
|
28
16
|
|
29
|
-
it "
|
30
|
-
Mint.path.
|
31
|
-
|
32
|
-
|
17
|
+
it "returns the paths corresponding to all scopes as an array" do
|
18
|
+
expect(Mint.path).to eq([Pathname.new(".mint"),
|
19
|
+
Pathname.new("~/.config/mint").expand_path,
|
20
|
+
Pathname.new(Mint::ROOT + "/config").expand_path])
|
33
21
|
end
|
34
22
|
|
35
23
|
it "can filter paths by one scope" do
|
36
|
-
Mint.path(
|
24
|
+
expect(Mint.path([:user])).to eq([Pathname.new("~/.config/mint").expand_path])
|
37
25
|
end
|
38
26
|
|
39
27
|
it "can filter paths by many scopes" do
|
40
|
-
Mint.path(
|
41
|
-
|
28
|
+
expect(Mint.path([:local, :user])).to eq([Pathname.new(".mint"),
|
29
|
+
Pathname.new("~/.config/mint").expand_path])
|
42
30
|
end
|
43
31
|
end
|
44
32
|
|
@@ -46,23 +34,28 @@ describe Mint do
|
|
46
34
|
describe ".configuration" do
|
47
35
|
let(:defaults) do
|
48
36
|
{
|
49
|
-
|
50
|
-
style: "default",
|
37
|
+
root: Dir.getwd,
|
51
38
|
destination: nil,
|
52
|
-
|
39
|
+
style_mode: :inline,
|
40
|
+
style_destination: nil,
|
41
|
+
output_file: '#{basename}.#{new_extension}',
|
42
|
+
layout_or_style_or_template: [:template, 'default'],
|
43
|
+
scope: :local,
|
44
|
+
recursive: false,
|
45
|
+
verbose: false
|
53
46
|
}
|
54
47
|
end
|
55
48
|
|
56
|
-
context "when there is no
|
49
|
+
context "when there is no config.yaml file on the Mint path" do
|
57
50
|
it "returns a default set of options" do
|
58
|
-
Mint.configuration.
|
51
|
+
expect(Mint.configuration).to eq(defaults)
|
59
52
|
end
|
60
53
|
end
|
61
54
|
|
62
|
-
context "when there is a
|
55
|
+
context "when there is a config.yaml file on the Mint path" do
|
63
56
|
before do
|
64
57
|
FileUtils.mkdir_p ".mint"
|
65
|
-
File.open(".mint/
|
58
|
+
File.open(".mint/config.yaml", "w") do |file|
|
66
59
|
file << "layout: zen"
|
67
60
|
end
|
68
61
|
end
|
@@ -72,57 +65,62 @@ describe Mint do
|
|
72
65
|
end
|
73
66
|
|
74
67
|
it "merges all specified options with precedence according to scope" do
|
75
|
-
Mint.configuration[:layout].
|
68
|
+
expect(Mint.configuration[:layout]).to eq("zen")
|
76
69
|
end
|
77
70
|
|
78
71
|
it "can filter by scope (but always includes defaults)" do
|
79
|
-
Mint.configuration(:
|
72
|
+
expect(Mint.configuration(scopes: [:user])).to eq(defaults)
|
80
73
|
end
|
81
74
|
end
|
82
75
|
end
|
83
76
|
|
84
77
|
describe ".configuration_with" do
|
85
78
|
it "displays the sum of all configuration files with other options added" do
|
86
|
-
Mint.configuration_with(:
|
87
|
-
|
88
|
-
style: "default",
|
79
|
+
expect(Mint.configuration_with(local: true)).to eq({
|
80
|
+
root: Dir.getwd,
|
89
81
|
destination: nil,
|
82
|
+
style_mode: :inline,
|
90
83
|
style_destination: nil,
|
84
|
+
output_file: '#{basename}.#{new_extension}',
|
85
|
+
layout_or_style_or_template: [:template, 'default'],
|
86
|
+
scope: :local,
|
87
|
+
recursive: false,
|
88
|
+
verbose: false,
|
91
89
|
local: true
|
92
|
-
}
|
90
|
+
})
|
93
91
|
end
|
94
92
|
end
|
95
93
|
|
96
94
|
describe ".templates" do
|
97
|
-
it "returns
|
98
|
-
|
95
|
+
it "returns local templates by default" do
|
96
|
+
# Note: Now defaults to local scope, will include global templates only if explicitly requested
|
97
|
+
expect(Mint.templates).to be_an(Array)
|
99
98
|
end
|
100
99
|
|
101
|
-
it "returns
|
102
|
-
|
103
|
-
Mint.templates(:scope => :local).should_not include(Mint.root + "/config/templates/default")
|
100
|
+
it "returns global templates when global scope is specified" do
|
101
|
+
expect(Mint.templates(:global)).to include(Mint::ROOT + "/config/templates/default")
|
104
102
|
end
|
105
103
|
end
|
106
104
|
|
107
105
|
describe ".formats" do
|
108
106
|
it "includes Markdown" do
|
109
|
-
Mint.formats.
|
107
|
+
expect(Mint.formats).to include("md")
|
110
108
|
end
|
111
109
|
|
112
110
|
it "includes Haml" do
|
113
|
-
Mint.formats.
|
111
|
+
expect(Mint.formats).to include("haml")
|
114
112
|
end
|
115
113
|
end
|
116
114
|
|
117
115
|
describe ".css_formats" do
|
118
116
|
it "includes Sass" do
|
119
|
-
Mint.
|
117
|
+
expect(Mint.css_formats).to include("sass")
|
120
118
|
end
|
121
119
|
end
|
122
120
|
|
123
121
|
describe ".renderer" do
|
124
122
|
it "creates a valid renderer" do
|
125
|
-
Mint.renderer(@content_file).
|
123
|
+
expect(Mint.renderer(@content_file)).to respond_to(:render)
|
126
124
|
end
|
127
125
|
end
|
128
126
|
|
@@ -130,51 +128,69 @@ describe Mint do
|
|
130
128
|
it "chooses the appropriate path for scope" do
|
131
129
|
expectations = {
|
132
130
|
local: Pathname.new(".mint"),
|
133
|
-
user: Pathname.new("~/.mint").expand_path,
|
134
|
-
global: Pathname.new(Mint
|
131
|
+
user: Pathname.new("~/.config/mint").expand_path,
|
132
|
+
global: Pathname.new(Mint::ROOT + "/config").expand_path
|
135
133
|
}
|
136
134
|
|
137
135
|
expectations.each do |scope, path|
|
138
|
-
Mint.path_for_scope(scope).
|
136
|
+
expect(Mint.path_for_scope(scope)).to eq(path)
|
139
137
|
end
|
140
138
|
end
|
141
139
|
end
|
142
140
|
|
141
|
+
# Refactored lookup methods for explicit parameter interface
|
143
142
|
describe ".lookup_template" do
|
144
|
-
it "
|
145
|
-
Mint.lookup_template(
|
146
|
-
|
147
|
-
|
148
|
-
Mint.lookup_template(:zen, :style).should be_in_template("zen")
|
149
|
-
Mint.lookup_template("layout.haml").should == "layout.haml"
|
150
|
-
Mint.lookup_template("dynamic.sass").should == "dynamic.sass"
|
143
|
+
it "returns template directory path by name" do
|
144
|
+
result = Mint.lookup_template("default")
|
145
|
+
expect(result.to_s).to include("templates/default")
|
146
|
+
expect(File.directory?(result)).to be true
|
151
147
|
end
|
152
148
|
end
|
153
149
|
|
154
|
-
describe ".
|
155
|
-
it "
|
156
|
-
Mint.
|
157
|
-
|
158
|
-
|
150
|
+
describe ".lookup_layout" do
|
151
|
+
it "returns layout file path by template name" do
|
152
|
+
result = Mint.lookup_layout("default")
|
153
|
+
expect(result).to include("templates/default")
|
154
|
+
expect(result).to end_with("layout.erb")
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
describe ".lookup_style" do
|
159
|
+
it "returns style file path by template name" do
|
160
|
+
result = Mint.lookup_style("default")
|
161
|
+
expect(result).to include("templates/default")
|
162
|
+
expect(result).to end_with("style.css")
|
159
163
|
end
|
164
|
+
end
|
160
165
|
|
161
|
-
|
162
|
-
|
163
|
-
|
166
|
+
describe ".find_template" do
|
167
|
+
it "finds the correct template file by name and type" do
|
168
|
+
layout_file = Mint.find_template("default", :layout)
|
169
|
+
style_file = Mint.find_template("default", :style)
|
170
|
+
|
171
|
+
expect(layout_file).to include("templates/default")
|
172
|
+
expect(layout_file).to end_with("layout.erb")
|
173
|
+
expect(style_file).to include("templates/default")
|
174
|
+
expect(style_file).to end_with("style.css")
|
175
|
+
end
|
176
|
+
|
177
|
+
it "determines if a file is a template file" do
|
178
|
+
actual_template = Mint.lookup_layout("default")
|
179
|
+
fake_template = "#{Mint::ROOT}/config/templates/default.css"
|
164
180
|
obvious_nontemplate = @dynamic_style_file
|
165
181
|
|
166
|
-
actual_template.
|
167
|
-
fake_template.
|
168
|
-
obvious_nontemplate.
|
182
|
+
expect(Mint.template?(actual_template)).to be_truthy
|
183
|
+
expect(Mint.template?(fake_template)).to be_falsy
|
184
|
+
expect(Mint.template?(obvious_nontemplate)).to be_falsy
|
169
185
|
end
|
170
186
|
end
|
171
187
|
|
172
188
|
describe ".guess_name_from" do
|
173
189
|
it "properly guesses destination file names based on source file names" do
|
174
|
-
Mint.guess_name_from("content.md").
|
175
|
-
Mint.guess_name_from("content.textile").
|
176
|
-
Mint.guess_name_from("layout.haml").
|
177
|
-
Mint.guess_name_from("dynamic.sass").
|
190
|
+
expect(Mint.guess_name_from("content.md")).to eq("content.html")
|
191
|
+
expect(Mint.guess_name_from("content.textile")).to eq("content.html")
|
192
|
+
expect(Mint.guess_name_from("layout.haml")).to eq("layout.html")
|
193
|
+
expect(Mint.guess_name_from("dynamic.sass")).to eq("dynamic.css")
|
178
194
|
end
|
179
195
|
end
|
180
196
|
|
@@ -184,7 +200,11 @@ describe Mint do
|
|
184
200
|
subject { document }
|
185
201
|
|
186
202
|
its(:destination_file_path) { should_not exist }
|
187
|
-
|
203
|
+
it "style destination file should not exist initially" do
|
204
|
+
# Clean up any existing style file first
|
205
|
+
FileUtils.rm_f(document.style_destination_file_path) if document.style_destination_file_path && File.exist?(document.style_destination_file_path)
|
206
|
+
expect(document.style_destination_file_path).not_to exist
|
207
|
+
end
|
188
208
|
end
|
189
209
|
|
190
210
|
# These are copied from document_spec.rb. I eventually want to move
|
@@ -195,24 +215,28 @@ describe Mint do
|
|
195
215
|
subject { document }
|
196
216
|
|
197
217
|
its(:destination_file_path) { should exist }
|
198
|
-
|
218
|
+
|
219
|
+
it "creates style file only for external style mode" do
|
220
|
+
if document.style_mode == :external
|
221
|
+
expect(document.style_destination_file_path).to exist
|
222
|
+
else
|
223
|
+
expect(document.style_destination_file_path).not_to exist
|
224
|
+
end
|
225
|
+
end
|
199
226
|
end
|
200
227
|
end
|
201
228
|
|
202
229
|
describe ".template_path" do
|
203
|
-
it "
|
204
|
-
Mint.template_path("pro", :
|
205
|
-
".mint/templates/pro/layout.haml"
|
230
|
+
it "returns template directory for given name and scope" do
|
231
|
+
expect(Mint.template_path("pro", :local)).to eq(Pathname.new(".mint/templates/pro"))
|
206
232
|
end
|
207
233
|
|
208
|
-
it "
|
209
|
-
Mint.template_path("pro", :
|
210
|
-
".mint/templates/pro/layout.erb"
|
234
|
+
it "works with user scope" do
|
235
|
+
expect(Mint.template_path("pro", :user)).to eq(Pathname.new("~/.config/mint/templates/pro").expand_path)
|
211
236
|
end
|
212
237
|
|
213
|
-
it "
|
214
|
-
Mint.template_path("pro", :
|
215
|
-
File.expand_path("~/.mint/templates/pro/layout.haml")
|
238
|
+
it "works with global scope" do
|
239
|
+
expect(Mint.template_path("pro", :global)).to eq(Pathname.new("#{Mint::ROOT}/config/templates/pro"))
|
216
240
|
end
|
217
241
|
end
|
218
242
|
end
|