fontcustom 1.1.0.pre2 → 1.1.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.
@@ -24,17 +24,6 @@ describe Fontcustom::Options do
24
24
 
25
25
  context ".set_config_path" do
26
26
  context "when :config is set" do
27
- # TODO abstract this into Util?
28
- it "should follow ../../ relative paths" do
29
- args = {
30
- :project_root => fixture("shared/vectors"),
31
- :config => "../../options"
32
- }
33
- o = options args
34
- o.send :set_config_path
35
- o.instance_variable_get(:@config).should == fixture("options/fontcustom.yml")
36
- end
37
-
38
27
  it "should use options[:config] if it's a file" do
39
28
  args = {
40
29
  :project_root => fixture,
@@ -61,7 +50,7 @@ describe Fontcustom::Options do
61
50
  :config => "does-not-exist"
62
51
  }
63
52
  o = options args
64
- expect { o.send :set_config_path }.to raise_error Fontcustom::Error, /configuration file was not found/
53
+ expect { o.send :set_config_path }.to raise_error Fontcustom::Error, /configuration file wasn't found/
65
54
  end
66
55
  end
67
56
 
@@ -91,7 +80,7 @@ describe Fontcustom::Options do
91
80
 
92
81
  context ".load_config" do
93
82
  def args
94
- { :project_root => fixture, :verbose => false }
83
+ { :project_root => fixture, :quiet => true }
95
84
  end
96
85
 
97
86
  it "should raise error if fontcustom.yml isn't valid" do
@@ -113,6 +102,20 @@ describe Fontcustom::Options do
113
102
  o.send :load_config
114
103
  o.instance_variable_get(:@config_options).should == {}
115
104
  end
105
+
106
+ it "should report which configuration file it's using" do
107
+ o = options
108
+ o.instance_variable_set :@config, fixture("options/any-file-name.yml")
109
+ stdout = capture(:stdout) { o.send :load_config }
110
+ stdout.should match /options\/any-file-name\.yml/
111
+ end
112
+
113
+ it "should warn if no configuration file is used" do
114
+ o = options
115
+ o.instance_variable_set :@config, false
116
+ stdout = capture(:stdout) { o.send :load_config }
117
+ stdout.should match /No configuration/
118
+ end
116
119
  end
117
120
 
118
121
  context ".merge_options" do
@@ -156,6 +159,7 @@ describe Fontcustom::Options do
156
159
  o = options
157
160
  o.instance_variable_set :@config, "path/to/config/fontcustom.yml"
158
161
  o.instance_variable_set :@data_cache, nil
162
+ o.remove_instance_variable :@cli_options
159
163
  o.send :set_data_path
160
164
  o.instance_variable_get(:@data_cache).should == "path/to/config/.fontcustom-data"
161
165
  end
@@ -166,6 +170,7 @@ describe Fontcustom::Options do
166
170
  o = options
167
171
  o.instance_variable_set :@project_root, fixture
168
172
  o.instance_variable_set :@input, "shared/vectors-empty"
173
+ o.remove_instance_variable :@cli_options
169
174
  expect { o.send :set_input_paths }.to raise_error Fontcustom::Error, /doesn't contain any vectors/
170
175
  end
171
176
 
@@ -175,6 +180,7 @@ describe Fontcustom::Options do
175
180
  o = options
176
181
  o.instance_variable_set :@project_root, fixture
177
182
  o.instance_variable_set :@input, hash
183
+ o.remove_instance_variable :@cli_options
178
184
  o.send :set_input_paths
179
185
  input = o.instance_variable_get :@input
180
186
  input[:templates].should == fixture("shared/vectors")
@@ -185,6 +191,7 @@ describe Fontcustom::Options do
185
191
  o = options
186
192
  o.instance_variable_set :@project_root, fixture
187
193
  o.instance_variable_set :@input, hash
194
+ o.remove_instance_variable :@cli_options
188
195
  o.send :set_input_paths
189
196
  input = o.instance_variable_get :@input
190
197
  input[:templates].should == fixture("shared/templates")
@@ -195,7 +202,8 @@ describe Fontcustom::Options do
195
202
  o = options
196
203
  o.instance_variable_set :@project_root, fixture
197
204
  o.instance_variable_set :@input, hash
198
- expect { o.send :set_input_paths }.to raise_error Fontcustom::Error, /contain a "vectors" key/
205
+ o.remove_instance_variable :@cli_options
206
+ expect { o.send :set_input_paths }.to raise_error Fontcustom::Error, /contain a :vectors key/
199
207
  end
200
208
 
