mint 0.5.1 → 0.7.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 (50) hide show
  1. data/Gemfile +18 -0
  2. data/README.md +3 -3
  3. data/bin/mint +27 -27
  4. data/bin/mint-epub +6 -6
  5. data/config/syntax.yaml +12 -12
  6. data/{templates → config/templates}/base/style.sass +11 -4
  7. data/config/templates/default/css/style.css +158 -0
  8. data/config/templates/default/layout.haml +8 -0
  9. data/{templates → config/templates}/default/style.sass +0 -0
  10. data/{templates/default → config/templates/protocol}/layout.haml +0 -0
  11. data/config/templates/protocol/style.sass +20 -0
  12. data/config/templates/reset.css +92 -0
  13. data/config/templates/zen/css/style.css +145 -0
  14. data/{templates/pro → config/templates/zen}/layout.haml +0 -0
  15. data/config/templates/zen/style.sass +24 -0
  16. data/features/config.feature +21 -0
  17. data/features/publish.feature +3 -3
  18. data/features/support/env.rb +9 -27
  19. data/features/templates.feature +79 -0
  20. data/lib/mint.rb +11 -11
  21. data/lib/mint/{commandline.rb → command_line.rb} +96 -80
  22. data/lib/mint/css.rb +43 -34
  23. data/lib/mint/document.rb +99 -93
  24. data/lib/mint/helpers.rb +21 -17
  25. data/lib/mint/layout.rb +1 -1
  26. data/lib/mint/mint.rb +92 -36
  27. data/lib/mint/plugin.rb +5 -5
  28. data/lib/mint/plugins/epub.rb +51 -51
  29. data/lib/mint/resource.rb +2 -2
  30. data/lib/mint/style.rb +2 -2
  31. data/lib/mint/version.rb +1 -1
  32. data/spec/command_line_spec.rb +87 -0
  33. data/spec/css_spec.rb +46 -0
  34. data/spec/document_spec.rb +38 -40
  35. data/spec/helpers_spec.rb +101 -83
  36. data/spec/layout_spec.rb +1 -1
  37. data/spec/mint_spec.rb +184 -60
  38. data/spec/plugin_spec.rb +61 -67
  39. data/spec/plugins/epub_spec.rb +47 -47
  40. data/spec/resource_spec.rb +9 -9
  41. data/spec/spec_helper.rb +20 -93
  42. data/spec/style_spec.rb +6 -8
  43. data/spec/support/fixtures/content.md +16 -0
  44. data/spec/support/fixtures/dynamic.sass +3 -0
  45. data/spec/support/fixtures/layout.haml +3 -0
  46. data/spec/support/fixtures/static.css +3 -0
  47. data/spec/support/matchers.rb +15 -0
  48. metadata +160 -70
  49. data/spec/commandline_spec.rb +0 -91
  50. data/templates/pro/style.sass +0 -0
data/lib/mint/resource.rb CHANGED
@@ -1,4 +1,4 @@
1
- require 'mint/mint'
1
+ require "mint/mint"
2
2
 
3
3
  module Mint
4
4
  class Resource
@@ -45,7 +45,7 @@ module Mint
45
45
  attr_accessor :destination
46
46
 
47
47
  def destination_file_path
48
- root_directory_path + (destination || '') + name
48
+ root_directory_path + (destination || "") + name
49
49
  end
50
50
 
51
51
  def destination_file
data/lib/mint/style.rb CHANGED
@@ -1,4 +1,4 @@
1
- require 'mint/resource'
1
+ require "mint/resource"
2
2
 
3
3
  module Mint
4
4
  class Style < Resource
@@ -19,7 +19,7 @@ module Mint
19
19
  # However, if a destination directory is already specified, we
20
20
  # leave it alone.
21
21
  if Mint.template?(self.source_directory) and rendered?
22
- self.destination ||= 'css'
22
+ self.destination ||= "css"
23
23
  end
24
24
  end
25
25
 
data/lib/mint/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Mint
2
- VERSION = '0.5.1'
2
+ VERSION = "0.7.1"
3
3
  end
