fontcustom 1.0.1 → 1.1.0.pre
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 +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +1 -1
- data/TODO.md +6 -0
- data/lib/fontcustom.rb +1 -1
- data/lib/fontcustom/actions.rb +28 -0
- data/lib/fontcustom/cli.rb +16 -15
- data/lib/fontcustom/generator/font.rb +31 -35
- data/lib/fontcustom/generator/template.rb +49 -34
- data/lib/fontcustom/options.rb +17 -11
- data/lib/fontcustom/scripts/generate.py +1 -1
- data/lib/fontcustom/templates/_fontcustom-bootstrap-ie7.scss +4 -3
- data/lib/fontcustom/templates/_fontcustom-bootstrap.scss +9 -14
- data/lib/fontcustom/templates/_fontcustom.scss +8 -14
- data/lib/fontcustom/templates/fontcustom-bootstrap-ie7.css +3 -2
- data/lib/fontcustom/templates/fontcustom-bootstrap.css +9 -8
- data/lib/fontcustom/templates/fontcustom-preview.html +2 -3
- data/lib/fontcustom/templates/fontcustom.css +7 -7
- data/lib/fontcustom/templates/fontcustom.yml +25 -66
- data/lib/fontcustom/util.rb +108 -31
- data/lib/fontcustom/version.rb +1 -1
- data/lib/fontcustom/watcher.rb +24 -8
- data/spec/fixtures/{mixed-output → generators}/.fontcustom-data +0 -0
- data/spec/fixtures/{mixed-output → generators/mixed-output}/another-font.ttf +0 -0
- data/spec/fixtures/{mixed-output → generators/mixed-output}/dont-delete-me.bro +0 -0
- data/spec/fixtures/{mixed-output → generators/mixed-output}/fontcustom.css +0 -0
- data/spec/fixtures/{mixed-output → generators/mixed-output}/fontcustom_cc5ce52f2ae4f9ce2e7ee8131bbfee1e.eot +0 -0
- data/spec/fixtures/{mixed-output → generators/mixed-output}/fontcustom_cc5ce52f2ae4f9ce2e7ee8131bbfee1e.svg +0 -0
- data/spec/fixtures/{mixed-output → generators/mixed-output}/fontcustom_cc5ce52f2ae4f9ce2e7ee8131bbfee1e.ttf +0 -0
- data/spec/fixtures/{mixed-output → generators/mixed-output}/fontcustom_cc5ce52f2ae4f9ce2e7ee8131bbfee1e.woff +0 -0
- data/spec/fixtures/{not-a-dir → shared/not-a-dir} +0 -0
- data/spec/fixtures/shared/templates/custom.css +1 -0
- data/spec/fixtures/shared/templates/regular.css +1 -0
- data/spec/fixtures/{empty → shared/vectors-empty}/no_vectors_here.txt +0 -0
- data/spec/fixtures/{vectors → shared/vectors}/C.svg +0 -0
- data/spec/fixtures/{vectors → shared/vectors}/D.svg +0 -0
- data/spec/fixtures/vectors/a_R3ally-eXotic f1Le Name.svg b/data/spec/fixtures/shared/vectors/a_R3ally-eXotic f1Le → Name.svg +0 -0
- data/spec/fixtures/util/config-is-in-dir/fontcustom.yml +1 -0
- data/spec/fixtures/util/fontcustom-malformed.yml +1 -0
- data/spec/fixtures/{fontcustom.yml → util/fontcustom.yml} +0 -0
- data/spec/fixtures/util/rails-like/config/fontcustom.yml +1 -0
- data/spec/fontcustom/actions_spec.rb +22 -0
- data/spec/fontcustom/generator/font_spec.rb +107 -62
- data/spec/fontcustom/generator/template_spec.rb +124 -29
- data/spec/fontcustom/util_spec.rb +299 -53
- data/spec/fontcustom/watcher_spec.rb +56 -10
- data/spec/spec_helper.rb +8 -3
- metadata +46 -34
- data/spec/fixtures/empty-data/.fontcustom-data +0 -0
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
.foo { color: black; }
|
@@ -0,0 +1 @@
|
|
1
|
+
.foo { color: blue; }
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
font_name: Config Is in Dir
|
@@ -0,0 +1 @@
|
|
1
|
+
font_name: Custom: Name From Config
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
font_name: Rails Like
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Fontcustom::Actions do
|
4
|
+
class Generator
|
5
|
+
include Fontcustom::Actions
|
6
|
+
attr_accessor :opts
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@opts = { :project_root => fixture, :verbose => true }
|
10
|
+
@shell = Thor::Shell::Color.new
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
context "#say_changed" do
|
15
|
+
it "should strip :project_root from changed paths" do
|
16
|
+
changed = %w|a b c|.map { |file| fixture(file) }
|
17
|
+
gen = Generator.new
|
18
|
+
output = capture(:stdout) { gen.say_changed(:success, changed) }
|
19
|
+
output.should_not match(fixture)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -6,63 +6,78 @@ describe Fontcustom::Generator::Font do
|
|
6
6
|
Fontcustom::Generator::Font.new([opts])
|
7
7
|
end
|
8
8
|
|
9
|
-
context "#
|
10
|
-
it "should
|
11
|
-
options = {
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
gen
|
34
|
-
gen.
|
35
|
-
gen.should_receive(:add_file).with(fixture("create-me") + "/.fontcustom-data", anything)
|
36
|
-
gen.check_output
|
9
|
+
context "#prepare_output_dirs" do
|
10
|
+
it "should create output dir if it doesn't exist" do
|
11
|
+
options = {
|
12
|
+
:project_root => fixture,
|
13
|
+
:input => "shared/vectors",
|
14
|
+
:output => "create-me"
|
15
|
+
}
|
16
|
+
gen = generator options
|
17
|
+
gen.stub(:empty_directory)
|
18
|
+
gen.should_receive(:empty_directory).with(fixture("create-me"), anything)
|
19
|
+
gen.prepare_output_dirs
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should create dirs for multiple output dirs" do
|
23
|
+
options = {
|
24
|
+
:project_root => fixture,
|
25
|
+
:input => "shared/vectors",
|
26
|
+
:output => {
|
27
|
+
:fonts => "assets/fonts",
|
28
|
+
:css => "assets/stylesheets"
|
29
|
+
}
|
30
|
+
}
|
31
|
+
gen = generator options
|
32
|
+
gen.stub(:empty_directory)
|
33
|
+
gen.should_receive(:empty_directory).twice
|
34
|
+
gen.prepare_output_dirs
|
37
35
|
end
|
38
36
|
end
|
39
37
|
|
40
38
|
context "#get_data" do
|
41
|
-
it "should assign empty data model if
|
42
|
-
|
43
|
-
|
39
|
+
it "should assign empty data model if data file is empty or missing" do
|
40
|
+
options = {
|
41
|
+
:project_root => fixture,
|
42
|
+
:input => "shared/vectors"
|
43
|
+
}
|
44
|
+
gen = generator options
|
45
|
+
gen.get_data
|
46
|
+
data = gen.instance_variable_get("@data")
|
44
47
|
data.should == Fontcustom::DATA_MODEL
|
45
48
|
end
|
46
49
|
|
47
50
|
it "should assign @data from data file" do
|
48
|
-
|
49
|
-
|
51
|
+
options = {
|
52
|
+
:project_root => fixture,
|
53
|
+
:input => "shared/vectors",
|
54
|
+
:output => "mixed-output"
|
55
|
+
}
|
56
|
+
gen = generator options
|
57
|
+
gen.get_data
|
58
|
+
data = gen.instance_variable_get("@data")
|
50
59
|
data[:fonts] =~ data_file_contents[:fonts]
|
51
60
|
end
|
52
61
|
end
|
53
62
|
|
54
63
|
context "#reset_output" do
|
55
64
|
subject do
|
56
|
-
|
65
|
+
options = {
|
66
|
+
:project_root => fixture,
|
67
|
+
:input => "shared/vectors",
|
68
|
+
:output => "mixed-output",
|
69
|
+
:verbose => false
|
70
|
+
}
|
71
|
+
gen = generator options
|
57
72
|
gen.stub :remove_file
|
58
|
-
Fontcustom::Util.stub :clear_file
|
59
73
|
gen.stub :append_to_file
|
74
|
+
gen.stub :clear_file
|
60
75
|
gen.instance_variable_set(:@data, data_file_contents)
|
61
76
|
gen
|
62
77
|
end
|
63
78
|
|
64
79
|
it "should delete fonts from @data[:fonts]" do
|
65
|
-
subject.should_receive(:remove_file).exactly(4).times.with(/fontcustom_cc5ce52f2ae4f9ce2e7ee8131bbfee1e/,
|
80
|
+
subject.should_receive(:remove_file).exactly(4).times.with(/fontcustom_cc5ce52f2ae4f9ce2e7ee8131bbfee1e/, anything)
|
66
81
|
subject.reset_output
|
67
82
|
end
|
68
83
|
|
@@ -77,10 +92,10 @@ describe Fontcustom::Generator::Font do
|
|
77
92
|
subject.reset_output
|
78
93
|
subject.instance_variable_get(:@data)[:fonts].should be_empty
|
79
94
|
end
|
80
|
-
|
95
|
+
|
81
96
|
it "should update the data file" do
|
82
|
-
file =
|
83
|
-
|
97
|
+
file = fixture(".fontcustom-data")
|
98
|
+
subject.should_receive(:clear_file).once.with(file)
|
84
99
|
subject.should_receive(:append_to_file).once.with(file, /"fonts":/, :verbose => false)
|
85
100
|
subject.reset_output
|
86
101
|
end
|
@@ -93,18 +108,23 @@ describe Fontcustom::Generator::Font do
|
|
93
108
|
|
94
109
|
context "#generate" do
|
95
110
|
subject do
|
96
|
-
gen = generator(
|
111
|
+
gen = generator(
|
112
|
+
:project_root => fixture,
|
113
|
+
:input => "shared/vectors",
|
114
|
+
:output => "mixed-output",
|
115
|
+
:verbose => false
|
116
|
+
)
|
97
117
|
gen.stub(:"`").and_return fontforge_output
|
98
118
|
gen
|
99
119
|
end
|
100
|
-
|
120
|
+
|
101
121
|
it "should call fontforge" do
|
102
122
|
subject.should_receive(:"`").with(/fontforge -script/)
|
103
123
|
subject.generate
|
104
124
|
end
|
105
125
|
|
106
126
|
it "should pass options to fontforge" do
|
107
|
-
subject.should_receive(:"`").with(/#{fixture("vectors")}.+#{fixture("mixed-output")}/)
|
127
|
+
subject.should_receive(:"`").with(/#{fixture("shared/vectors")}.+#{fixture("mixed-output")}/)
|
108
128
|
subject.generate
|
109
129
|
end
|
110
130
|
|
@@ -115,65 +135,90 @@ describe Fontcustom::Generator::Font do
|
|
115
135
|
end
|
116
136
|
|
117
137
|
it "should raise error if fontforge fails" do
|
118
|
-
gen = generator(
|
138
|
+
gen = generator(
|
139
|
+
:project_root => fixture,
|
140
|
+
:input => "shared/vectors",
|
141
|
+
:output => "fake-dir-should-cause-failure",
|
142
|
+
:debug => true
|
143
|
+
)
|
119
144
|
expect { capture(:stdout) { gen.generate } }.to raise_error Fontcustom::Error, /failed unexpectedly/
|
120
145
|
end
|
121
146
|
end
|
122
147
|
|
123
148
|
context "#collect_data" do
|
124
149
|
it "should assign @data from @json" do
|
125
|
-
gen = generator(
|
150
|
+
gen = generator(
|
151
|
+
:project_root => fixture,
|
152
|
+
:input => "shared/vectors",
|
153
|
+
:output => "output"
|
154
|
+
)
|
126
155
|
gen.instance_variable_set(:@data, Fontcustom::DATA_MODEL)
|
127
156
|
gen.instance_variable_set(:@json, data_file_contents.to_json)
|
128
157
|
gen.collect_data
|
129
158
|
data = gen.instance_variable_get(:@data)
|
130
159
|
data[:glyphs].should =~ ["c", "d", "a_r3ally-exotic-f1le-name"]
|
131
|
-
data[:file_name].should == "fontcustom_cc5ce52f2ae4f9ce2e7ee8131bbfee1e"
|
132
160
|
data[:fonts].should =~ [
|
133
|
-
"fontcustom_cc5ce52f2ae4f9ce2e7ee8131bbfee1e.eot",
|
134
|
-
"fontcustom_cc5ce52f2ae4f9ce2e7ee8131bbfee1e.svg",
|
135
|
-
"fontcustom_cc5ce52f2ae4f9ce2e7ee8131bbfee1e.ttf",
|
136
|
-
"fontcustom_cc5ce52f2ae4f9ce2e7ee8131bbfee1e.woff"
|
161
|
+
fixture("output/fontcustom_cc5ce52f2ae4f9ce2e7ee8131bbfee1e.eot"),
|
162
|
+
fixture("output/fontcustom_cc5ce52f2ae4f9ce2e7ee8131bbfee1e.svg"),
|
163
|
+
fixture("output/fontcustom_cc5ce52f2ae4f9ce2e7ee8131bbfee1e.ttf"),
|
164
|
+
fixture("output/fontcustom_cc5ce52f2ae4f9ce2e7ee8131bbfee1e.woff")
|
137
165
|
]
|
138
166
|
end
|
139
167
|
end
|
140
168
|
|
141
169
|
context "#announce_files" do
|
142
170
|
it "should print generated files to console" do
|
143
|
-
gen = generator(
|
144
|
-
|
171
|
+
gen = generator(
|
172
|
+
:project_root => fixture,
|
173
|
+
:input => "shared/vectors",
|
174
|
+
:output => "output"
|
175
|
+
)
|
176
|
+
gen.instance_variable_set :@data, data_file_contents
|
145
177
|
stdout = capture(:stdout) { gen.announce_files }
|
146
|
-
stdout.should =~ /
|
178
|
+
stdout.should =~ /created.+\.(woff|ttf|eot|svg)/
|
147
179
|
end
|
148
180
|
|
149
181
|
it "should print nothing if verbose is false" do
|
150
|
-
gen = generator(
|
151
|
-
|
182
|
+
gen = generator(
|
183
|
+
:project_root => fixture,
|
184
|
+
:input => "shared/vectors",
|
185
|
+
:output => "output",
|
186
|
+
:verbose => false
|
187
|
+
)
|
188
|
+
gen.instance_variable_set :@data, data_file_contents
|
152
189
|
stdout = capture(:stdout) { gen.announce_files }
|
153
190
|
stdout.should == ""
|
154
191
|
end
|
155
192
|
end
|
156
193
|
|
157
194
|
context "#save_data" do
|
158
|
-
it "should update data file
|
159
|
-
gen = generator(
|
160
|
-
|
195
|
+
it "should update data file" do
|
196
|
+
gen = generator(
|
197
|
+
:project_root => fixture,
|
198
|
+
:input => "shared/vectors",
|
199
|
+
:output => "output"
|
200
|
+
)
|
201
|
+
gen.stub :clear_file
|
161
202
|
gen.stub :append_to_file
|
162
203
|
gen.instance_variable_set(:@data, data_file_contents)
|
163
|
-
file = File.join
|
164
|
-
|
204
|
+
file = File.join fixture(".fontcustom-data")
|
205
|
+
gen.should_receive(:clear_file).once.with(file)
|
165
206
|
gen.should_receive(:append_to_file).once.with do |path, content|
|
166
207
|
path.should == file
|
167
208
|
content.should match(/"fonts":/)
|
168
209
|
content.should match(/"glyphs":/)
|
169
|
-
content.should match(/"file_name":/)
|
170
210
|
end
|
171
211
|
gen.save_data
|
172
212
|
end
|
173
213
|
|
174
214
|
it "should be silent if verbose is false" do
|
175
|
-
gen = generator(
|
176
|
-
|
215
|
+
gen = generator(
|
216
|
+
:project_root => fixture,
|
217
|
+
:input => "shared/vectors",
|
218
|
+
:output => "output",
|
219
|
+
:verbose => false
|
220
|
+
)
|
221
|
+
gen.stub :clear_file
|
177
222
|
gen.stub :append_to_file
|
178
223
|
gen.instance_variable_set(:@data, data_file_contents)
|
179
224
|
stdout = capture(:stdout) { gen.save_data }
|
@@ -7,37 +7,42 @@ describe Fontcustom::Generator::Template do
|
|
7
7
|
end
|
8
8
|
|
9
9
|
context "#get_data" do
|
10
|
-
it "should raise error if data file doesn't exist" do
|
11
|
-
gen = generator
|
10
|
+
it "should raise error if data file doesn't exist" do
|
11
|
+
gen = generator(
|
12
|
+
:project_root => fixture,
|
13
|
+
:input => "shared/vectors"
|
14
|
+
)
|
12
15
|
expect { gen.get_data }.to raise_error Fontcustom::Error, /no \.fontcustom-data/
|
13
16
|
end
|
14
17
|
|
18
|
+
# TODO ensure data file is correct
|
15
19
|
it "should assign @data from data file" do
|
16
|
-
gen = generator
|
20
|
+
gen = generator(
|
21
|
+
:project_root => fixture("generators"),
|
22
|
+
:input => "../shared/vectors"
|
23
|
+
)
|
17
24
|
gen.get_data
|
18
25
|
gen.instance_variable_get(:@data)[:templates].should =~ data_file_contents[:templates]
|
19
26
|
end
|
20
27
|
end
|
21
28
|
|
22
|
-
context "#check_templates" do
|
23
|
-
it "should raise an error if no templates are given" do
|
24
|
-
gen = generator :templates => []
|
25
|
-
expect { gen.check_templates }.to raise_error Fontcustom::Error, /No templates were specified/
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
29
|
context "#reset_output" do
|
30
30
|
subject do
|
31
|
-
gen = generator
|
31
|
+
gen = generator(
|
32
|
+
:project_root => fixture("generators"),
|
33
|
+
:input => "../shared/vectors",
|
34
|
+
:output => "mixed-output",
|
35
|
+
:verbose => false
|
36
|
+
)
|
32
37
|
gen.stub :remove_file
|
33
|
-
|
38
|
+
gen.stub :clear_file
|
34
39
|
gen.stub :append_to_file
|
35
40
|
gen.instance_variable_set(:@data, data_file_contents)
|
36
41
|
gen
|
37
42
|
end
|
38
43
|
|
39
44
|
it "should delete files from @data[:templates]" do
|
40
|
-
subject.should_receive(:remove_file).once.with(/fontcustom\.css/,
|
45
|
+
subject.should_receive(:remove_file).once.with(/fontcustom\.css/, anything)
|
41
46
|
subject.reset_output
|
42
47
|
end
|
43
48
|
|
@@ -52,10 +57,10 @@ describe Fontcustom::Generator::Template do
|
|
52
57
|
subject.reset_output
|
53
58
|
subject.instance_variable_get(:@data)[:templates].should be_empty
|
54
59
|
end
|
55
|
-
|
60
|
+
|
56
61
|
it "should update the data file" do
|
57
|
-
file =
|
58
|
-
|
62
|
+
file = fixture("generators/.fontcustom-data")
|
63
|
+
subject.should_receive(:clear_file).once.with(file)
|
59
64
|
subject.should_receive(:append_to_file).once.with(file, /"templates":/, :verbose => false)
|
60
65
|
subject.reset_output
|
61
66
|
end
|
@@ -66,41 +71,131 @@ describe Fontcustom::Generator::Template do
|
|
66
71
|
end
|
67
72
|
end
|
68
73
|
|
74
|
+
context "#make_relative_paths" do
|
75
|
+
it "should assign :css_to_fonts and :preview_to_css" do
|
76
|
+
gen = generator(
|
77
|
+
:project_root => fixture,
|
78
|
+
:input => "shared/vectors",
|
79
|
+
:output => {:fonts => "foo/fonts", :css => "output/css", :preview => ""}
|
80
|
+
)
|
81
|
+
gen.instance_variable_set "@data", data_file_contents
|
82
|
+
gen.make_relative_paths
|
83
|
+
data = gen.instance_variable_get("@data")
|
84
|
+
data[:paths][:css_to_fonts].should match("../../foo/fonts")
|
85
|
+
data[:paths][:preview_to_css].should match("output/css/")
|
86
|
+
data[:paths][:preprocessor_to_fonts].should eq(data[:paths][:css_to_fonts])
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should assign :preprocessor_to_css if :preprocessor_font_path is set" do
|
90
|
+
gen = generator(
|
91
|
+
:project_root => fixture,
|
92
|
+
:preprocessor_font_path => "fonts/fontcustom",
|
93
|
+
:input => "shared/vectors",
|
94
|
+
:output => {:fonts => "foo/bar/fonts", :css => "output/css", :preview => ""}
|
95
|
+
)
|
96
|
+
gen.instance_variable_set "@data", data_file_contents
|
97
|
+
gen.make_relative_paths
|
98
|
+
data = gen.instance_variable_get("@data")
|
99
|
+
data[:paths][:preprocessor_to_fonts].should match("fonts/fontcustom")
|
100
|
+
end
|
101
|
+
|
102
|
+
it "should assign '.' when paths are the same" do
|
103
|
+
gen = generator(
|
104
|
+
:project_root => fixture,
|
105
|
+
:input => "shared/vectors",
|
106
|
+
:output => "output"
|
107
|
+
)
|
108
|
+
gen.instance_variable_set "@data", data_file_contents
|
109
|
+
gen.make_relative_paths
|
110
|
+
data = gen.instance_variable_get("@data")
|
111
|
+
data[:paths][:css_to_fonts].should match("./")
|
112
|
+
data[:paths][:preview_to_css].should match("./")
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
69
116
|
context "#generate" do
|
70
117
|
subject do
|
71
|
-
gen = generator
|
118
|
+
gen = generator(
|
119
|
+
:project_root => fixture("generators"),
|
120
|
+
:input => {:vectors => "../shared/vectors", :templates => "../shared/templates"},
|
121
|
+
:output => "mixed-output",
|
122
|
+
:templates => %W|scss css custom.css|,
|
123
|
+
:verbose => false
|
124
|
+
)
|
72
125
|
gen.instance_variable_set :@data, data_file_contents
|
73
126
|
gen.stub :template
|
74
|
-
|
127
|
+
gen.stub :clear_file
|
75
128
|
gen.stub :append_to_file
|
76
129
|
gen
|
77
130
|
end
|
78
131
|
|
79
132
|
it "should call #template for each template" do
|
80
|
-
subject.should_receive(:template).exactly(3).times
|
133
|
+
subject.should_receive(:template).exactly(3).times do |*args|
|
134
|
+
args[1].should match(/(fontcustom\.css|_fontcustom\.scss|custom\.css)/)
|
135
|
+
end
|
81
136
|
subject.generate
|
82
137
|
end
|
83
138
|
|
84
|
-
it "should update data file" do
|
85
|
-
file =
|
86
|
-
|
139
|
+
it "should update data file with generated templates" do
|
140
|
+
file = fixture("generators/.fontcustom-data")
|
141
|
+
subject.should_receive(:clear_file).once.with(file)
|
87
142
|
subject.should_receive(:append_to_file).once.with do |path, content|
|
88
143
|
path.should == file
|
89
144
|
content.should match(/fontcustom\.css/)
|
90
145
|
content.should match(/_fontcustom\.scss/)
|
91
|
-
content.should match(/
|
146
|
+
content.should match(/custom\.css/)
|
92
147
|
end
|
93
148
|
subject.generate
|
94
149
|
end
|
95
150
|
|
96
151
|
it "should be silent if verbose is false" do
|
97
|
-
|
98
|
-
gen.instance_variable_set :@data, data_file_contents
|
99
|
-
gen.stub :template
|
100
|
-
Fontcustom::Util.stub :clear_file
|
101
|
-
gen.stub :append_to_file
|
102
|
-
stdout = capture(:stdout) { gen.generate }
|
152
|
+
stdout = capture(:stdout) { subject.generate }
|
103
153
|
stdout.should == ""
|
104
154
|
end
|
155
|
+
|
156
|
+
context "when various output locations are given" do
|
157
|
+
subject do
|
158
|
+
gen = generator(
|
159
|
+
:project_root => fixture,
|
160
|
+
:input => {:vectors => "shared/vectors", :templates => "shared/templates"},
|
161
|
+
:output => {:fonts => "output/fonts", :css => "output/css", :preview => "output/views", "custom.css" => "output/custom"},
|
162
|
+
:templates => %W|scss preview css custom.css regular.css|,
|
163
|
+
:verbose => false
|
164
|
+
)
|
165
|
+
gen.instance_variable_set :@data, data_file_contents
|
166
|
+
gen.stub :template
|
167
|
+
gen.stub :clear_file
|
168
|
+
gen.stub :append_to_file
|
169
|
+
gen
|
170
|
+
end
|
171
|
+
|
172
|
+
it "should output custom templates to their matching :output paths" do
|
173
|
+
subject.should_receive(:template).exactly(5).times do |*args|
|
174
|
+
if File.basename(args[0]) == "custom.css"
|
175
|
+
args[1].should == fixture("output/custom/custom.css")
|
176
|
+
end
|
177
|
+
end
|
178
|
+
subject.generate
|
179
|
+
end
|
180
|
+
|
181
|
+
it "should output css templates into :css" do
|
182
|
+
subject.should_receive(:template).exactly(5).times do |*args|
|
183
|
+
name = File.basename(args[0])
|
184
|
+
if %w|_fontcustom.scss fontcustom.css regular.css|.include? name
|
185
|
+
args[1].should match(/output\/css\/#{name}/)
|
186
|
+
end
|
187
|
+
end
|
188
|
+
subject.generate
|
189
|
+
end
|
190
|
+
|
191
|
+
it "should output fontcustom-preview.html into :preview" do
|
192
|
+
subject.should_receive(:template).exactly(5).times do |*args|
|
193
|
+
if File.basename(args[0]) == "fontcustom-preview.html"
|
194
|
+
args[1].should == fixture("output/views/fontcustom-preview.html")
|
195
|
+
end
|
196
|
+
end
|
197
|
+
subject.generate
|
198
|
+
end
|
199
|
+
end
|
105
200
|
end
|
106
201
|
end
|