201
209
  it "should raise an error if :vectors doesn't point to an existing directory" do
@@ -203,19 +211,9 @@ describe Fontcustom::Options do
203
211
  o = options
204
212
  o.instance_variable_set :@project_root, fixture
205
213
  o.instance_variable_set :@input, hash
214
+ o.remove_instance_variable :@cli_options
206
215
  expect { o.send :set_input_paths }.to raise_error Fontcustom::Error, /should be a directory/
207
216
  end
208
-
209
- it "should follow ../../ relative paths" do
210
- hash = { :vectors => "../../shared/vectors", :templates => "../../shared/templates" }
211
- o = options
212
- o.instance_variable_set :@project_root, fixture("generators/mixed-output")
213
- o.instance_variable_set :@input, hash
214
- o.send :set_input_paths
215
- input = o.instance_variable_get(:@input)
216
- input[:vectors].should == fixture("shared/vectors")
217
- input[:templates].should == fixture("shared/templates")
218
- end
219
217
  end
220
218
 
221
219
  context "when @input is a string" do
@@ -223,16 +221,18 @@ describe Fontcustom::Options do
223
221
  o = options
224
222
  o.instance_variable_set :@project_root, fixture
225
223
  o.instance_variable_set :@input, "shared/vectors"
224
+ o.remove_instance_variable :@cli_options
226
225
  o.send :set_input_paths
227
226
  input = o.instance_variable_get :@input
228
- input.should have_key("vectors")
229
- input.should have_key("templates")
227
+ input.should have_key(:vectors)
228
+ input.should have_key(:templates)
230
229
  end
231
230
 
232
231
  it "should set :templates to match :vectors" do
233
232
  o = options
234
233
  o.instance_variable_set :@project_root, fixture
235
234
  o.instance_variable_set :@input, "shared/vectors"
235
+ o.remove_instance_variable :@cli_options
236
236
  o.send :set_input_paths
237
237
  input = o.instance_variable_get :@input
238
238
  input[:templates].should == fixture("shared/vectors")
@@ -242,18 +242,9 @@ describe Fontcustom::Options do
242
242
  o = options
243
243
  o.instance_variable_set :@project_root, fixture
244
244
  o.instance_variable_set :@input, "shared/not-a-dir"
245
+ o.remove_instance_variable :@cli_options
245
246
  expect { o.send :set_input_paths }.to raise_error Fontcustom::Error, /should be a directory/
246
247
  end
247
-
248
- it "should follow ../../ relative paths" do
249
- o = options
250
- o.instance_variable_set :@project_root, fixture("generators/mixed-output")
251
- o.instance_variable_set :@input, "../../shared/vectors"
252
- o.send :set_input_paths
253
- input = o.instance_variable_get(:@input)
254
- input[:vectors].should == fixture("shared/vectors")
255
- input[:templates].should == fixture("shared/vectors")
256
- end
257
248
  end
258
249
  end
259
250
 
@@ -265,6 +256,7 @@ describe Fontcustom::Options do
265
256
  o.instance_variable_set :@project_root, fixture
266
257
  o.instance_variable_set :@font_name, "Test-Font"
267
258
  o.instance_variable_set :@output, nil
259
+ o.remove_instance_variable :@cli_options
268
260
  o.send :set_output_paths
269
261
  output = o.instance_variable_get :@output
270
262
  output[:fonts].should == fixture("Test-Font")
@@ -275,6 +267,7 @@ describe Fontcustom::Options do
275
267
  o.instance_variable_set :@project_root, fixture
276
268
  o.instance_variable_set :@font_name, "Test-Font"
277
269
  o.instance_variable_set :@output, nil
270
+ o.remove_instance_variable :@cli_options
278
271
  stdout = capture(:stdout) { o.send :set_output_paths }
279
272
  stdout.should match("Test-Font")
280
273
  end
@@ -286,6 +279,7 @@ describe Fontcustom::Options do
286
279
  o = options
287
280
  o.instance_variable_set :@project_root, fixture
288
281
  o.instance_variable_set :@output, hash
282
+ o.remove_instance_variable :@cli_options
289
283
  o.send :set_output_paths
290
284
  output = o.instance_variable_get :@output
291
285
  output[:css].should == fixture("output/fonts")
@@ -301,6 +295,7 @@ describe Fontcustom::Options do
301
295
  o = options
302
296
  o.instance_variable_set :@project_root, fixture
303
297
  o.instance_variable_set :@output, hash
298
+ o.remove_instance_variable :@cli_options
304
299
  o.send :set_output_paths
305
300
  output = o.instance_variable_get :@output