@@ -0,0 +1,87 @@
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
data/spec/css_spec.rb ADDED
@@ -0,0 +1,46 @@
1
+ require "spec_helper"
2
+
3
+ module Mint
4
+ describe CSS do
5
+ describe ".stylify" do
6
+ it "translates from human-readable configuration to CSS" do
7
+ table = {
8
+ "Font: Helvetica" => "font-family: Helvetica",
9
+ 'Font: "Lucida Grande"' => 'font-family: "Lucida Grande"',
10
+ "Font Size: 12pt" => "font-size: 12pt",
11
+ "Font Color: gray" => "color: gray",
12
+ "Color: gray" => "color: gray",
13
+ "Top Margin: 1in" => "padding-top: 1in",
14
+ "Top: 1in" => "padding-top: 1in",
15
+ "Bottom: 1in" => "padding-bottom: 1in",
16
+ "Left: 1in" => "padding-left: 1in",
17
+ "Right: 1in" => "padding-right: 1in",
18
+ "Height: 11in" => "height: 11in",
19
+ "Width: 8in" => "width: 8in",
20
+ "Columns: 2" => "column-count: 2",
21
+ "Column Gap: 1in" => "column-gap: 1in",
22
+ "Orientation: landscape" => "@page { size: landscape }",
23
+ "Indentation: 0.5in" => "p+p { text-indent: 0.5in }",
24
+ "Indent: 0.5in" => "p+p { text-indent: 0.5in }",
25
+ "Bullet: square" => "li { list-style-type: square }",
26
+ "Bullet Image: img.png" => "li { list-style-image: url(img.png) }",
27
+ "Before Paragraph: 0.5in" => "p { margin-top: 0.5in }",
28
+ "After Paragraph: 0.5in" => "p { margin-bottom: 0.5in }"
29
+ # "Smart Typography: On" => "text-rendering: optimizeLegibility",
30
+ # "Spacing: double" => "line-height: 2 * ?",
31
+ # "Bullet: checkbox.png" => "li { list-style-image: url(checkbox.png) }",
32
+ }
33
+
34
+ table.each do |human, machine|
35
+ CSS.stylify(*human.split(":").map(&:strip))
36
+ end
37
+ end
38
+ end
39
+
40
+ describe ".parse" do
41
+ it "transforms a map of human-readable styles into a CSS string" do
42
+ CSS.parse({ "Font" => "Helvetica" }).should == "#container {\n font-family: Helvetica; }\n"
43
+ end
44
+ end
45
+ end
46
+ end
@@ -1,9 +1,7 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  module Mint
4
4
  describe Document do
5
- before { @tmp_dir = Dir.getwd }
6
-
7
5
  # We're not going to re-test derivative methods like source_file_path
8
6
  # or root_directory. resource_spec.rb tells us that if the master
9
7
  # values hold true, then their derivatives will be what we expect, as well.
@@ -17,7 +15,7 @@ module Mint
17
15
  # This test doesn't cover any plugin transformations. Those
18
16
  # transformations are covered in the Plugin spec.
19
17
  its(:content) { should =~ /<p>This is just a test.<\/p>/ }
20
- its(:metadata) { should == { 'metadata' => true } }
18
+ its(:metadata) { should == { "metadata" => true } }
21
19
 
22
20
  # Render output
23
21
 
@@ -55,15 +53,15 @@ module Mint
55
53
  subject { document }
56
54
  its(:root) { should == @tmp_dir }
57
55
  its(:destination) { should be_nil }
58
- its(:source) { should == 'content.md' }
56
+ its(:source) { should == "content.md" }
59
57
  its(:style_destination) { should be_nil }
60
58
 
61
59
  its(:style_destination_file) do
62
- should == Mint.root + '/templates/default/css/style.css'
60
+ should == Mint.root + "/config/templates/default/css/style.css"
63
61
  end
64
62
 
65
63
  its(:style_destination_directory) do
66
- should == Mint.root + '/templates/default/css'
64
+ should == Mint.root + "/config/templates/default/css"
67
65
  end
68
66
 
69
67
  its(:style_destination_file_path) do
@@ -74,24 +72,24 @@ module Mint
74
72
  should == Pathname.new(document.style_destination_directory)
75
73
  end
76
74
 
77
- its(:layout) { should be_in_directory('default') }
78
- its(:style) { should be_in_directory('default') }
75
+ its(:layout) { should be_in_directory("default") }
76
+ its(:style) { should be_in_directory("default") }
79
77
 
80
- its(:stylesheet) { should == Mint.root + '/templates/default/css/style.css' }
78
+ its(:stylesheet) { should == Mint.root + "/config/templates/default/css/style.css" }
81
79
 
82
80
  it_should_behave_like "all documents"
83
81
  end
84
82
 
85
83
  context "when it's created with explicit destination directories" do
86
84
  let(:document) { Document.new @content_file,
87
- :destination => 'destination',
88
- :style_destination => 'styles' }
85
+ :destination => "destination",
86
+ :style_destination => "styles" }
89
87
 
