fontcustom 1.3.1 → 1.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/.travis.yml +1 -0
- data/CHANGELOG.md +6 -0
- data/README.md +1 -0
- data/lib/fontcustom/generator/template.rb +11 -5
- data/lib/fontcustom/templates/_fontcustom-rails.scss +1 -1
- data/lib/fontcustom/templates/_fontcustom.scss +1 -1
- data/lib/fontcustom/version.rb +1 -1
- data/spec/fontcustom/generator/template_spec.rb +18 -8
- metadata +2 -4
- data/spec/fontcustom/generator/template_spec.rb.off +0 -215
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c735f457e4f3c87c9fe6a4bfb96a838ceb41e5ed
|
4
|
+
data.tar.gz: 9cb39edaaed9d22c46cc5293de50659c5d259544
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a01dd169d606ae246fe0b31cca4c511f9b2d13364f9cb22253912c28fd0ca14c4e8de3623016c3cc67a545e2f51191e9cd53e0278ea445cfe93b63e20e428b0
|
7
|
+
data.tar.gz: 315d840c2ffb6d314a9e0db5df8f852c6cc47ea5d22e627974769504523b86524b8cbde3be92f2420027058f0f25578870813a2b8171e727c5ca0c860e6ce243
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
## 1.3.2 (1/31/2014)
|
2
|
+
|
3
|
+
* Fixes `preprocessor_path` for Rails asset pipeline / Sprockets ([#162](https://github.com/FontCustom/fontcustom/pull/162), [#167](https://github.com/FontCustom/fontcustom/pull/167))
|
4
|
+
* Fixes bug where `preprocessor_path` was ignored by the scss template ([#171](https://github.com/FontCustom/fontcustom/issues/171))
|
5
|
+
* Fixes bug where relative output paths containing ".." would fail to compile
|
6
|
+
|
1
7
|
## 1.3.1 (12/28/2013)
|
2
8
|
|
3
9
|
* Fixes syntax error in generate.py that affects Python 2.6
|
data/README.md
CHANGED
@@ -85,6 +85,7 @@ templates: [ css, preview ] # List of templates to generate alongside
|
|
85
85
|
# Possible values: preview, css, scss, scss-rails
|
86
86
|
css_selector: .icon-{{glyph}} # CSS selector format (`{{glyph}}` is replaced)
|
87
87
|
preprocessor_path: "" # Font path used in CSS proprocessor templates
|
88
|
+
# Set to "" or false to use the bare font name
|
88
89
|
|
89
90
|
# Custom templates should live in the `input`
|
90
91
|
# or `input[:templates]` directory and be added
|
@@ -32,11 +32,17 @@ module Fontcustom
|
|
32
32
|
def set_relative_paths
|
33
33
|
fonts = @manifest.get :fonts
|
34
34
|
name = File.basename fonts.first, File.extname(fonts.first)
|
35
|
-
fonts_path = Pathname.new
|
36
|
-
css_path = Pathname.new
|
37
|
-
preview_path = Pathname.new
|
35
|
+
fonts_path = Pathname.new(@options[:output][:fonts]).realdirpath
|
36
|
+
css_path = Pathname.new(@options[:output][:css]).realdirpath
|
37
|
+
preview_path = Pathname.new(@options[:output][:preview]).realdirpath
|
38
38
|
@font_path = File.join fonts_path.relative_path_from(css_path).to_s, name
|
39
|
-
@font_path_alt = @options[:preprocessor_path].nil?
|
39
|
+
@font_path_alt = if @options[:preprocessor_path].nil?
|
40
|
+
@font_path
|
41
|
+
elsif ! @options[:preprocessor_path] || @options[:preprocessor_path].empty?
|
42
|
+
name
|
43
|
+
else
|
44
|
+
File.join(@options[:preprocessor_path], name)
|
45
|
+
end
|
40
46
|
@font_path_preview = File.join fonts_path.relative_path_from(preview_path).to_s, name
|
41
47
|
end
|
42
48
|
|
@@ -109,7 +115,7 @@ module Fontcustom
|
|
109
115
|
|
110
116
|
def font_face(style = :normal)
|
111
117
|
case style
|
112
|
-
when :
|
118
|
+
when :preprocessor
|
113
119
|
url = "font-url"
|
114
120
|
path = @font_path_alt
|
115
121
|
when :preview
|
data/lib/fontcustom/version.rb
CHANGED
@@ -24,28 +24,38 @@ describe Fontcustom::Generator::Template do
|
|
24
24
|
it "should assign @font_path, @font_path_alt, and @font_path_preview" do
|
25
25
|
gen = Fontcustom::Generator::Template.new fixture("generators/.fontcustom-manifest.json")
|
26
26
|
options = gen.instance_variable_get :@options
|
27
|
-
options[:output] = {:fonts => fixture("
|
27
|
+
options[:output] = {:fonts => fixture("sandbox/test/fonts"), :css => fixture("sandbox/test/css"), :preview => fixture("sandbox/test")}
|
28
28
|
|
29
29
|
gen.send :set_relative_paths
|
30
|
-
gen.instance_variable_get(:@font_path).should match("
|
31
|
-
gen.instance_variable_get(:@font_path_alt).should match("
|
32
|
-
gen.instance_variable_get(:@font_path_preview).should match("
|
30
|
+
gen.instance_variable_get(:@font_path).should match("../fonts")
|
31
|
+
gen.instance_variable_get(:@font_path_alt).should match("../fonts")
|
32
|
+
gen.instance_variable_get(:@font_path_preview).should match(".")
|
33
33
|
end
|
34
34
|
|
35
|
-
it "should assign @font_path_alt if :
|
35
|
+
it "should assign @font_path_alt if :preprocessor_path is set" do
|
36
36
|
gen = Fontcustom::Generator::Template.new fixture("generators/.fontcustom-manifest.json")
|
37
37
|
options = gen.instance_variable_get :@options
|
38
|
-
options[:
|
39
|
-
options[:output] = {:fonts => fixture("
|
38
|
+
options[:preprocessor_path] = "fonts/fontcustom"
|
39
|
+
options[:output] = {:fonts => fixture("sandbox/test/fonts"), :css => fixture("sandbox/test/css"), :preview => fixture("sandbox/test")}
|
40
40
|
|
41
41
|
gen.send :set_relative_paths
|
42
42
|
gen.instance_variable_get(:@font_path_alt).should match("fonts/fontcustom")
|
43
43
|
end
|
44
44
|
|
45
|
+
it "should assign @font_path_alt as bare font name if :preprocessor_path is false" do
|
46
|
+
gen = Fontcustom::Generator::Template.new fixture("generators/.fontcustom-manifest.json")
|
47
|
+
options = gen.instance_variable_get :@options
|
48
|
+
options[:preprocessor_path] = false
|
49
|
+
options[:output] = {:fonts => fixture("sandbox/test/fonts"), :css => fixture("sandbox/test/css"), :preview => fixture("sandbox/test")}
|
50
|
+
|
51
|
+
gen.send :set_relative_paths
|
52
|
+
gen.instance_variable_get(:@font_path_alt).should_not match("../fonts")
|
53
|
+
end
|
54
|
+
|
45
55
|
it "should assign '.' when paths are the same" do
|
46
56
|
gen = Fontcustom::Generator::Template.new fixture("generators/.fontcustom-manifest.json")
|
47
57
|
options = gen.instance_variable_get :@options
|
48
|
-
options[:output] = {:fonts => fixture("
|
58
|
+
options[:output] = {:fonts => fixture("sandbox/test/fonts"), :css => fixture("sandbox/test/fonts"), :preview => fixture("sandbox/test/fonts")}
|
49
59
|
|
50
60
|
gen.send :set_relative_paths
|
51
61
|
gen.instance_variable_get(:@font_path).should match("./")
|
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.
|
4
|
+
version: 1.3.2
|
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:
|
12
|
+
date: 2014-01-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
@@ -165,7 +165,6 @@ files:
|
|
165
165
|
- spec/fontcustom/cli_spec.rb
|
166
166
|
- spec/fontcustom/generator/font_spec.rb
|
167
167
|
- spec/fontcustom/generator/template_spec.rb
|
168
|
-
- spec/fontcustom/generator/template_spec.rb.off
|
169
168
|
- spec/fontcustom/manifest_spec.rb
|
170
169
|
- spec/fontcustom/options_spec.rb
|
171
170
|
- spec/fontcustom/utility_spec.rb
|
@@ -226,7 +225,6 @@ test_files:
|
|
226
225
|
- spec/fontcustom/cli_spec.rb
|
227
226
|
- spec/fontcustom/generator/font_spec.rb
|
228
227
|
- spec/fontcustom/generator/template_spec.rb
|
229
|
-
- spec/fontcustom/generator/template_spec.rb.off
|
230
228
|
- spec/fontcustom/manifest_spec.rb
|
231
229
|
- spec/fontcustom/options_spec.rb
|
232
230
|
- spec/fontcustom/utility_spec.rb
|
@@ -1,215 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Fontcustom::Generator::Template do
|
4
|
-
before(:each) do
|
5
|
-
Fontcustom::Options.any_instance.stub :say_message
|
6
|
-
end
|
7
|
-
|
8
|
-
def generator(options)
|
9
|
-
opts = Fontcustom::Options.new(options)
|
10
|
-
Fontcustom::Generator::Template.new([opts])
|
11
|
-
end
|
12
|
-
|
13
|
-
context "#get_manifest" do
|
14
|
-
it "should raise error if data file doesn't exist" do
|
15
|
-
gen = generator(
|
16
|
-
:project_root => fixture,
|
17
|
-
:input => "shared/vectors",
|
18
|
-
:quiet => true
|
19
|
-
)
|
20
|
-
expect { gen.get_manifest }.to raise_error Fontcustom::Error, /\.fontcustom-manifest\.json/
|
21
|
-
end
|
22
|
-
|
23
|
-
it "should assign @data from data file" do
|
24
|
-
gen = generator(
|
25
|
-
:project_root => fixture("generators"),
|
26
|
-
:input => "../shared/vectors",
|
27
|
-
:quiet => true
|
28
|
-
)
|
29
|
-
gen.get_manifest
|
30
|
-
gen.instance_variable_get(:@data)[:templates].should =~ data_file_contents[:templates]
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
context "#reset_output" do
|
35
|
-
subject do
|
36
|
-
gen = generator(
|
37
|
-
:project_root => fixture("generators"),
|
38
|
-
:input => "../shared/vectors",
|
39
|
-
:output => "mixed-output",
|
40
|
-
:quiet => true
|
41
|
-
)
|
42
|
-
gen.stub :remove_file
|
43
|
-
gen.stub :overwrite_file
|
44
|
-
gen.instance_variable_set(:@data, data_file_contents)
|
45
|
-
gen
|
46
|
-
end
|
47
|
-
|
48
|
-
it "should delete files from @data[:templates]" do
|
49
|
-
subject.should_receive(:remove_file).once.with(/fontcustom\.css/, anything)
|
50
|
-
subject.reset_output
|
51
|
-
end
|
52
|
-
|
53
|
-
it "should not delete non-template files" do
|
54
|
-
subject.should_not_receive(:remove_file).with("dont-delete-me.bro")
|
55
|
-
subject.should_not_receive(:remove_file).with("another-font.ttf")
|
56
|
-
subject.should_not_receive(:remove_file).with(/fontcustom_cc5ce52f2ae4f9ce2e7ee8131bbfee1e/)
|
57
|
-
subject.reset_output
|
58
|
-
end
|
59
|
-
|
60
|
-
it "should empty @data[:fonts]" do
|
61
|
-
subject.reset_output
|
62
|
-
subject.instance_variable_get(:@data)[:templates].should be_empty
|
63
|
-
end
|
64
|
-
|
65
|
-
it "should update the data file" do
|
66
|
-
file = fixture("generators/.fontcustom-manifest.json")
|
67
|
-
subject.should_receive(:overwrite_file).once.with(file, /"templates":/)
|
68
|
-
subject.reset_output
|
69
|
-
end
|
70
|
-
|
71
|
-
it "should be silent" do
|
72
|
-
stdout = capture(:stdout) { subject.reset_output }
|
73
|
-
stdout.should == ""
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
context "#make_relative_paths" do
|
78
|
-
it "should assign @font_path, @font_path_alt, and @font_path_preview" do
|
79
|
-
gen = generator(
|
80
|
-
:project_root => fixture,
|
81
|
-
:input => "shared/vectors",
|
82
|
-
:output => {:fonts => "foo/fonts", :css => "output/css", :preview => "views/"}
|
83
|
-
)
|
84
|
-
gen.instance_variable_set :@data, data_file_contents
|
85
|
-
gen.make_relative_paths
|
86
|
-
gen.instance_variable_get(:@font_path).should match("../../foo/fonts")
|
87
|
-
gen.instance_variable_get(:@font_path_alt).should match("../../foo/fonts")
|
88
|
-
gen.instance_variable_get(:@font_path_preview).should match("../foo/fonts")
|
89
|
-
end
|
90
|
-
|
91
|
-
it "should assign @font_path_alt if :preprocessor_font_path is set" do
|
92
|
-
gen = generator(
|
93
|
-
:project_root => fixture,
|
94
|
-
:preprocessor_font_path => "fonts/fontcustom",
|
95
|
-
:input => "shared/vectors",
|
96
|
-
:output => {:fonts => "foo/bar/fonts", :css => "output/css", :preview => ""}
|
97
|
-
)
|
98
|
-
gen.instance_variable_set "@data", data_file_contents
|
99
|
-
gen.make_relative_paths
|
100
|
-
gen.instance_variable_get(:@font_path_alt).should match("fonts/fontcustom")
|
101
|
-
end
|
102
|
-
|
103
|
-
it "should assign '.' when paths are the same" do
|
104
|
-
gen = generator(
|
105
|
-
:project_root => fixture,
|
106
|
-
:input => "shared/vectors",
|
107
|
-
:output => "output"
|
108
|
-
)
|
109
|
-
gen.instance_variable_set "@data", data_file_contents
|
110
|
-
gen.make_relative_paths
|
111
|
-
gen.instance_variable_get(:@font_path).should match("./")
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
context "#generate" do
|
116
|
-
subject do
|
117
|
-
gen = generator(
|
118
|
-
:project_root => fixture("generators"),
|
119
|
-
:input => {:vectors => "../shared/vectors", :templates => "../shared/templates"},
|
120
|
-
:output => "mixed-output",
|
121
|
-
:templates => %W|scss css custom.css|,
|
122
|
-
:quiet => true
|
123
|
-
)
|
124
|
-
gen.instance_variable_set :@data, data_file_contents
|
125
|
-
gen.stub :template
|
126
|
-
gen.stub :overwrite_file
|
127
|
-
gen
|
128
|
-
end
|
129
|
-
|
130
|
-
it "should call #template for each template" do
|
131
|
-
subject.should_receive(:template).exactly(3).times do |*args|
|
132
|
-
args[1].should match(/(fontcustom\.css|_fontcustom\.scss|custom\.css)/)
|
133
|
-
end
|
134
|
-
subject.generate
|
135
|
-
end
|
136
|
-
|
137
|
-
it "should update data file with generated templates" do
|
138
|
-
file = fixture("generators/.fontcustom-manifest.json")
|
139
|
-
subject.should_receive(:overwrite_file).once.with do |path, content|
|
140
|
-
path.should == file
|
141
|
-
content.should match(/fontcustom\.css/)
|
142
|
-
content.should match(/_fontcustom\.scss/)
|
143
|
-
content.should match(/custom\.css/)
|
144
|
-
end
|
145
|
-
subject.generate
|
146
|
-
end
|
147
|
-
|
148
|
-
it "should be silent if :quiet is set" do
|
149
|
-
stdout = capture(:stdout) { subject.generate }
|
150
|
-
stdout.should == ""
|
151
|
-
end
|
152
|
-
|
153
|
-
it "should rename stock templates according to opts.font_name" do
|
154
|
-
gen = generator(
|
155
|
-
:project_root => fixture("generators"),
|
156
|
-
:font_name => "Test Font",
|
157
|
-
:input => {:vectors => "../shared/vectors", :templates => "../shared/templates"},
|
158
|
-
:templates => %W|scss css|,
|
159
|
-
:quiet => true
|
160
|
-
)
|
161
|
-
gen.instance_variable_set :@data, data_file_contents
|
162
|
-
gen.stub :template
|
163
|
-
gen.stub :overwrite_file
|
164
|
-
gen.should_receive(:template).exactly(2).times do |*args|
|
165
|
-
args[1].should match(/(Test-Font\.css|_Test-Font\.scss)/)
|
166
|
-
end
|
167
|
-
gen.generate
|
168
|
-
end
|
169
|
-
|
170
|
-
context "when various output locations are given" do
|
171
|
-
subject do
|
172
|
-
gen = generator(
|
173
|
-
:project_root => fixture,
|
174
|
-
:input => {:vectors => "shared/vectors", :templates => "shared/templates"},
|
175
|
-
:output => {:fonts => "output/fonts", :css => "output/css", :preview => "output/views", "custom.css" => "output/custom"},
|
176
|
-
:templates => %W|scss preview css custom.css regular.css|,
|
177
|
-
:quiet => true
|
178
|
-
)
|
179
|
-
gen.instance_variable_set :@data, data_file_contents
|
180
|
-
gen.stub :template
|
181
|
-
gen.stub :overwrite_file
|
182
|
-
gen
|
183
|
-
end
|
184
|
-
|
185
|
-
# 6 times because preview also includes preview-css
|
186
|
-
it "should output custom templates to their matching :output paths" do
|
187
|
-
subject.should_receive(:template).exactly(5).times do |*args|
|
188
|
-
if File.basename(args[0]) == :"custom.css"
|
189
|
-
args[1].should == fixture("output/custom/custom.css")
|
190
|
-
end
|
191
|
-
end
|
192
|
-
subject.generate
|
193
|
-
end
|
194
|
-
|
195
|
-
it "should output css templates into :css" do
|
196
|
-
subject.should_receive(:template).exactly(5).times do |*args|
|
197
|
-
name = File.basename(args[0])
|
198
|
-
if %w|_fontcustom.scss fontcustom.css regular.css|.include? name
|
199
|
-
args[1].should match(/output\/css\/#{name}/)
|
200
|
-
end
|
201
|
-
end
|
202
|
-
subject.generate
|
203
|
-
end
|
204
|
-
|
205
|
-
it "should output fontcustom-preview.html into :preview" do
|
206
|
-
subject.should_receive(:template).exactly(5).times do |*args|
|
207
|
-
if File.basename(args[0]) == "fontcustom-preview.html"
|
208
|
-
args[1].should == fixture("output/views/fontcustom-preview.html")
|
209
|
-
end
|
210
|
-
end
|
211
|
-
subject.generate
|
212
|
-
end
|
213
|
-
end
|
214
|
-
end
|
215
|
-
end
|