fontcustom 1.3.0.beta4 → 1.3.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -9
- data/TODO.md +0 -4
- data/lib/fontcustom/base.rb +3 -1
- data/lib/fontcustom/cli.rb +1 -2
- data/lib/fontcustom/generator/font.rb +1 -1
- data/lib/fontcustom/generator/template.rb +8 -1
- data/lib/fontcustom/options.rb +16 -5
- data/lib/fontcustom/scripts/generate.py +1 -2
- data/lib/fontcustom/templates/fontcustom.yml +20 -28
- data/lib/fontcustom/utility.rb +9 -7
- data/lib/fontcustom/version.rb +1 -1
- data/lib/fontcustom/watcher.rb +22 -37
- data/spec/fontcustom/options_spec.rb +30 -38
- data/spec/fontcustom/{watcher_spec.rb.off → watcher_spec.rb} +25 -25
- data/spec/spec_helper.rb +23 -18
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c3398b6e31a2d23df76685528575c74d5f0d7739
|
4
|
+
data.tar.gz: 8ff178040adf1fc60c82edf1cf69cc0e427b00cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2d4d505b543b0c4c6be525f7151b4a5601547ba4decc860e1e985dceaa41da9a143a8bfc350ce608d83dbf3f9ddee3c6a6650ce4cd286ed5fdf857815f032beb
|
7
|
+
data.tar.gz: 58d1fc4dd1f3e4ee499adfb2a53252cd08330fb59c9661c2da523d9eac3999bb9e8a913bc9754497261080334224f66bb4dfd788d17474c2d1ee616db839f115
|
data/CHANGELOG.md
CHANGED
@@ -1,18 +1,20 @@
|
|
1
|
-
## 1.3.0
|
1
|
+
## 1.3.0 (12/24/2013)
|
2
2
|
|
3
|
-
**
|
3
|
+
**If upgrading from 1.2.0, delete your old `.fontcustom-manifest.json` and output directories first.**
|
4
4
|
|
5
|
-
The big news: fixed glyph code points. Automatically assigned for now, but changing them by hand is just a matter of modifying the generated `.fontcustom-manifest.json`. A few breaking changes (`css_prefix`, custom template syntax, possibly others).
|
5
|
+
The big news: fixed glyph code points. Automatically assigned for now, but changing them by hand is just a matter of modifying the generated `.fontcustom-manifest.json`. A few breaking changes (`css_prefix`, custom template syntax, possibly others).
|
6
6
|
|
7
|
-
*
|
7
|
+
* Adds fixed glyph code points ([#56](https://github.com/FontCustom/fontcustom/issues/56))
|
8
|
+
* Drops bootstrap templates (maintenance overhead, unsure if anyone was using them)
|
9
|
+
* Stores relative paths for collaborative editing ([#149](https://github.com/FontCustom/fontcustom/pull/149))
|
8
10
|
* Changes `css_prefix` to `css_selector` to allow greater flexibility ([#126](https://github.com/FontCustom/fontcustom/pull/126))
|
9
11
|
* Skips compilation if inputs have not changed (and `force` option to bypass checks)
|
10
12
|
* Adds CSS template helpers for convenience and DRYness
|
11
|
-
*
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
*
|
13
|
+
* Improves rendering on Chrome Windows ([#143](https://github.com/FontCustom/fontcustom/pull/143))
|
14
|
+
* Improves Windows hinting ([#160](https://github.com/FontCustom/fontcustom/pull/160))
|
15
|
+
* Fixes Python 2.6 optsparse syntax ([#159](https://github.com/FontCustom/fontcustom/issues/159))
|
16
|
+
* Fixes bug where changes in custom templates were not detected by `watch`
|
17
|
+
* Improves error and debuggging messages
|
16
18
|
|
17
19
|
## 1.2.0 (11/2/2013)
|
18
20
|
|
data/TODO.md
CHANGED
data/lib/fontcustom/base.rb
CHANGED
@@ -15,13 +15,15 @@ module Fontcustom
|
|
15
15
|
def compile
|
16
16
|
current = checksum
|
17
17
|
previous = @manifest.get(:checksum)[:previous]
|
18
|
+
|
19
|
+
say_message :status, "Forcing compile." if @options[:force]
|
18
20
|
if @options[:force] || current != previous
|
19
21
|
@manifest.set :checksum, {:previous => previous, :current => current}
|
20
22
|
start_generators
|
21
23
|
@manifest.reload
|
22
24
|
@manifest.set :checksum, {:previous => current, :current => current}
|
23
25
|
else
|
24
|
-
say_message :status, "No changes detected. Skipping
|
26
|
+
say_message :status, "No changes detected. Skipping compile."
|
25
27
|
end
|
26
28
|
end
|
27
29
|
|
data/lib/fontcustom/cli.rb
CHANGED
@@ -68,13 +68,12 @@ module Fontcustom
|
|
68
68
|
def watch(input = nil)
|
69
69
|
say "Font Custom is watching your icons. Press Ctrl + C to stop.", :yellow unless options[:quiet]
|
70
70
|
opts = options.merge :input => input, :skip_first => !! options[:skip_first]
|
71
|
-
opts = Options.new(opts)
|
72
71
|
Watcher.new(opts).watch
|
73
72
|
rescue Fontcustom::Error => e
|
74
73
|
say_status :error, e.message, :red
|
75
74
|
end
|
76
75
|
|
77
|
-
desc "config [DIR]", "Generates
|
76
|
+
desc "config [DIR]", "Generates a starter configuration file (fontcustom.yml) in DIR. Default: `pwd`"
|
78
77
|
def config(dir = Dir.pwd)
|
79
78
|
template "fontcustom.yml", File.join(dir, "fontcustom.yml")
|
80
79
|
end
|
@@ -6,7 +6,7 @@ module Fontcustom
|
|
6
6
|
class Template
|
7
7
|
include Utility
|
8
8
|
|
9
|
-
attr_reader :manifest
|
9
|
+
attr_reader :manifest
|
10
10
|
|
11
11
|
def initialize(manifest)
|
12
12
|
@manifest = Fontcustom::Manifest.new manifest
|
@@ -128,6 +128,13 @@ module Fontcustom
|
|
128
128
|
#{url}("#{path}.svg##{font_name}") format("svg");
|
129
129
|
font-weight: normal;
|
130
130
|
font-style: normal;
|
131
|
+
}
|
132
|
+
|
133
|
+
@media screen and (-webkit-min-device-pixel-ratio:0) {
|
134
|
+
@font-face {
|
135
|
+
font-family: "#{font_name}";
|
136
|
+
src: url("#{path}.svg##{font_name}") format("svg");
|
137
|
+
}
|
131
138
|
}|
|
132
139
|
end
|
133
140
|
|
data/lib/fontcustom/options.rb
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
require "yaml"
|
2
|
+
require "pp"
|
2
3
|
|
3
4
|
module Fontcustom
|
4
5
|
class Options
|
5
6
|
include Utility
|
6
7
|
|
7
|
-
attr_accessor :options
|
8
|
-
|
9
8
|
def initialize(cli_options = {})
|
10
9
|
@manifest = cli_options[:manifest]
|
11
10
|
@cli_options = symbolize_hash(cli_options)
|
@@ -24,6 +23,7 @@ module Fontcustom
|
|
24
23
|
set_input_paths
|
25
24
|
set_output_paths
|
26
25
|
check_template_paths
|
26
|
+
print_debug if @options[:debug]
|
27
27
|
end
|
28
28
|
|
29
29
|
# We give Thor fake defaults to generate more useful help messages.
|
@@ -60,11 +60,11 @@ module Fontcustom
|
|
60
60
|
def load_config
|
61
61
|
@config_options = {}
|
62
62
|
if @cli_options[:config]
|
63
|
-
say_message :debug, "Using settings from `#{@cli_options[:config]}`." if @cli_options[:debug]
|
64
63
|
begin
|
65
64
|
config = YAML.load File.open(@cli_options[:config])
|
66
65
|
if config # empty YAML returns false
|
67
66
|
@config_options = symbolize_hash(config)
|
67
|
+
say_message :debug, "Using settings from `#{@cli_options[:config]}`." if @cli_options[:debug] || @config_options[:debug]
|
68
68
|
else
|
69
69
|
say_message :warn, "`#{@cli_options[:config]}` was empty. Using defaults."
|
70
70
|
end
|
@@ -109,7 +109,12 @@ module Fontcustom
|
|
109
109
|
@options[:input][:templates] = @options[:input][:vectors]
|
110
110
|
end
|
111
111
|
else
|
112
|
-
|
112
|
+
if @options[:input]
|
113
|
+
input = @options[:input]
|
114
|
+
else
|
115
|
+
input = "."
|
116
|
+
say_message :warn, "No input directory given. Using present working directory."
|
117
|
+
end
|
113
118
|
check_input input
|
114
119
|
@options[:input] = { :vectors => input, :templates => input }
|
115
120
|
end
|
@@ -163,7 +168,7 @@ module Fontcustom
|
|
163
168
|
path = File.expand_path File.join(@options[:input][:templates], template) unless template[0] == "/"
|
164
169
|
unless File.exists? path
|
165
170
|
raise Fontcustom::Error,
|
166
|
-
"Custom template `#{template}`
|
171
|
+
"Custom template `#{template}` wasn't found in `#{@options[:input][:templates]}/`. Check your options."
|
167
172
|
end
|
168
173
|
end
|
169
174
|
end
|
@@ -177,5 +182,11 @@ module Fontcustom
|
|
177
182
|
"Input `#{dir}` isn't a directory. Check your options."
|
178
183
|
end
|
179
184
|
end
|
185
|
+
|
186
|
+
def print_debug
|
187
|
+
message = line_break(16)
|
188
|
+
message << @options.pretty_inspect.split("\n ").join(line_break(16))
|
189
|
+
say_message :debug, "Using options:#{message}"
|
190
|
+
end
|
180
191
|
end
|
181
192
|
end
|
@@ -17,7 +17,6 @@ try:
|
|
17
17
|
except ImportError:
|
18
18
|
import optparse
|
19
19
|
parser = optparse.OptionParser()
|
20
|
-
parser.add_option('manifest', help='Path to .fontcustom-manifest.json')
|
21
20
|
(nothing, args) = parser.parse_args()
|
22
21
|
|
23
22
|
manifestfile = open(args.manifest, 'r+')
|
@@ -94,7 +93,7 @@ try:
|
|
94
93
|
manifest['fonts'].append(fontfile + '.svg')
|
95
94
|
|
96
95
|
# Hint the TTF file
|
97
|
-
subprocess.call('ttfautohint -s -f -n ' + fontfile + '.ttf ' + fontfile + '-hinted.ttf > /dev/null 2>&1 && mv ' + fontfile + '-hinted.ttf ' + fontfile + '.ttf', shell=True)
|
96
|
+
subprocess.call('ttfautohint -s -f -n -W ' + fontfile + '.ttf ' + fontfile + '-hinted.ttf > /dev/null 2>&1 && mv ' + fontfile + '-hinted.ttf ' + fontfile + '.ttf', shell=True)
|
98
97
|
|
99
98
|
# Fix SVG header for webkit
|
100
99
|
# from: https://github.com/fontello/font-builder/blob/master/bin/fontconvert.py
|
@@ -4,42 +4,34 @@
|
|
4
4
|
# `fontcustom help` or visiting <http://fontcustom.com>.
|
5
5
|
# --------------------------------------------------------------------------- #
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
7
|
+
font_name: fontcustom
|
8
|
+
css_selector: .icon-{{glyph}}
|
9
|
+
preprocessor_path: ""
|
10
|
+
autowidth: false
|
11
|
+
no_hash: false
|
12
|
+
force: false
|
13
|
+
debug: false
|
14
|
+
quiet: false
|
15
15
|
|
16
16
|
|
17
17
|
# --------------------------------------------------------------------------- #
|
18
18
|
# Input Paths
|
19
19
|
# --------------------------------------------------------------------------- #
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
#input: # as a hash
|
26
|
-
# vectors: app/assets/fonts/fontcustom/vectors # required
|
27
|
-
# templates: app/assets/fonts/fontcustom/templates
|
21
|
+
input:
|
22
|
+
vectors: app/assets/fonts/fontcustom/vectors # required
|
23
|
+
templates: app/assets/fonts/fontcustom/templates
|
28
24
|
|
29
25
|
|
30
26
|
# --------------------------------------------------------------------------- #
|
31
27
|
# Output Paths
|
32
28
|
# --------------------------------------------------------------------------- #
|
33
29
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
#
|
39
|
-
# fonts: app/assets/fonts # required
|
40
|
-
# css: app/assets/stylesheets
|
41
|
-
# preview: app/views/styleguide
|
42
|
-
# my-custom-template.yml: config
|
30
|
+
output:
|
31
|
+
fonts: app/assets/fonts # required
|
32
|
+
css: app/assets/stylesheets
|
33
|
+
preview: app/views/styleguide
|
34
|
+
#my-custom-template.yml: path/to/template/output
|
43
35
|
|
44
36
|
|
45
37
|
# --------------------------------------------------------------------------- #
|
@@ -49,7 +41,7 @@
|
|
49
41
|
# referenced by their baserame.
|
50
42
|
# --------------------------------------------------------------------------- #
|
51
43
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
44
|
+
templates:
|
45
|
+
- scss
|
46
|
+
- preview
|
47
|
+
#- my-custom-template.yml
|
data/lib/fontcustom/utility.rb
CHANGED
@@ -91,25 +91,27 @@ module Fontcustom
|
|
91
91
|
#
|
92
92
|
|
93
93
|
def say_message(status, message, color = nil)
|
94
|
-
return if options[:quiet] && status != :error
|
94
|
+
return if options[:quiet] && status != :error && status != :debug
|
95
95
|
color = :red if [:error, :debug, :warn].include?(status)
|
96
96
|
say_status status, message, color
|
97
97
|
end
|
98
98
|
|
99
99
|
def say_changed(status, changed)
|
100
|
-
return if options[:quiet]
|
100
|
+
return if options[:quiet] || ! options[:debug] && status == :delete
|
101
101
|
say_status status, changed.join(line_break)
|
102
102
|
end
|
103
103
|
|
104
104
|
# magic number for Thor say_status line breaks
|
105
|
-
def line_break
|
106
|
-
"\n#{" " *
|
105
|
+
def line_break(n = 14)
|
106
|
+
"\n#{" " * n}"
|
107
107
|
end
|
108
108
|
|
109
|
-
private
|
110
|
-
|
111
109
|
def options
|
112
|
-
|
110
|
+
if @data
|
111
|
+
@data[:options]
|
112
|
+
else
|
113
|
+
@options || @cli_options || @config_options || {}
|
114
|
+
end
|
113
115
|
end
|
114
116
|
end
|
115
117
|
end
|
data/lib/fontcustom/version.rb
CHANGED
data/lib/fontcustom/watcher.rb
CHANGED
@@ -5,31 +5,29 @@ module Fontcustom
|
|
5
5
|
class Watcher
|
6
6
|
include Utility
|
7
7
|
|
8
|
-
def initialize(
|
9
|
-
@
|
10
|
-
@
|
8
|
+
def initialize(options, is_test = false)
|
9
|
+
@base = Fontcustom::Base.new options
|
10
|
+
@options = @base.options
|
11
|
+
@is_test = is_test
|
11
12
|
|
12
|
-
templates = @
|
13
|
-
|
14
|
-
|
15
|
-
end
|
16
|
-
unless templates.empty?
|
17
|
-
templates = templates.map do |template|
|
18
|
-
File.basename template
|
19
|
-
end
|
20
|
-
@template_listener = Listen.to(@opts.input[:templates]).relative_paths(true).filter(/(#{templates.join("|")})/).change(&callback)
|
21
|
-
end
|
13
|
+
templates = @options[:templates].dup.map { |template| File.basename(template) }
|
14
|
+
packaged = %w|preview css scss scss-rails|
|
15
|
+
templates.delete_if { |template| packaged.include?(template) }
|
22
16
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
@
|
27
|
-
@template_listener = @template_listener.polling_fallback_message(false) if @template_listener
|
17
|
+
if templates.empty?
|
18
|
+
@listener = Listen.to(@options[:input][:vectors])
|
19
|
+
else
|
20
|
+
@listener = Listen.to(@options[:input][:vectors], @options[:input][:templates])
|
28
21
|
end
|
22
|
+
|
23
|
+
@listener = @listener.relative_paths(true)
|
24
|
+
@listener = @listener.filter(/(#{templates.join("|")}|.+\.svg)$/)
|
25
|
+
@listener = @listener.change(&callback)
|
26
|
+
@listener = @listener.polling_fallback_message(false) if @is_test
|
29
27
|
end
|
30
28
|
|
31
29
|
def watch
|
32
|
-
compile unless @
|
30
|
+
compile unless @options[:skip_first]
|
33
31
|
start
|
34
32
|
rescue SignalException # Catches Ctrl + C
|
35
33
|
stop
|
@@ -39,18 +37,15 @@ module Fontcustom
|
|
39
37
|
|
40
38
|
def start
|
41
39
|
if @is_test # Non-blocking listener
|
42
|
-
@
|
43
|
-
@template_listener.start if @template_listener
|
40
|
+
@listener.start
|
44
41
|
else
|
45
|
-
@
|
46
|
-
@template_listener.start! if @template_listener
|
42
|
+
@listener.start!
|
47
43
|
end
|
48
44
|
end
|
49
45
|
|
50
46
|
def stop
|
51
|
-
@
|
52
|
-
|
53
|
-
say "\nFont Custom is signing off. Good night and good luck.", :yellow
|
47
|
+
@listener.stop
|
48
|
+
shell.say "\nFont Custom is signing off. Good night and good luck.", :yellow
|
54
49
|
end
|
55
50
|
|
56
51
|
def callback
|
@@ -68,17 +63,7 @@ module Fontcustom
|
|
68
63
|
end
|
69
64
|
|
70
65
|
def compile
|
71
|
-
|
72
|
-
Generator::Template.start [@opts]
|
73
|
-
end
|
74
|
-
|
75
|
-
def say(*args)
|
76
|
-
return if @opts.quiet
|
77
|
-
@opts.instance_variable_get(:@shell).say *args
|
78
|
-
end
|
79
|
-
|
80
|
-
def say_message(*args)
|
81
|
-
@opts.say_message *args
|
66
|
+
@base.compile
|
82
67
|
end
|
83
68
|
end
|
84
69
|
end
|
@@ -26,26 +26,20 @@ describe Fontcustom::Options do
|
|
26
26
|
context ".set_config_path" do
|
27
27
|
context "when :config is set" do
|
28
28
|
it "should use options[:config] if it's a file" do
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
o.instance_variable_get(:@cli_options)[:config].should == "options/any-file-name.yml"
|
33
|
-
end
|
29
|
+
o = options :config => "options/any-file-name.yml"
|
30
|
+
o.send :set_config_path
|
31
|
+
o.instance_variable_get(:@cli_options)[:config].should == "options/any-file-name.yml"
|
34
32
|
end
|
35
33
|
|
36
34
|
it "should search for fontcustom.yml if options[:config] is a dir" do
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
o.instance_variable_get(:@cli_options)[:config].should == "options/config-is-in-dir/fontcustom.yml"
|
41
|
-
end
|
35
|
+
o = options :config => "options/config-is-in-dir"
|
36
|
+
o.send :set_config_path
|
37
|
+
o.instance_variable_get(:@cli_options)[:config].should == "options/config-is-in-dir/fontcustom.yml"
|
42
38
|
end
|
43
39
|
|
44
40
|
it "should raise error if :config doesn't exist" do
|
45
|
-
|
46
|
-
|
47
|
-
expect { o.send :set_config_path }.to raise_error Fontcustom::Error, /configuration file/
|
48
|
-
end
|
41
|
+
o = options :config => "does-not-exist"
|
42
|
+
expect { o.send :set_config_path }.to raise_error Fontcustom::Error, /configuration file/
|
49
43
|
end
|
50
44
|
end
|
51
45
|
|
@@ -67,11 +61,9 @@ describe Fontcustom::Options do
|
|
67
61
|
end
|
68
62
|
|
69
63
|
it "should be false if nothing is found" do
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
o.instance_variable_get(:@cli_options)[:config].should == false
|
74
|
-
end
|
64
|
+
o = options :manifest => "options/no-config-here/.fontcustom-manifest.json"
|
65
|
+
o.send :set_config_path
|
66
|
+
o.instance_variable_get(:@cli_options)[:config].should == false
|
75
67
|
end
|
76
68
|
end
|
77
69
|
end
|
@@ -131,7 +123,7 @@ describe Fontcustom::Options do
|
|
131
123
|
context ".clean_font_name" do
|
132
124
|
it "should normalize the font name" do
|
133
125
|
o = options
|
134
|
-
o.options
|
126
|
+
o.instance_variable_set :@options, { :font_name => " A_stR4nG3 nAm3 Ø& " }
|
135
127
|
o.send :clean_font_name
|
136
128
|
o.options[:font_name].should == "A_stR4nG3--nAm3---"
|
137
129
|
end
|
@@ -141,7 +133,7 @@ describe Fontcustom::Options do
|
|
141
133
|
it "should raise error if input[:vectors] doesn't contain SVGs" do
|
142
134
|
FileUtils.cd fixture("shared") do
|
143
135
|
o = options
|
144
|
-
o.options
|
136
|
+
o.instance_variable_set :@options, { :input => "vectors-empty" }
|
145
137
|
expect { o.send :set_input_paths }.to raise_error Fontcustom::Error, /doesn't contain any SVGs/
|
146
138
|
end
|
147
139
|
end
|
@@ -150,7 +142,7 @@ describe Fontcustom::Options do
|
|
150
142
|
it "should set :templates as :vectors if :templates isn't set" do
|
151
143
|
FileUtils.cd fixture("shared") do
|
152
144
|
o = options
|
153
|
-
o.options
|
145
|
+
o.instance_variable_set :@options, { :input => { :vectors => "vectors" } }
|
154
146
|
o.send :set_input_paths
|
155
147
|
o.options[:input][:templates].should == "vectors"
|
156
148
|
end
|
@@ -159,7 +151,7 @@ describe Fontcustom::Options do
|
|
159
151
|
it "should preserve :templates if it's set" do
|
160
152
|
FileUtils.cd fixture("shared") do
|
161
153
|
o = options
|
162
|
-
o.options
|
154
|
+
o.instance_variable_set :@options, { :input => { :vectors => "vectors", :templates => "templates" } }
|
163
155
|
o.send :set_input_paths
|
164
156
|
o.options[:input][:templates].should == "templates"
|
165
157
|
end
|
@@ -168,7 +160,7 @@ describe Fontcustom::Options do
|
|
168
160
|
it "should raise an error if :vectors isn't set" do
|
169
161
|
FileUtils.cd fixture("shared") do
|
170
162
|
o = options
|
171
|
-
o.options
|
163
|
+
o.instance_variable_set :@options, { :input => { :templates => "templates" } }
|
172
164
|
expect { o.send :set_input_paths }.to raise_error Fontcustom::Error, /have a :vectors key/
|
173
165
|
end
|
174
166
|
end
|
@@ -176,7 +168,7 @@ describe Fontcustom::Options do
|
|
176
168
|
it "should raise an error if :vectors doesn't point to an existing directory" do
|
177
169
|
FileUtils.cd fixture("shared") do
|
178
170
|
o = options
|
179
|
-
o.options
|
171
|
+
o.instance_variable_set :@options, {
|
180
172
|
:config => "fontcustom.yml",
|
181
173
|
:input => { :vectors => "not-a-dir" }
|
182
174
|
}
|
@@ -189,7 +181,7 @@ describe Fontcustom::Options do
|
|
189
181
|
it "should return a hash of locations" do
|
190
182
|
FileUtils.cd fixture("shared") do
|
191
183
|
o = options
|
192
|
-
o.options
|
184
|
+
o.instance_variable_set :@options, { :input => "vectors" }
|
193
185
|
o.send :set_input_paths
|
194
186
|
o.options[:input].should have_key(:vectors)
|
195
187
|
o.options[:input].should have_key(:templates)
|
@@ -199,7 +191,7 @@ describe Fontcustom::Options do
|
|
199
191
|
it "should set :templates to match :vectors" do
|
200
192
|
FileUtils.cd fixture("shared") do
|
201
193
|
o = options
|
202
|
-
o.options
|
194
|
+
o.instance_variable_set :@options, { :input => "vectors" }
|
203
195
|
o.send :set_input_paths
|
204
196
|
o.options[:input][:templates].should == "vectors"
|
205
197
|
end
|
@@ -208,7 +200,7 @@ describe Fontcustom::Options do
|
|
208
200
|
it "should raise an error if :vectors doesn't point to a directory" do
|
209
201
|
FileUtils.cd fixture("shared") do
|
210
202
|
o = options
|
211
|
-
o.options
|
203
|
+
o.instance_variable_set :@options, {
|
212
204
|
:config => "fontcustom.yml",
|
213
205
|
:input => "not-a-dir"
|
214
206
|
}
|
@@ -223,7 +215,7 @@ describe Fontcustom::Options do
|
|
223
215
|
context "when :debug is true" do
|
224
216
|
it "should print a warning" do
|
225
217
|
o = options
|
226
|
-
o.options
|
218
|
+
o.instance_variable_set :@options, {
|
227
219
|
:debug => true,
|
228
220
|
:font_name => "Test-Font"
|
229
221
|
}
|
@@ -236,7 +228,7 @@ describe Fontcustom::Options do
|
|
236
228
|
context "when :output is a hash" do
|
237
229
|
it "should set :css and :preview to match :fonts if either aren't set" do
|
238
230
|
o = options
|
239
|
-
o.options
|
231
|
+
o.instance_variable_set :@options, { :output => { :fonts => "output/fonts" } }
|
240
232
|
o.send :set_output_paths
|
241
233
|
o.options[:output][:css].should == "output/fonts"
|
242
234
|
o.options[:output][:preview].should == "output/fonts"
|
@@ -244,7 +236,7 @@ describe Fontcustom::Options do
|
|
244
236
|
|
245
237
|
it "should preserve :css and :preview if they do exist" do
|
246
238
|
o = options
|
247
|
-
o.options
|
239
|
+
o.instance_variable_set :@options, {
|
248
240
|
:output => {
|
249
241
|
:fonts => "output/fonts",
|
250
242
|
:css => "output/styles",
|
@@ -258,7 +250,7 @@ describe Fontcustom::Options do
|
|
258
250
|
|
259
251
|
it "should create additional paths if they are given" do
|
260
252
|
o = options
|
261
|
-
o.options
|
253
|
+
o.instance_variable_set :@options, {
|
262
254
|
:output => {
|
263
255
|
:fonts => "output/fonts",
|
264
256
|
"special.js" => "assets/javascripts"
|
@@ -270,7 +262,7 @@ describe Fontcustom::Options do
|
|
270
262
|
|
271
263
|
it "should raise an error if :fonts isn't set" do
|
272
264
|
o = options
|
273
|
-
o.options
|
265
|
+
o.instance_variable_set :@options, {
|
274
266
|
:config => "fontcustom.yml",
|
275
267
|
:output => { :css => "output/styles" }
|
276
268
|
}
|
@@ -281,7 +273,7 @@ describe Fontcustom::Options do
|
|
281
273
|
context "when :output is a string" do
|
282
274
|
it "should return a hash of output locations" do
|
283
275
|
o = options
|
284
|
-
o.options
|
276
|
+
o.instance_variable_set :@options, { :output => "output/fonts" }
|
285
277
|
o.send :set_output_paths
|
286
278
|
o.options[:output].should be_a(Hash)
|
287
279
|
o.options[:output].should have_key(:fonts)
|
@@ -291,7 +283,7 @@ describe Fontcustom::Options do
|
|
291
283
|
|
292
284
|
it "should set :css and :preview to match :fonts" do
|
293
285
|
o = options
|
294
|
-
o.options
|
286
|
+
o.instance_variable_set :@options, { :output => "output/fonts" }
|
295
287
|
o.send :set_output_paths
|
296
288
|
o.options[:output][:css].should == "output/fonts"
|
297
289
|
o.options[:output][:preview].should == "output/fonts"
|
@@ -300,7 +292,7 @@ describe Fontcustom::Options do
|
|
300
292
|
it "should raise an error if :fonts exists but isn't a directory" do
|
301
293
|
FileUtils.cd fixture("shared") do
|
302
294
|
o = options
|
303
|
-
o.options
|
295
|
+
o.instance_variable_set :@options, {
|
304
296
|
:config => "fontcustom.yml",
|
305
297
|
:output => "not-a-dir"
|
306
298
|
}
|
@@ -313,11 +305,11 @@ describe Fontcustom::Options do
|
|
313
305
|
context ".check_template_paths" do
|
314
306
|
it "should raise an error if a template does not exist" do
|
315
307
|
o = options
|
316
|
-
o.options
|
308
|
+
o.instance_variable_set :@options, {
|
317
309
|
:input => { :templates => fixture("shared/templates") },
|
318
310
|
:templates => %w|fake-template.txt|
|
319
311
|
}
|
320
|
-
expect { o.send :check_template_paths }.to raise_error Fontcustom::Error, /
|
312
|
+
expect { o.send :check_template_paths }.to raise_error Fontcustom::Error, /wasn't found/
|
321
313
|
end
|
322
314
|
end
|
323
315
|
end
|
@@ -4,27 +4,27 @@ require "fontcustom/watcher"
|
|
4
4
|
|
5
5
|
describe Fontcustom::Watcher do
|
6
6
|
# Silence messages without passing :quiet => true to everything
|
7
|
-
before(:each) do
|
8
|
-
Fontcustom::Options.any_instance.stub :say_message
|
9
|
-
end
|
7
|
+
#before(:each) do
|
8
|
+
#Fontcustom::Options.any_instance.stub :say_message
|
9
|
+
#end
|
10
10
|
|
11
11
|
def watcher(options)
|
12
|
-
Fontcustom::
|
13
|
-
Fontcustom::
|
14
|
-
|
15
|
-
|
16
|
-
Fontcustom::Watcher.new
|
12
|
+
Fontcustom::Manifest.any_instance.stub :write_file
|
13
|
+
Fontcustom::Base.any_instance.stub :compile
|
14
|
+
|
15
|
+
# undocumented — non-blocking use of watcher for testing
|
16
|
+
Fontcustom::Watcher.new options, true
|
17
17
|
end
|
18
18
|
|
19
19
|
context "#watch" do
|
20
|
-
it "should
|
21
|
-
Fontcustom::
|
22
|
-
|
20
|
+
it "should compile on init" do
|
21
|
+
Fontcustom::Base.any_instance.should_receive(:compile).once
|
22
|
+
|
23
23
|
w = watcher(
|
24
|
-
:project_root => fixture,
|
25
24
|
:input => "shared/vectors",
|
26
25
|
:output => "output"
|
27
26
|
)
|
27
|
+
|
28
28
|
# silence output
|
29
29
|
capture(:stdout) do
|
30
30
|
w.watch
|
@@ -33,14 +33,14 @@ describe Fontcustom::Watcher do
|
|
33
33
|
end
|
34
34
|
|
35
35
|
it "should not call generators on init if options[:skip_first] is passed" do
|
36
|
-
Fontcustom::
|
37
|
-
|
36
|
+
Fontcustom::Base.any_instance.should_not_receive(:compile)
|
37
|
+
|
38
38
|
w = watcher(
|
39
|
-
:project_root => fixture,
|
40
39
|
:input => "shared/vectors",
|
41
40
|
:output => "output",
|
42
41
|
:skip_first => true
|
43
42
|
)
|
43
|
+
|
44
44
|
capture(:stdout) do
|
45
45
|
w.watch
|
46
46
|
w.send :stop
|
@@ -48,14 +48,14 @@ describe Fontcustom::Watcher do
|
|
48
48
|
end
|
49
49
|
|
50
50
|
it "should call generators when vectors change" do
|
51
|
-
Fontcustom::
|
52
|
-
|
51
|
+
Fontcustom::Base.any_instance.should_receive(:compile).once
|
52
|
+
|
53
53
|
w = watcher(
|
54
|
-
:project_root => fixture,
|
55
54
|
:input => "shared/vectors",
|
56
55
|
:output => "output",
|
57
56
|
:skip_first => true
|
58
57
|
)
|
58
|
+
|
59
59
|
capture(:stdout) do
|
60
60
|
begin
|
61
61
|
w.watch
|
@@ -69,16 +69,16 @@ describe Fontcustom::Watcher do
|
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
|
-
it "should call generators when
|
73
|
-
Fontcustom::
|
74
|
-
|
72
|
+
it "should call generators when custom templates change" do
|
73
|
+
Fontcustom::Base.any_instance.should_receive(:compile).once
|
74
|
+
|
75
75
|
w = watcher(
|
76
|
-
:project_root => fixture,
|
77
76
|
:input => {:vectors => "shared/vectors", :templates => "shared/templates"},
|
78
77
|
:templates => %w|css preview custom.css|,
|
79
78
|
:output => "output",
|
80
79
|
:skip_first => true
|
81
80
|
)
|
81
|
+
|
82
82
|
capture(:stdout) do
|
83
83
|
begin
|
84
84
|
template = fixture "shared/templates/custom.css"
|
@@ -97,14 +97,14 @@ describe Fontcustom::Watcher do
|
|
97
97
|
end
|
98
98
|
|
99
99
|
it "should do nothing when non-vectors change" do
|
100
|
-
Fontcustom::
|
101
|
-
|
100
|
+
Fontcustom::Base.any_instance.should_not_receive(:compile)
|
101
|
+
|
102
102
|
w = watcher(
|
103
|
-
:project_root => fixture,
|
104
103
|
:input => "shared/vectors",
|
105
104
|
:output => "output",
|
106
105
|
:skip_first => true
|
107
106
|
)
|
107
|
+
|
108
108
|
capture(:stdout) do
|
109
109
|
begin
|
110
110
|
w.watch
|
data/spec/spec_helper.rb
CHANGED
@@ -4,34 +4,39 @@ require "fileutils"
|
|
4
4
|
require File.expand_path("../../lib/fontcustom.rb", __FILE__)
|
5
5
|
|
6
6
|
RSpec.configure do |c|
|
7
|
+
c.before(:all) do
|
8
|
+
FileUtils.cd fixture
|
9
|
+
puts "Running `cd #{Dir.pwd}`"
|
10
|
+
end
|
11
|
+
|
7
12
|
def fixture(path = "")
|
8
13
|
File.join(File.expand_path("../fixtures", __FILE__), path)
|
9
14
|
end
|
10
15
|
|
11
|
-
def manifest_contents
|
16
|
+
def manifest_contents
|
12
17
|
{
|
13
18
|
:checksum => {
|
14
19
|
:current => "82a59e769bc60192484f2620570bbb59e225db97c1aac3f242a2e49d6060a19c",
|
15
20
|
:previous => "82a59e769bc60192484f2620570bbb59e225db97c1aac3f242a2e49d6060a19c"
|
16
21
|
},
|
17
22
|
:fonts => [
|
18
|
-
"
|
19
|
-
"
|
20
|
-
"
|
21
|
-
"
|
23
|
+
"fontcustom/fontcustom_82a59e769bc60192484f2620570bbb59.ttf",
|
24
|
+
"fontcustom/fontcustom_82a59e769bc60192484f2620570bbb59.svg",
|
25
|
+
"fontcustom/fontcustom_82a59e769bc60192484f2620570bbb59.woff",
|
26
|
+
"fontcustom/fontcustom_82a59e769bc60192484f2620570bbb59.eot"
|
22
27
|
],
|
23
28
|
:glyphs => {
|
24
29
|
:"a_r3ally-exotic-f1le-name" => {
|
25
30
|
:codepoint => 61696,
|
26
|
-
:source => "
|
31
|
+
:source => "vectors/a_R3ally-eXotic f1Le Name.svg"
|
27
32
|
},
|
28
33
|
:c => {
|
29
34
|
:codepoint => 61697,
|
30
|
-
:source => "
|
35
|
+
:source => "vectors/C.svg"
|
31
36
|
},
|
32
37
|
:d => {
|
33
38
|
:codepoint => 61698,
|
34
|
-
:source => "
|
39
|
+
:source => "vectors/D.svg"}
|
35
40
|
},
|
36
41
|
:options => {
|
37
42
|
:autowidth => false,
|
@@ -39,23 +44,23 @@ RSpec.configure do |c|
|
|
39
44
|
:css_selector => ".icon-{{glyph}}",
|
40
45
|
:debug => false,
|
41
46
|
:font_name => "fontcustom",
|
47
|
+
:force => true,
|
42
48
|
:input => {
|
43
|
-
:templates => "
|
44
|
-
:vectors => "
|
49
|
+
:templates => "vectors",
|
50
|
+
:vectors => "vectors"
|
45
51
|
},
|
46
|
-
:manifest => "#{root}/.fontcustom-manifest.json",
|
47
52
|
:no_hash => false,
|
48
53
|
:output => {
|
49
|
-
:css => "
|
50
|
-
:fonts => "
|
51
|
-
:preview => "
|
54
|
+
:css => "fontcustom",
|
55
|
+
:fonts => "fontcustom",
|
56
|
+
:preview => "fontcustom"
|
52
57
|
},
|
53
58
|
:preprocessor_path => nil,
|
54
|
-
:project_root => "#{root}",
|
55
59
|
:quiet => true,
|
56
60
|
:templates => [
|
57
|
-
"
|
58
|
-
"
|
61
|
+
"css",
|
62
|
+
"scss",
|
63
|
+
"preview"
|
59
64
|
]
|
60
65
|
},
|
61
66
|
:templates => []
|
@@ -80,7 +85,7 @@ RSpec.configure do |c|
|
|
80
85
|
|
81
86
|
def live_test
|
82
87
|
testdir = fixture File.join("sandbox", "test")
|
83
|
-
FileUtils.rm_r testdir
|
88
|
+
FileUtils.rm_r testdir if File.directory?(testdir)
|
84
89
|
FileUtils.mkdir testdir
|
85
90
|
FileUtils.cp_r fixture("shared/vectors"), testdir
|
86
91
|
FileUtils.cd testdir do
|
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.3.0
|
4
|
+
version: 1.3.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-12-
|
12
|
+
date: 2013-12-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
@@ -169,7 +169,7 @@ files:
|
|
169
169
|
- spec/fontcustom/manifest_spec.rb
|
170
170
|
- spec/fontcustom/options_spec.rb
|
171
171
|
- spec/fontcustom/utility_spec.rb
|
172
|
-
- spec/fontcustom/watcher_spec.rb
|
172
|
+
- spec/fontcustom/watcher_spec.rb
|
173
173
|
- spec/spec_helper.rb
|
174
174
|
homepage: http://fontcustom.com
|
175
175
|
licenses: []
|
@@ -186,9 +186,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
186
186
|
version: '0'
|
187
187
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
188
188
|
requirements:
|
189
|
-
- - '
|
189
|
+
- - '>='
|
190
190
|
- !ruby/object:Gem::Version
|
191
|
-
version:
|
191
|
+
version: '0'
|
192
192
|
requirements: []
|
193
193
|
rubyforge_project:
|
194
194
|
rubygems_version: 2.1.9
|
@@ -230,5 +230,5 @@ test_files:
|
|
230
230
|
- spec/fontcustom/manifest_spec.rb
|
231
231
|
- spec/fontcustom/options_spec.rb
|
232
232
|
- spec/fontcustom/utility_spec.rb
|
233
|
-
- spec/fontcustom/watcher_spec.rb
|
233
|
+
- spec/fontcustom/watcher_spec.rb
|
234
234
|
- spec/spec_helper.rb
|