90
88
  subject { document }
91
89
  its(:root) { should == @tmp_dir }
92
- its(:destination) { should == 'destination' }
93
- its(:source) { should == 'content.md' }
94
- its(:style_destination) { should == 'styles' }
90
+ its(:destination) { should == "destination" }
91
+ its(:source) { should == "content.md" }
92
+ its(:style_destination) { should == "styles" }
95
93
 
96
94
  its(:style_destination_file) do
97
95
  should == "#{@tmp_dir}/destination/styles/style.css"
@@ -109,10 +107,10 @@ module Mint
109
107
  should == Pathname.new(document.style_destination_directory)
110
108
  end
111
109
 
112
- its(:layout) { should be_in_directory('default') }
113
- its(:style) { should be_in_directory('default') }
110
+ its(:layout) { should be_in_directory("default") }
111
+ its(:style) { should be_in_directory("default") }
114
112
 
115
- its(:stylesheet) { should == 'styles/style.css' }
113
+ its(:stylesheet) { should == "styles/style.css" }
116
114
 
117
115
  it_should_behave_like "all documents"
118
116
  end
@@ -124,15 +122,15 @@ module Mint
124
122
  subject { document }
125
123
  its(:root) { should == "#{@tmp_dir}/alternative-root" }
126
124
  its(:destination) { should be_nil }
127
- its(:source) { should == 'content.md' }
125
+ its(:source) { should == "content.md" }
128
126
  its(:style_destination) { should be_nil }
129
127
 
130
128
  its(:style_destination_file) do
131
- should == Mint.root + '/templates/default/css/style.css'
129
+ should == Mint.root + "/config/templates/default/css/style.css"
132
130
  end
133
131
 
134
132
  its(:style_destination_directory) do
135
- should == Mint.root + '/templates/default/css'
133
+ should == Mint.root + "/config/templates/default/css"
136
134
  end
137
135
 
138
136
  its(:style_destination_file_path) do
@@ -143,10 +141,10 @@ module Mint
143
141
  should == Pathname.new(document.style_destination_directory)
144
142
  end
145
143
 
146
- its(:layout) { should be_in_directory('default') }
147
- its(:style) { should be_in_directory('default') }
144
+ its(:layout) { should be_in_directory("default") }
145
+ its(:style) { should be_in_directory("default") }
148
146
 
149
- its(:stylesheet) { should == Mint.root + '/templates/default/css/style.css' }
147
+ its(:stylesheet) { should == Mint.root + "/config/templates/default/css/style.css" }
150
148
 
151
149
  it_should_behave_like "all documents"
152
150
  end
@@ -155,18 +153,18 @@ module Mint
155
153
  let(:document) do
156
154
  Document.new @content_file do |doc|
157
155
  doc.root = "#{@tmp_dir}/alternative-root"
158
- doc.destination = 'destination'
159
- doc.style_destination = 'styles'
160
- doc.layout = 'pro'
161
- doc.style = 'pro'
156
+ doc.destination = "destination"
157
+ doc.style_destination = "styles"
158
+ doc.layout = "zen"
159
+ doc.style = "zen"
162
160
  end
163
161
  end
164
162
 
165
163
  subject { document }
166
164
  its(:root) { should == "#{@tmp_dir}/alternative-root" }
167
- its(:destination) { should == 'destination' }
168
- its(:source) { should == 'content.md' }
169
- its(:style_destination) { should == 'styles' }
165
+ its(:destination) { should == "destination" }
166
+ its(:source) { should == "content.md" }
167
+ its(:style_destination) { should == "styles" }
170
168
 
171
169
  its(:style_destination_file) do
172
170
  should == "#{@tmp_dir}/alternative-root/destination/styles/style.css"
@@ -184,10 +182,10 @@ module Mint
184
182
  should == Pathname.new(document.style_destination_directory)
185
183
  end
186
184
 
187
- its(:layout) { should be_in_directory('pro') }
188
- its(:style) { should be_in_directory('pro') }
185
+ its(:layout) { should be_in_directory("zen") }
186
+ its(:style) { should be_in_directory("zen") }
189
187
 
190
- its(:stylesheet) { should == 'styles/style.css' }
188
+ its(:stylesheet) { should == "styles/style.css" }
191
189
 
192
190
  it_should_behave_like "all documents"
193
191
  end
@@ -196,29 +194,29 @@ module Mint
196
194
  let(:text) { "metadata: true\n\nReal text" }
