fontcustom 0.1.4 → 1.0.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.
Files changed (42) hide show
  1. data/CHANGELOG.md +14 -0
  2. data/CONTRIBUTING.md +15 -8
  3. data/Rakefile +4 -6
  4. data/bin/fontcustom +1 -1
  5. data/fontcustom.gemspec +2 -7
  6. data/lib/fontcustom.rb +6 -21
  7. data/lib/fontcustom/cli.rb +46 -18
  8. data/lib/fontcustom/error.rb +4 -0
  9. data/lib/fontcustom/generator/font.rb +101 -0
  10. data/lib/fontcustom/generator/template.rb +80 -0
  11. data/lib/fontcustom/options.rb +20 -0
  12. data/lib/fontcustom/scripts/generate.py +22 -6
  13. data/lib/fontcustom/templates/_fontcustom.scss +72 -0
  14. data/lib/fontcustom/templates/fontcustom-ie7.css +10 -10
  15. data/lib/fontcustom/templates/fontcustom.css +19 -19
  16. data/lib/fontcustom/templates/fontcustom.html +119 -0
  17. data/lib/fontcustom/templates/fontcustom.yml +23 -0
  18. data/lib/fontcustom/util.rb +89 -0
  19. data/lib/fontcustom/version.rb +1 -1
  20. data/lib/fontcustom/watcher.rb +50 -25
  21. data/spec/fixtures/empty-data/.fontcustom-data +0 -0
  22. data/spec/fixtures/fontcustom.yml +1 -0
  23. data/spec/fixtures/mixed-output/.fontcustom-data +17 -0
  24. data/spec/fixtures/mixed-output/another-font.ttf +0 -0
  25. data/spec/fixtures/mixed-output/dont-delete-me.bro +0 -0
  26. data/spec/fixtures/mixed-output/fontcustom-cc5ce52f2ae4f9ce2e7ee8131bbfee1e.eot +0 -0
  27. data/spec/fixtures/mixed-output/fontcustom-cc5ce52f2ae4f9ce2e7ee8131bbfee1e.svg +102 -0
  28. data/spec/fixtures/mixed-output/fontcustom-cc5ce52f2ae4f9ce2e7ee8131bbfee1e.ttf +0 -0
  29. data/spec/fixtures/mixed-output/fontcustom-cc5ce52f2ae4f9ce2e7ee8131bbfee1e.woff +0 -0
  30. data/spec/fixtures/mixed-output/fontcustom.css +108 -0
  31. data/spec/fixtures/not-a-dir +0 -0
  32. data/spec/fontcustom/generator/font_spec.rb +183 -0
  33. data/spec/fontcustom/generator/template_spec.rb +106 -0
  34. data/spec/fontcustom/util_spec.rb +109 -0
  35. data/spec/fontcustom/watcher_spec.rb +68 -0
  36. data/spec/spec_helper.rb +32 -22
  37. metadata +47 -100
  38. data/lib/fontcustom/generator.rb +0 -105
  39. data/lib/fontcustom/templates/test.html +0 -100
  40. data/spec/fontcustom/fontcustom_spec.rb +0 -42
  41. data/spec/fontcustom/generator_spec.rb +0 -75
  42. data/spec/fontcustom/watcher_spec.rb.off +0 -34