306
301
  output[:css].should == fixture("output/styles")
@@ -315,9 +310,10 @@ describe Fontcustom::Options do
315
310
  o = options
316
311
  o.instance_variable_set :@project_root, fixture
317
312
  o.instance_variable_set :@output, hash
313
+ o.remove_instance_variable :@cli_options
318
314
  o.send :set_output_paths
319
315
  output = o.instance_variable_get :@output
320
- output["special.js"].should == fixture("assets/javascripts")
316
+ output[:"special.js"].should == fixture("assets/javascripts")
321
317
  end
322
318
 
323
319
  it "should raise an error if :fonts isn't set" do
@@ -325,23 +321,8 @@ describe Fontcustom::Options do
325
321
  o = options
326
322
  o.instance_variable_set :@project_root, fixture
327
323
  o.instance_variable_set :@output, hash
328
- expect { o.send :set_output_paths }.to raise_error Fontcustom::Error, /contain a "fonts" key/
329
- end
330
-
331
- it "should follow ../../ relative paths" do
332
- hash = {
333
- :fonts => "../../output/fonts",
334
- :css => "../../output/css",
335
- :preview => "../../output/views"
336
- }
337
- o = options
338
- o.instance_variable_set :@project_root, fixture("generators/mixed-output")
339
- o.instance_variable_set :@output, hash
340
- o.send :set_output_paths
341
- output = o.instance_variable_get :@output
342
- output[:fonts].should == fixture("output/fonts")
343
- output[:css].should == fixture("output/css")
344
- output[:preview].should == fixture("output/views")
324
+ o.remove_instance_variable :@cli_options
325
+ expect { o.send :set_output_paths }.to raise_error Fontcustom::Error, /contain a :fonts key/
345
326
  end
346
327
  end
347
328
 
@@ -350,18 +331,20 @@ describe Fontcustom::Options do
350
331
  o = options
351
332
  o.instance_variable_set :@project_root, fixture
352
333
  o.instance_variable_set :@output, "output/fonts"
334
+ o.remove_instance_variable :@cli_options
353
335
  o.send :set_output_paths
354
336
  output = o.instance_variable_get :@output
355
337
  output.should be_a(Hash)
356
- output.should have_key("fonts")
357
- output.should have_key("css")
358
- output.should have_key("preview")
338
+ output.should have_key(:fonts)
339
+ output.should have_key(:css)
340
+ output.should have_key(:preview)
359
341
  end
360
342
 
361
343
  it "should set :css and :preview to match :fonts" do
362
344
  o = options
363
345
  o.instance_variable_set :@project_root, fixture
364
346
  o.instance_variable_set :@output, "output/fonts"
347
+ o.remove_instance_variable :@cli_options
365
348
  o.send :set_output_paths
366
349
  output = o.instance_variable_get :@output
367
350
  output[:css].should == fixture("output/fonts")
@@ -372,19 +355,9 @@ describe Fontcustom::Options do
372
355
  o = options
373
356
  o.instance_variable_set :@project_root, fixture
374
357
  o.instance_variable_set :@output, "shared/not-a-dir"
358
+ o.remove_instance_variable :@cli_options
375
359
  expect { o.send :set_output_paths }.to raise_error Fontcustom::Error, /directory, not a file/
376
360
  end
377
-
378
- it "should follow ../../ relative paths" do
379
- o = options
380
- o.instance_variable_set :@project_root, fixture("generators/mixed-output")
381
- o.instance_variable_set :@output, "../../something/else"
382
- o.send :set_output_paths
383
- output = o.instance_variable_get :@output
384
- output[:fonts].should == fixture("something/else")
385
- output[:css].should == fixture("something/else")
386
- output[:preview].should == fixture("something/else")
387
- end
388
361
  end
389
362
  end
390
363
 
@@ -394,6 +367,7 @@ describe Fontcustom::Options do
394
367
  o.instance_variable_set :@project_root, fixture
395
368
  o.instance_variable_set :@input, { :templates => "shared/templates" }
396
369
  o.instance_variable_set :@templates, %w|preview css scss bootstrap bootstrap-scss bootstrap-ie7 bootstrap-ie7-scss|
370
+ o.remove_instance_variable :@cli_options
397
371
  o.send :set_template_paths
398
372
  templates = o.instance_variable_get :@templates