197
195
  describe ".metadata_chunk" do
198
196
  it "extracts, but does not parse, metadata from text" do
199
- Document.metadata_chunk(text).should == 'metadata: true'
197
+ Document.metadata_chunk(text).should == "metadata: true"
200
198
  end
201
199
  end
202
200
 
203
201
  describe ".metadata_from" do
204
202
  it "parses a documents metadata if present" do
205
- Document.metadata_from(text).should == { 'metadata' => true }
203
+ Document.metadata_from(text).should == { "metadata" => true }
206
204
  end
207
205
 
208
206
  it "returns the empty string if a document has bad/no metadata" do
209
- Document.metadata_from('No metadata here').should == {}
207
+ Document.metadata_from("No metadata here").should == {}
210
208
  end
211
209
  end
212
210
 
213
211
  describe ".parse_metadata_from" do
214
212
  it "separates text from its metadata if present" do
215
213
  Document.parse_metadata_from(text).should ==
216
- [{ 'metadata' => true }, 'Real text']
214
+ [{ "metadata" => true }, "Real text"]
217
215
  end
218
216
 
219
217
  it "returns the entire text if no metadata is found" do
220
- Document.parse_metadata_from('No metadata here').should ==
221
- [{}, 'No metadata here']
218
+ Document.parse_metadata_from("No metadata here").should ==
219
+ [{}, "No metadata here"]
222
220
  end
223
221
  end
224
222
  end
data/spec/helpers_spec.rb CHANGED
@@ -1,58 +1,58 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  module Mint
4
4
  describe Helpers do
5
- describe "#underscore" do
5
+ describe ".underscore" do
6
6
  it "underscores class names per ActiveSupport conventions" do
7
- Helpers.underscore('ClassName').should == 'class_name'
7
+ Helpers.underscore("ClassName").should == "class_name"
8
8
  end
9
9
 
10
10
  it "allows for camel case prefixes" do
11
- Helpers.underscore('EPub').should == 'e_pub'
12
- Helpers.underscore('EPub', :ignore_prefix => true).should == 'epub'
11
+ Helpers.underscore("EPub").should == "e_pub"
12
+ Helpers.underscore("EPub", :ignore_prefix => true).should == "epub"
13
13
  end
14
14
 
15
15
  it "allows for namespace removal" do
16
- Helpers.underscore('Mint::EPub',
17
- :namespaces => true).should == 'mint/e_pub'
18
- Helpers.underscore('Mint::EPub',
19
- :namespaces => false).should == 'e_pub'
20
- Helpers.underscore('Mint::EPub',
16
+ Helpers.underscore("Mint::EPub",
17
+ :namespaces => true).should == "mint/e_pub"
18
+ Helpers.underscore("Mint::EPub",
19
+ :namespaces => false).should == "e_pub"
20
+ Helpers.underscore("Mint::EPub",
21
21
  :namespaces => true,
22
- :ignore_prefix => true).should == 'mint/epub'
22
+ :ignore_prefix => true).should == "mint/epub"
23
23
  end
24
24
  end
25
25
 
26
- describe "#slugize" do
26
+ describe ".slugize" do
27
27
  it "downcases everything" do
28
- Helpers.slugize('This could use FEWER CAPITALS').should ==
29
- 'this-could-use-fewer-capitals'
28
+ Helpers.slugize("This could use FEWER CAPITALS").should ==
29
+ "this-could-use-fewer-capitals"
30
30
  end
31
31
 
32
32
  it "parses 'and'" do
33
- Helpers.slugize('You & me').should == 'you-and-me'
33
+ Helpers.slugize("You & me").should == "you-and-me"
34
34
  end
35
35
 
36
36
  it "parses spaces" do
37
- Helpers.slugize('You and me').should == 'you-and-me'
37
+ Helpers.slugize("You and me").should == "you-and-me"
38
38
  end
39
39
 
40
40
  it "removes non-word/non-digits" do
41
- Helpers.slugize('You // and :: me').should == 'you-and-me'
41
+ Helpers.slugize("You // and :: me").should == "you-and-me"
42
42
  end
43
43
 
44
44
  it "condenses multiple hyphens" do
45
- Helpers.slugize('You-----and me').should == 'you-and-me'
45
+ Helpers.slugize("You-----and me").should == "you-and-me"
46
46
  end
47
47
  end
48
48
 
49
- describe "#symbolize" do
49
+ describe ".symbolize" do
50
50
  it "converts hyphens to underscores" do