@@ -1,100 +0,0 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <title>Your Font/Glyphs</title>
5
- <!--[if IE]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
6
-
7
- <link rel="stylesheet" href="fontcustom.css" />
8
- <!--[if lte IE 7]>
9
- <link rel="stylesheet" href="fontcustom-ie7.css" />
10
- <![endif]-->
11
-
12
-
13
- <style>
14
- section, header, footer {display: block;}
15
- body {
16
- font-family: sans-serif;
17
- color: #444;
18
- line-height: 1.5;
19
- font-size: 1em;
20
- }
21
- * {
22
- -moz-box-sizing: border-box;
23
- -webkit-box-sizing: border-box;
24
- box-sizing: border-box;
25
- margin: 0;
26
- padding: 0;
27
- }
28
- .glyph {
29
- float: left;
30
- text-align: center;
31
- background: #eee;
32
- padding: .75em;
33
- margin: .75em 1.5em .75em 0;
34
- width: 7em;
35
- border-radius: .25em;
36
- box-shadow: inset 0 0 0 1px #f8f8f8, 0 0 0 1px #CCC;
37
- }
38
- .glyph input {
39
- width: 100%;
40
- text-align: center;
41
- font-family: consolas, monospace;
42
- }
43
- .glyph input, .mtm {
44
- margin-top: .75em;
45
- }
46
- .w-main {
47
- width: 80%;
48
- }
49
- .centered {
50
- margin-left: auto;
51
- margin-right: auto;
52
- }
53
- .fs1 {
54
- font-size: 2em;
55
- }
56
- header {
57
- margin: 2em 0;
58
- padding-bottom: .5em;
59
- color: #666;
60
- box-shadow: 0 2px #eee;
61
- }
62
- header h1 {
63
- font-size: 2em;
64
- font-weight: normal;
65
- }
66
- .clearfix:before, .clearfix:after { content: ""; display: table; }
67
- .clearfix:after, .clear { clear: both; }
68
- footer {
69
- margin-top: 2em;
70
- padding: .5em 0;
71
- box-shadow: 0 -2px #eee;
72
- }
73
- a, a:visited {
74
- color: #B35047;
75
- text-decoration: none;
76
- }
77
- a:hover, a:focus {color: #000;}
78
- .box1 {
79
- display: inline-block;
80
- width: 15em;
81
- padding: .25em .5em;
82
- background: #eee;
83
- margin: .5em 1em .5em 0;
84
- }
85
- </style>
86
- </head>
87
- <body>
88
- <div class="w-main centered">
89
- <section class="mtm clearfix" id="glyphs">
90
- <header> <h1>Your font contains the following glyphs</h1> </header>
91
- <% @classes.each_with_index do |name, index| %>
92
- <div class="glyph">
93
- <div class="fs1" ><i class="icon-<%= name %>"></i></div>
94
- <input type="text" readonly="readonly" value="&amp;#x<%= (61696+index).to_s(16) %>;" />
95
- </div>
96
- <% end %>
97
- </section>
98
- </div>
99
- </body>
100
- </html>
@@ -1,42 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Fontcustom do
4
- let(:input_dir) { 'spec/fixtures/vectors' }
5
- let(:output_dir) { 'tmp' }
6
- let(:fake_file) { output_dir + '/non-vector.txt' }
7
-
8
- context 'when ouput_dir already contains files' do
9
- # Compile, add non-fontcustom file, change input vectors, recompile
10
- before(:all) do
11
- # originals
12
- Fontcustom.compile(input_dir, '-o', output_dir, '-n', 'Original Font')
13
- FileUtils.touch(fake_file, :verbose => true)
14
- @original_fonts = Dir[output_dir + '/fontcustom-*.{woff,eot,ttf,svg}']
15
- @original_css = File.read(output_dir + '/fontcustom.css')
16
-
17
- FileUtils.mv(input_dir + '/C.svg', input_dir + '/E.svg', :verbose => true)
18
- Fontcustom.compile(input_dir, '-o', output_dir)
19
- end
20
-
21
- after(:all) do
22
- cleanup(output_dir)
23
- FileUtils.mv(input_dir + '/E.svg', input_dir + '/C.svg', :verbose => true)
24
- end
25
-
26
- it 'should delete previous fontcustom generated files' do
27
- new_files = Dir[output_dir + '/*']
28
- @original_fonts.each do |original|
29
- new_files.should_not include(original)
30
- end
31
- end
32
-
33
- it 'should not delete non-fontcustom generated files' do
34
- File.exists?(fake_file).should be_true
35
- end
36
-
37
- it 'should generate different css' do
38
- new_css = File.read(output_dir + '/fontcustom.css')
39
- new_css.should_not equal(@original_css)
40
- end
41
- end
42
- end
@@ -1,75 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Fontcustom::Generator do
4
- let(:input_dir) { 'spec/fixtures/vectors' }
5
- let(:output_dir) { 'tmp' }
6
-
7
- context 'normally' do
8
- before(:all) { Fontcustom::Generator.start([input_dir, '-o', output_dir]) }
9
- after(:all) { cleanup(output_dir) }
10
-
11
- it 'should create webfonts' do
12
- exts = %w( .woff .eot .ttf .svg )
13
- files = Dir[output_dir + '/*']
14
- files.map! { |file| File.extname(file) }
15
-
16
- exts.each { |ext| files.should include(ext) }
17
- end
18
-
19
- it 'should print font-face declarations in fontcustom.css' do
20
- stylesheet = File.read(output_dir + '/fontcustom.css')
21
- files = Dir[output_dir + '/*.{woff,eot,ttf,svg}']
22
-
23
- files.each do |file|
24
- stylesheet.should include(File.basename(file))
25
- end
26
- end
27
-
28
- it 'should print icon-* CSS classes in fontcustom.css' do
29
- stylesheet = File.read(output_dir + '/fontcustom.css')
30
- icon_names = Dir[input_dir + '/*'].map { |file| File.basename(file)[0..-5].gsub(/\W/, '-').downcase }
31
-
32
- icon_names.each do |name|
33
- stylesheet.should include('.icon-' + name)
34
- end
35
- end
36
- end
37
-
38
- context 'when input_dir does not exist' do
39
- let(:fake_input_dir) { 'does/not/exist' }
40
-
41
- it 'should raise an error' do
42
- results = capture(:stderr) { Fontcustom::Generator.start([fake_input_dir, '-o', output_dir]) }
43
- results.should =~ /doesn't exist or isn't a directory/
44
- end
45
- end
46
-
47
- context 'when input_dir does not contain vectors' do
48
- let(:empty_input_dir) { 'spec/fixtures/empty' }
49
-
50
- it 'should raise an error' do
51
- results = capture(:stderr) { Fontcustom::Generator.start([empty_input_dir, output_dir]) }
52
- results.should =~ /doesn't contain any vectors/
53
- end
54
- end
55
-
56
- context 'when flags are passed' do
57
- it 'should save output files with a custom name' do
58
- Fontcustom::Generator.start([input_dir, '-o', output_dir, '-n', 'customname'])
59
-
60
- file = Dir[File.join(output_dir, 'customname-*.ttf')].first
61
- File.exists?(file).should be_true
62
-
63
- cleanup(output_dir)
64
- end
65
-
66
- it 'should exclude the filename hash' do
67
- Fontcustom::Generator.start([input_dir, '-o', output_dir, '--nohash'])
68
-
69
- file = File.join(output_dir, 'fontcustom.ttf')
70
- File.exists?(file).should be_true
71
-
72
- cleanup(output_dir)
73
- end
74
- end
75
- end
@@ -1,34 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Fontcustom do
4
- let (:input_dir) { 'spec/fixtures/vectors' }
5
- let (:output_dir) { 'tmp' }
6
- let (:fontcustom) { Fontcustom }
7
-
8
- before(:all) do
9
- fontcustom.watch(input_dir, output_dir)
10
- end
11
-
12
- context '#watch' do
13
- it 'should detect when a vector file changes' do
14
- `mv spec/fixtures/vectors/B.svg spec/fixtures/vectors/E.svg`
15
- sleep 1
16
- fontcustom.should_receive(:compile).with(input_dir, output_dir)
17
- end
18
-
19
- it 'should detect when a vector file is added' do
20
- end
21
-
22
- it 'should detect when a vector file is removed' do
23
- end
24
-
25
- it 'should send complain if the dir has no vectors' do
26
- end
27
- end
28
-
29
- after(:all) do
30
- Fontcustom.stop
31
- `mv spec/fixtures/vectors/E.svg spec/fixtures/vectors/B.svg`
32
- cleanup(output_dir)
33
- end
34
- end