399
373
  templates.should =~ [
@@ -412,6 +386,7 @@ describe Fontcustom::Options do
412
386
  o.instance_variable_set :@project_root, fixture
413
387
  o.instance_variable_set :@input, { :templates => fixture("shared/templates") }
414
388
  o.instance_variable_set :@templates, %w|custom.css|
389
+ o.remove_instance_variable :@cli_options
415
390
  o.send :set_template_paths
416
391
  templates = o.instance_variable_get :@templates
417
392
  templates.should =~ [fixture("shared/templates/custom.css")]
@@ -422,6 +397,7 @@ describe Fontcustom::Options do
422
397
  o.instance_variable_set :@project_root, fixture
423
398
  o.instance_variable_set :@input, { :templates => "shared/templates" }
424
399
  o.instance_variable_set :@templates, %w|fake-template.txt|
400
+ o.remove_instance_variable :@cli_options
425
401
  expect { o.send :set_template_paths }.to raise_error Fontcustom::Error, /does not exist/
426
402
  end
427
403
  end
@@ -6,7 +6,7 @@ describe Fontcustom::Util do
6
6
  attr_accessor :cli_options
7
7
 
8
8
  def initialize
9
- @cli_options = { :project_root => fixture, :verbose => true }
9
+ @cli_options = { :project_root => fixture, :quiet => false }
10
10
  @shell = Thor::Shell::Color.new
11
11
  end
12
12
  end
@@ -27,24 +27,45 @@ describe Fontcustom::Util do
27
27
  output.should_not match(fixture)
28
28
  end
29
29
 
30
- it "should not respond if :verbose is false" do
30
+ it "should not respond if :quiet is true " do
31
31
  changed = %w|a b c|.map { |file| fixture(file) }
32
32
  gen = Generator.new
33
- gen.cli_options[:verbose] = false
33
+ gen.cli_options[:quiet] = true
34
34
  output = capture(:stdout) { gen.say_changed(:success, changed) }
35
35
  output.should == ""
36
36
  end
37
37
  end
38
38
 
39
39
  context "#say_message" do
40
- it "should not respond if :verbose is false" do
40
+ it "should not respond if :quiet is true" do
41
41
  gen = Generator.new
42
- gen.cli_options[:verbose] = false
42
+ gen.cli_options[:quiet] = true
43
43
  output = capture(:stdout) { gen.say_message(:test, "Hello") }
44
44
  output.should == ""
45
45
  end
46
46
  end
47
47
 
48
+ context "#expand_path" do
49
+ it "should leave absolute paths alone" do
50
+ gen = Generator.new
51
+ path = gen.expand_path "/absolute/path"
52
+ path.should == "/absolute/path"
53
+ end
54
+
55
+ it "should prepend paths with :project_root" do
56
+ gen = Generator.new
57
+ path = gen.expand_path "generators"
58
+ path.should == fixture("generators")
59
+ end
60
+
61
+ it "should follow ../../ relative paths" do
62
+ gen = Generator.new
63
+ gen.cli_options[:project_root] = fixture("shared/vectors")
64
+ path = gen.expand_path "../../generators"
65
+ path.should == fixture("generators")
66
+ end
67
+ end
68
+
48
69
  context "#relative_to_root" do
49
70
  it "should trim project root from paths" do
50
71
  gen = Generator.new
@@ -3,7 +3,7 @@ require "fileutils"
3
3
  require "fontcustom/watcher"
4
4
 
5
5
  describe Fontcustom::Watcher do
6
- # Silence messages without passing :verbose => false to everything
6
+ # Silence messages without passing :quiet => true to everything
7
7
  before(:each) do
8
8
  Fontcustom::Options.any_instance.stub :say_message
9
9
  end
@@ -28,7 +28,7 @@ describe Fontcustom::Watcher do
28
28
  # silence output
29
29
  capture(:stdout) do
30
30
  w.watch
31
- w.stop
31
+ w.send :stop
32
32
  end
33
33
  end
34
34
 
@@ -43,7 +43,7 @@ describe Fontcustom::Watcher do
43
43
  )
44
44
  capture(:stdout) do
45
45
  w.watch
46
- w.stop
46
+ w.send :stop
47
47
  end
48
48
  end
49
49
 
@@ -62,7 +62,7 @@ describe Fontcustom::Watcher do
62
62
  FileUtils.cp fixture("shared/vectors/C.svg"), fixture("shared/vectors/test.svg")
63
63
  sleep 1
64
64
  ensure
65
- w.stop
65
+ w.send :stop
66
66
  new = fixture("shared/vectors/test.svg")
67
67
  FileUtils.rm(new) if File.exists?(new)
68
68
  end
@@ -89,7 +89,7 @@ describe Fontcustom::Watcher do
89
89
  File.open(template, "w") { |file| file.write(new) }
90
90
  sleep 1
91
91
  ensure