51
- Helpers.symbolize('you-and-me').should == :you_and_me
51
+ Helpers.symbolize("you-and-me").should == :you_and_me
52
52
  end
53
53
  end
54
54
 
55
- describe "#pathize" do
55
+ describe ".pathize" do
56
56
  it "converts a String to a Pathname" do
57
57
  Helpers.pathize("filename.md").should ==
58
58
  Pathname.new("filename.md").expand_path
@@ -64,18 +64,18 @@ module Mint
64
64
  end
65
65
  end
66
66
 
67
- describe "#symbolize_keys" do
67
+ describe ".symbolize_keys" do
68
68
  it "turns all string keys in a flat map into symbols" do
69
69
  flat_map = {
70
- 'key1' => 'value1',
71
- 'key2' => 'value2',
72
- 'key3' => 'value3'
70
+ "key1" => "value1",
71
+ "key2" => "value2",
72
+ "key3" => "value3"
73
73
  }
74
74
 
75
75
  expected_map = {
76
- key1: 'value1',
77
- key2: 'value2',
78
- key3: 'value3'
76
+ key1: "value1",
77
+ key2: "value2",
78
+ key3: "value3"
79
79
  }
80
80
 
81
81
  Helpers.symbolize_keys(flat_map).should == expected_map
@@ -83,22 +83,22 @@ module Mint
83
83
 
84
84
  it "recursively turns all string keys in a nested map into symbols" do
