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.
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 +193 -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 +105 -68
  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 +145 -167
  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
@@ -1,87 +0,0 @@
1
- require "spec_helper"
2
-
3
- module Mint
4
- describe CommandLine do
5
- describe ".options" do
6
- it "provides default options" do
7
- CommandLine.options["template"]["long"].should == "template"
8
- CommandLine.options["layout"]["long"].should == "layout"
9
- CommandLine.options["style"]["long"].should == "style"
10
- end
11
- end
12
-
13
- describe ".parse" do
14
- it "does not mutate passed in ARGV" do
15
- argv = ["--layout", "zen"]
16
- lambda { CommandLine.parse(argv) }.should_not change { argv }
17
- end
18
-
19
- it "returns a hash of commandline options, unconsumed options, and the help message" do
20
- OptionParser.any_instance.stub(:help => "Help message")
21
- CommandLine.parse(["command", "--layout", "zen"]).should == {
22
- help: "Help message",
23
- argv: ["command"],
24
- options: {
25
- layout: "zen"
26
- }
27
- }
28
- end
29
- end
30
-
31
- describe ".help" do
32
- it "prints a help message" do
33
- STDOUT.should_receive(:puts).with("message")
34
- CommandLine.help("message")
35
- end
36
- end
37
-
38
- describe ".install" do
39
- describe "when there is no template by the specified name" do
40
- it "installs the specified file as a new template" do
41
- CommandLine.install("dynamic.sass", :template => "pro")
42
- Mint.find_template("pro", :style).should == Mint.template_path("pro", :style, :scope => :local, :ext => "sass")
43
- end
44
- end
45
- end
46
-
47
- describe ".uninstall" do
48
- it "uninstalls the specified template" do
49
- CommandLine.install("dynamic.sass", :template => "pro")
50
- CommandLine.uninstall("pro")
51
- lambda do
52
- Mint.find_template("pro", :style)
53
- end.should raise_error
54
- end
55
- end
56
-
57
- describe ".edit" do
58
- it "pulls up a named template file in the user's editor" do
59
- ENV["EDITOR"] = "vim"
60
- CommandLine.should_receive(:system).with("vim #{@dynamic_style_file}")
61
- CommandLine.edit(@dynamic_style_file)
62
- end
63
- end
64
-
65
- describe ".configure" do
66
- it "writes options to the correct file for the scope specified" do
67
- Mint.configuration[:layout].should == "default"
68
- CommandLine.configure({ layout: "pro" }, :local)
69
- Mint.configuration[:layout].should == "pro"
70
- end
71
- end
72
-
73
- describe ".set" do
74
- it "sets and stores a scoped configuration variable" do
75
- CommandLine.should_receive(:configure).with({ layout: "pro" }, :local)
76
- CommandLine.set(:layout, "pro", :scope => :local)
77
- end
78
- end
79
-
80
- describe ".publish!" do
81
- it "publishes a set of files" do
82
- CommandLine.publish!([@content_file])
83
- File.exist?("content.html").should be_true
84
- end
85
- end
86
- end
87
- end
@@ -1,242 +0,0 @@
1
- require "spec_helper"
2
-
3
- # Mimics the requirement to actually require plugins for
4
- # them to be registered/work.
5
- require "mint/plugins/epub"
6
-
7
- module Mint
8
- describe Document do
9
- describe "#chapters" do
10
- it "splits a document's final text into chapters and maps onto IDs" do
11
- # TODO: Clean up these long lines
12
- chapters = Document.new("content.md").chapters
13
- chapters[0].should =~ /This is just a test.*Paragraph number two/m
14
- chapters[1].should =~ /Third sentence.*Fourth sentence/m
15
- end
16
- end
17
- end
18
-
19
- describe EPub do
20
- describe "#after_publish" do
21
- let(:document) do
22
- Document.new "content.md", :destination => "directory"
23
- end
24
-
25
- before do
26
- document.publish!
27
- document_length = File.read("directory/content.html").length
28
- EPub.after_publish(document)
29
-
30
- # We're going to consider a document successfully split
31
- # if its two chapters are less than half of it's length,
32
- # not including the DOCTYPE/HTML chrome that we introduce
33
- # into each split document (~150 characters)
34
- @target_length = document_length / 2 + 200
35
- end
36
-
37
- after do
38
- FileUtils.rm_r "directory.epub"
39
- end
40
-
41
- it "does nothing if no destination is specified" do
42
- invalid_document = Document.new "content.md"
43
- lambda do
44
- EPub.after_publish(invalid_document)
45
- end.should raise_error(InvalidDocumentError)
46
- end
47
-
48
- it "replaces the monolithic published file with a packaged ePub file" do
49
- File.exist?("directory/content.html").should be_false
50
- File.exist?("directory.epub").should be_true
51
- end
52
-
53
- it "produces a valid ePub file" do
54
- pending "need to integrate epubcheck script if found on system"
55
- end
56
-
57
- it "ensures all files were compressed using PKZIP" do
58
- File.read("directory.epub")[0..1].should == "PK"
59
- end
60
-
61
- context "when the ePub file is unzipped" do
62
- before do
63
- # Copy instead of moving to make test cleanup more
64
- # predictable in nested contexts.
65
- FileUtils.cp "directory.epub", "directory.zip"
66
-
67
- # I will later replace this with my own EPub.unzip! function
68
- # but don't want to get too distracted now.
69
- `unzip -o directory.zip -d directory`
70
-
71
- # EPub.unzip! "directory.zip"
72
- end
73
-
74
- after do
75
- FileUtils.rm_r "directory.zip"
76
- FileUtils.rm_r "directory"
77
- end
78
-
79
- it "contains a META-INF directory" do
80
- File.exist?("directory/META-INF/container.xml").should be_true
81
- end
82
-
83
- it "contains an OPS directory" do
84
- File.exist?("directory/OPS").should be_true
85
- end
86
-
87
- it "contains a mimetype file" do
88
- File.exist?("directory/mimetype").should be_true
89
- File.read("directory/mimetype").chomp.should == "application/epub+zip"
90
- end
91
-
92
- it "contains a container file that points to the OPF file" do
93
- File.exist?("directory/META-INF/container.xml").should be_true
94
- end
95
-
96
- it "contains an OPF manifest with book metadata" do
97
- File.exist?("directory/OPS/content.opf").should be_true
98
- end
99
-
100
- it "contains an NCX file with book spine and TOC" do
101
- File.exist?("directory/OPS/toc.ncx").should be_true
102
- end
103
-
104
- it "splits the document into chapters" do
105
- chapter1 = File.read "directory/OPS/chapter-1.html"
106
- chapter2 = File.read "directory/OPS/chapter-2.html"
107
-
108
- chapter1.length.should < @target_length
109
- chapter2.length.should < @target_length
110
- end
111
-
112
- it "creates a stylesheet for all pages"
113
- end
114
- end
115
-
116
- describe "#split_on" do
117
- it "returns a copy of the HTML text it is passed, grouping elements" do
118
- Document.new("content.md").publish!
119
-
120
- html_text = File.read "content.html"
121
- html_document = Nokogiri::HTML.parse(html_text)
122
-
123
- chapters = EPub.split_on(html_document, "h2")
124
-
125
- expected_document = Nokogiri::HTML.parse <<-HTML
126
- <div id="container">
127
- <div>
128
- <h2>Header</h2>
129
- <p>This is just a test.</p>
130
- <p>Paragraph number two.</p>
131
- </div>
132
-
133
- <div>
134
- <h2>Header 2</h2>
135
- <p>Third sentence.</p>
136
- <p>Fourth sentence.</p>
137
- </div>
138
- </div>
139
- HTML
140
-
141
- expected_chapters = expected_document.search "div div"
142
-
143
- cleanse(chapters).should == cleanse(expected_chapters)
144
- end
145
- end
146
-
147
- describe "#zip!" do
148
- before do
149
- FileUtils.mkdir "directory"
150
-
151
- files = {
152
- first: "First content",
153
- second: "Second content",
154
- third: "Third content"
155
- }
156
-
157
- files.each do |name, content|
158
- File.open "directory/#{name}", "w" do |f|
159
- f << content
160
- end
161
- end
162
- end
163
-
164
- after do
165
- Dir["directory*"].each {|dir| FileUtils.rm_r dir }
166
- # FileUtils.rm "directory.zip"
167
- # FileUtils.rm_r "directory"
168
- end
169
-
170
- # This is not a great test of Zip functionality,
171
- # but I don't really care to spend time on this right now.
172
- # Most of the details of the Zip file creation will be tested
173
- # above.
174
- it "compresses the named file into a directory" do
175
- EPub.zip! "directory"
176
- File.exist?("directory.zip").should be_true
177
- end
178
-
179
- it "accepts an extension parameter" do
180
- EPub.zip! "directory", :extension => "epub"
181
- File.exist?("directory.epub").should be_true
182
- end
183
-
184
- it "creates a mimetype entry if specified" do
185
- pending "a more robust Zip testing strategy"
186
- EPub.zip! "directory", :mimetype => "text/epub"
187
- end
188
- end
189
-
190
- describe "#create!" do
191
- before do
192
- EPub.should_receive(:create_from_template!).and_return
193
- end
194
-
195
- it "accepts a block for configuration options" do
196
- lambda do
197
- EPub.create! do |file|
198
- file.type = "container"
199
- end
200
- end.should_not raise_error
201
- end
202
-
203
- it "render a container file" do
204
- EPub.should_receive(:container_defaults).once.and_return({})
205
- EPub.create! do |file|
206
- file.type = "container"
207
- end
208
- end
209
-
210
- it "render a content file" do
211
- EPub.should_receive(:content_defaults).once.and_return({})
212
- EPub.create! do |file|
213
- file.type = "content"
214
- end
215
- end
216
-
217
- it "render a table of contents file" do
218
- EPub.should_receive(:toc_defaults).once.and_return({})
219
- EPub.create! do |file|
220
- file.type = "toc"
221
- end
222
- end
223
-
224
- it "defaults to a type of 'container'" do
225
- EPub.should_receive(:container_defaults).once.and_return({})
226
- EPub.create!
227
- end
228
- end
229
-
230
- describe "#create_chapters!" do
231
- it "calls #create_chapter! for each chapter" do
232
- EPub.should_receive(:create_chapter!).once.ordered
233
- EPub.should_receive(:create_chapter!).once.ordered
234
- EPub.create_chapters! ["text1", "text2"]
235
- end
236
- end
237
-
238
- def cleanse(dom)
239
- dom.to_s.squeeze.chomp.gsub(/^\s/, "")
240
- end
241
- end
242
- end