92
- w.stop
92
+ w.send :stop
93
93
  File.open(template, "w") { |file| file.write(content) }
94
94
  end
95
95
  end
@@ -110,7 +110,7 @@ describe Fontcustom::Watcher do
110
110
  w.watch
111
111
  FileUtils.touch fixture("shared/vectors/non-vector-file")
112
112
  ensure
113
- w.stop
113
+ w.send :stop
114
114
  new = fixture("shared/vectors/non-vector-file")
115
115
  FileUtils.rm(new) if File.exists?(new)
116
116
  end
data/spec/spec_helper.rb CHANGED
@@ -17,18 +17,18 @@ RSpec.configure do |c|
17
17
  fontcustom_cc5ce52f2ae4f9ce2e7ee8131bbfee1e.svg
18
18
  |,
19
19
  :templates => %w|fontcustom.css|,
20
- :glyphs => %w|a_r3ally-exotic-f1le-name c d|,
21
- :paths => {
22
- :css_to_fonts => "",
23
- :preprocessor_to_fonts => ""
24
- }
20
+ :glyphs => %w|a_r3ally-exotic-f1le-name c d|
25
21
  }
26
22
  end
27
23
 
28
- def fontforge_output
29
- "Copyright (c) 2000-2012 by George Williams.\n Executable based on sources from 14:57 GMT 31-Jul-2012-D.\n Library based on sources from 14:57 GMT 31-Jul-2012.\n#{data_file_contents.to_json}"
24
+ def fontforge_stdout
25
+ data_file_contents.to_json.to_s
30
26
  end
31
-
27
+
28
+ def fontforge_stderr
29
+ "Copyright (c) 2000-2012 by George Williams.\n Executable based on sources from 14:57 GMT 31-Jul-2012-D.\n Library based on sources from 14:57 GMT 31-Jul-2012.\n"
30
+ end
31
+
32
32
  def capture(stream)
33
33
  begin
34
34
  stream = stream.to_s
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fontcustom
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0.pre2
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kai Zau
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-09-13 00:00:00.000000000 Z
12
+ date: 2013-09-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
@@ -45,14 +45,14 @@ dependencies:
45
45
  requirements:
46
46
  - - ~>
47
47
  - !ruby/object:Gem::Version
48
- version: 1.2.2
48
+ version: 1.3.1
49
49
  type: :runtime
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
53
  - - ~>
54
54
  - !ruby/object:Gem::Version
55
- version: 1.2.2
55
+ version: 1.3.1
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: rake
58
58
  requirement: !ruby/object:Gem::Requirement
@@ -95,8 +95,8 @@ dependencies:
95
95
  - - '>='
96
96
  - !ruby/object:Gem::Version
97
97
  version: '0'
98
- description: Transforms EPS and SVG vectors into icon webfonts. Generates CSS (or
99
- any custom template) for easy inclusion in your projects.
98
+ description: Transforms EPS and SVG vectors into icon webfonts. Generates CSS or other
99
+ template files for your projects.
100
100
  email:
101
101
  - kai@kaizau.com
102
102
  - joshua@gross.is
@@ -112,7 +112,6 @@ files:
112
112
  - LICENSES.txt
113
113
  - README.md
114
114
  - Rakefile
115
- - TODO.md
116
115
  - bin/fontcustom
117
116
  - fontcustom.gemspec
118
117
  - lib/fontcustom.rb
@@ -169,7 +168,8 @@ files:
169
168
  homepage: http://fontcustom.com
170
169
  licenses: []
171
170
  metadata: {}
172
- post_install_message:
171
+ post_install_message: ' >> Thanks for installing Font Custom! Please ensure that
172
+ fontforge is installed before compiling any icons.'
173
173
  rdoc_options: []
174
174
  require_paths:
175
175
  - lib
@@ -180,15 +180,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
180
180
  version: '0'
181
181
  required_rubygems_version: !ruby/object:Gem::Requirement
182
182
  requirements:
183
- - - '>'
183
+ - - '>='
184
184
  - !ruby/object:Gem::Version
185
- version: 1.3.1
185
+ version: '0'
186
186
  requirements: []
187
187
  rubyforge_project:
188
188
  rubygems_version: 2.0.3
189
189
  signing_key:
190
190
  specification_version: 4
191
- summary: Generate custom icon webfonts from the comfort of the command line.
191
+ summary: Generate icon webfonts from the comfort of the command line.
192
192
  test_files:
193
193
  - spec/fixtures/generators/.fontcustom-data
194
194
  - spec/fixtures/generators/.fontcustom-data-corrupted