85
85
  nested_map = {
86
- 'key1' => 'value1',
87
- 'key2' => 'value2',
88
- 'key3' => 'value3',
89
- 'key4' => {
90
- 'nested_key1' => 'nested_value1',
91
- 'nested_key2' => 'nested_value2'
86
+ "key1" => "value1",
87
+ "key2" => "value2",
88
+ "key3" => "value3",
89
+ "key4" => {
90
+ "nested_key1" => "nested_value1",
91
+ "nested_key2" => "nested_value2"
92
92
  }
93
93
  }
94
94
 
95
95
  expected_map = {
96
- key1: 'value1',
97
- key2: 'value2',
98
- key3: 'value3',
96
+ key1: "value1",
97
+ key2: "value2",
98
+ key3: "value3",
99
99
  key4: {
100
- nested_key1: 'nested_value1',
101
- nested_key2: 'nested_value2'
100
+ nested_key1: "nested_value1",
101
+ nested_key2: "nested_value2"
102
102
  }
103
103
  }
104
104
 
@@ -107,22 +107,22 @@ module Mint
107
107
 
108
108
  it "recursively downcases all keys if specified" do
109
109
  capitalized_map = {
110
- 'Key1' => 'value1',
111
- 'Key2' => 'value2',
112
- 'Key3' => 'value3',
113
- 'Key4' => {
114
- 'Nested_key1' => 'nested_value1',
115
- 'Nested_key2' => 'nested_value2'
110
+ "Key1" => "value1",
111
+ "Key2" => "value2",
112
+ "Key3" => "value3",
113
+ "Key4" => {
114
+ "Nested_key1" => "nested_value1",
115
+ "Nested_key2" => "nested_value2"
116
116
  }
117
117
  }
118
118
 
119
119
  expected_map = {
120
- key1: 'value1',
121
- key2: 'value2',
122
- key3: 'value3',
120
+ key1: "value1",
121
+ key2: "value2",
122
+ key3: "value3",
123
123
  key4: {
124
- nested_key1: 'nested_value1',
125
- nested_key2: 'nested_value2'
124
+ nested_key1: "nested_value1",
125
+ nested_key2: "nested_value2"
126
126
  }
127
127
  }
128
128
 
@@ -130,28 +130,28 @@ module Mint
130
130
  end
131
131
  end
132
132
 
133
- describe "#listify" do
133
+ describe ".listify" do
134
134
  it "joins a list of three or more with an ampersand, without the Oxford comma" do
135
- Helpers.listify(['Alex', 'Chris', 'John']).should ==
136
- 'Alex, Chris & John'
135
+ Helpers.listify(["Alex", "Chris", "John"]).should ==
136
+ "Alex, Chris & John"
137
137
  end
138
138
 
139
139
  it "joins a list of two with an ampersand" do
140
- Helpers.listify(['Alex', 'Chris']).should == 'Alex & Chris'
140
+ Helpers.listify(["Alex", "Chris"]).should == "Alex & Chris"
141
141
  end
142
142
 
143
143
  it "does not do anything to a list of one" do
144
- Helpers.listify(['Alex']).should == 'Alex'
144
+ Helpers.listify(["Alex"]).should == "Alex"
145
145
  end
146
146
  end
147
147
 
148
- describe "#standardize" do
148
+ describe ".standardize" do
149
149
  before do
150
150
  @nonstandard = {
151
- title: 'Title',
152
- author: 'David',
153
- editors: ['David', 'Jake'],
154
- barcode: 'Unique ID'
151
+ title: "Title",
152
+ author: "David",
153
+ editors: ["David", "Jake"],
154
+ barcode: "Unique ID"
155
155
  }
156
156
 
157
157
  @table = {
@@ -161,10 +161,10 @@ module Mint
161
161
  }
162
162
 
163
163
  @standard = {
164
- title: 'Title',
165
- creators: ['David'],
166
- collaborators: ['David', 'Jake'],
167
- uuid: 'Unique ID'
164
+ title: "Title",
165
+ creators: ["David"],
166
+ collaborators: ["David", "Jake"],
167
+ uuid: "Unique ID"
168
168
  }
169
169
  end
170
170
 
@@ -174,43 +174,61 @@ module Mint
174
174
  end
175
175
  end
176
176
 
177
- describe "#normalize_path" do
177
+ describe ".hashify" do
178
+ it "zips two lists of the same size into a Hash" do
179
+ Helpers.hashify([:one, :two, :three], [1, 2, 3]).should == {
180
+ one: 1,
181
+ two: 2,
182
+ three: 3
183
+ }
184
+ end
185
+ end
186
+
187
+ describe ".normalize_path" do
178
188
  it "handles two files in the same directory" do
179
- path1 = '~/file1'
180
- path2 = '~/file2'
189
+ path1 = "~/file1"
190
+ path2 = "~/file2"
181
191
  Helpers.normalize_path(path1, path2).should ==
182
- Pathname.new('../file1')
192
+ Pathname.new("../file1")
183
193
  end
184
194
 
185
195
  it "handles two files one directory apart" do
186
- path1 = '~/file1'
187
- path2 = '~/subdir/file2'
196
+ path1 = "~/file1"
197
+ path2 = "~/subdir/file2"
188
198
  Helpers.normalize_path(path1, path2).should ==
189
- Pathname.new('../../file1')
199
+ Pathname.new("../../file1")
190
200
  end
191
201
 
192
202
  it "handles two files linked only at the directory root" do
193
- path1 = '/home/david/file1'
194
- path2 = '/usr/local/src/file2'
203
+ path1 = "/home/david/file1"
204
+ path2 = "/usr/local/src/file2"
195
205
  Helpers.normalize_path(path1, path2).should ==
196
- Pathname.new('/home/david/file1')
206
+ Pathname.new("/home/david/file1")
197
207
  end
198
208
 
199
209
  it "returns nil for identical files" do
200
- path1 = '~/file1'
201
- path2 = '~/file1'
202
- Helpers.normalize_path(path1, path2).should == Pathname.new('.')
210
+ path1 = "~/file1"
211
+ path2 = "~/file1"
212
+ Helpers.normalize_path(path1, path2).should == Pathname.new(".")
203
213
  end
204
214
  end
205
215
 
206
- describe "#update_yaml!" do
207
- it "loads existing YAML data from file"
208
- it "combines existing YAML data with new data and writes to file"
216
+ describe ".update_yaml!" do
217
+ before do
218
+ File.open "example.yaml", "w" do |file|
219
+ file << "conflicting: foo\nnon-conflicting: bar"
220
+ end
221
+ end
222
+
223
+ it "combines specified data with data in YAML file and updates file" do
224
+ Helpers.update_yaml! "example.yaml", "conflicting" => "baz"
225
+ YAML.load_file("example.yaml")["conflicting"].should == "baz"
226
+ end
209
227
  end
210
228
 
211
- describe "#generate_temp_file!" do
229
+ describe ".generate_temp_file!" do
212
230
  before do
213
- @file = Helpers.generate_temp_file! 'content.md'
231
+ @file = Helpers.generate_temp_file! "content.md"
214
232
  @path = Pathname.new @file
215
233
  end
216
234
 
@@ -220,7 +238,7 @@ module Mint
220
238
 
221
239
  it "creates a temp file with the correct name and extension" do
222
240
  @path.basename.to_s.should =~ /content/
223
- @path.extname.should == '.md'
241
+ @path.extname.should == ".md"
224
242
  end
225
243
 
226
244
  it "fills the temp file with the specified content" do