fontcustom 1.3.3 → 1.3.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: a6e8bb4958c86331ee3892c42e9a10b10cd3df0d
4
- data.tar.gz: de87bb5735a42ebd41672e739f44c00bdc5452f7
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MTRkNmEyNmI5ZTFhNjhhMTVmZTdlOTlkYzRiZTRhYWY2OGFkOGNkZg==
5
+ data.tar.gz: !binary |-
6
+ MGUzYTA4ZGNiZjBjN2M1NGJlY2ZkZWQxZDgwZjY3YzNiZjIzZjM3NQ==
5
7
  SHA512:
6
- metadata.gz: f7a94f1314cf98b613bf5bca317ba166c4e2a148f0ae511cc033db551d9691fb04003a7c3ac8aa1c12d5a8bc0049bd6891f050738e0fe2c5968e73127a8ab72c
7
- data.tar.gz: 2fba689d4f3f007385d3419dff4652254ad0cddc9eaf97129baeba392188b3fcca58ab598efcdc7cd5215ec584b3b79583198cb7e3328de77393e81f2597ce15
8
+ metadata.gz: !binary |-
9
+ ZWVjYTY1N2Q4NWRkNzY0ZTFlMzY1ZGFmZTc1ZmNkZGJjZTM1YmYyMjA4NDc1
10
+ ZjI4MmY0NzJlODRjOWVhNTkxMTc2YTE4NTRmZWM4OWE0N2FiNWM5ZGM5N2E3
11
+ OWQ2NjlkYTBkMGRhODhmZjljYTMzYzUyZGE2MWVhOGIzOTk0MDg=
12
+ data.tar.gz: !binary |-
13
+ OWY3MTM5OWE1ZWMxMGVkMDFjNTExNGIzMTVjM2VmZjE3NDY3YTZjODhjMTI4
14
+ ZTQ4NGI0OWZiYWQzMGEwYzg0NTBmZjQ2N2RlYjgxNGIwMzFlY2ZhMzk5ZTNj
15
+ MTA0OGE2YzFiMWJiMGZlZmEwYzE4MTE1NDhhZjIyMjJiNzMxOGM=
@@ -10,4 +10,11 @@ rvm:
10
10
  - 2.0.0
11
11
  - 1.9.3
12
12
  - 1.9.2
13
+ gemfile:
14
+ - Gemfile
15
+ - gemfiles/Gemfile.listen_1
16
+ matrix:
17
+ exclude:
18
+ - gemfile: Gemfile
19
+ rvm: 1.9.2
13
20
  script: bundle exec rake
@@ -1,3 +1,15 @@
1
+ ## 1.3.4 (10/11/2014)
2
+
3
+ * Updates rspec tests to be compatible with rspec v3.1.6
4
+ * Add additional metrics to make it easier to have different size icon fonts ([#175](https://github.com/FontCustom/fontcustom/pull/175))
5
+ * Add woff data uri to generated CSS + template helper ([#182](https://github.com/FontCustom/fontcustom/pull/182))
6
+ * Support listen v1 and v2 ([#191](https://github.com/FontCustom/fontcustom/pull/191))
7
+ * Add multiple classes to config file ([#174](https://github.com/FontCustom/fontcustom/issues/174))
8
+ * Don't strip "%" symbol (and other potentially valid characters) from CSS selector ([#173](https://github.com/FontCustom/fontcustom/issues/173))
9
+ * Fix bug where custom template path appears in output filenames ([#198](https://github.com/FontCustom/fontcustom/pull/198), [#172](https://github.com/FontCustom/fontcustom/issues/172))
10
+ * SCSS content variables like Font Awesome ([#151](https://github.com/FontCustom/fontcustom/issues/151))
11
+ * Running compile on a folder containing directories shouldn't throw an error
12
+
1
13
  ## 1.3.3 (2/20/2014)
2
14
 
3
15
  * Removes ttfautohint ([#160c](https://github.com/FontCustom/fontcustom/pull/160#issuecomment-34593191))
data/README.md CHANGED
@@ -73,6 +73,10 @@ output:
73
73
  ```yml
74
74
  font_name: fontcustom # Also sets the default output directory and
75
75
  # the name of generated stock templates
76
+ font_design_size: 16 # The size of the original glyphs
77
+ font_em: 512 # Scale font up to this size
78
+ font_ascent: 448 # Location of font ascent
79
+ font_descent: 64 # Location of font descent
76
80
  no_hash: false # Don't add asset-busting hashes to font files
77
81
  autowidth: false # Automatically size glyphs based on the width of
78
82
  # their individual vectors
@@ -20,7 +20,7 @@ Gem::Specification.new do |gem|
20
20
 
21
21
  gem.add_dependency "json", "~>1.4"
22
22
  gem.add_dependency "thor", "~>0.14"
23
- gem.add_dependency "listen", "~>1.0"
23
+ gem.add_dependency "listen", ">=1.0","<3.0"
24
24
 
25
25
  gem.add_development_dependency "rake"
26
26
  gem.add_development_dependency "bundler"
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in fontcustom.gemspec
4
+ gemspec
5
+
6
+ gem "listen", "~>1.0"
@@ -28,6 +28,10 @@ module Fontcustom
28
28
  :config => nil,
29
29
  :templates => %w|css preview|,
30
30
  :font_name => "fontcustom",
31
+ :font_design_size => 16,
32
+ :font_em => 512,
33
+ :font_ascent => 448,
34
+ :font_descent => 64,
31
35
  :css_selector => ".icon-{{glyph}}",
32
36
  :preprocessor_path => nil,
33
37
  :autowidth => false,
@@ -38,8 +38,8 @@ module Fontcustom
38
38
 
39
39
  # Calculates a hash of vectors, options, and templates (content and filenames)
40
40
  def checksum
41
- files = Dir.glob File.join(@options[:input][:vectors], "*.svg")
42
- files += Dir.glob File.join(@options[:input][:templates], "*")
41
+ files = Dir.glob(File.join(@options[:input][:vectors], "*.svg")).select { |fn| File.file?(fn) }
42
+ files += Dir.glob(File.join(@options[:input][:templates], "*")).select { |fn| File.file?(fn) }
43
43
  content = files.map { |file| File.read(file) }.join
44
44
  content << files.join
45
45
  content << @options.flatten(2).join
@@ -25,6 +25,22 @@ module Fontcustom
25
25
  class_option :font_name, :aliases => "-f", :type => :string,
26
26
  :desc => "The font's name. Also determines the file names of generated templates.",
27
27
  :default => DEFAULT_OPTIONS[:font_name]
28
+
29
+ class_option :font_design_size, :aliases => '-x', :type => :numeric,
30
+ :desc => "Size (in pica points) for which this font was designed.",
31
+ :default => DEFAULT_OPTIONS[:font_design_size]
32
+
33
+ class_option :font_em, :aliases => '-m', :type => :numeric,
34
+ :desc => "The em size of the font. Setting this will scale the entire font to the given size.",
35
+ :default => DEFAULT_OPTIONS[:font_em]
36
+
37
+ class_option :font_ascent, :aliases => '-a', :type => :numeric,
38
+ :desc => "The font's ascent.",
39
+ :default => DEFAULT_OPTIONS[:font_ascent]
40
+
41
+ class_option :font_descent, :aliases => '-z', :type => :numeric,
42
+ :desc => "The font's descent.",
43
+ :default => DEFAULT_OPTIONS[:font_descent]
28
44
 
29
45
  class_option :css_selector, :aliases => "-s", :type => :string,
30
46
  :desc => "Format of generated CSS selector. \"{{glyph}}\" is substituted for the glyph name.",
@@ -1,5 +1,6 @@
1
1
  require "json"
2
2
  require "pathname"
3
+ require "base64"
3
4
 
4
5
  module Fontcustom
5
6
  module Generator
@@ -36,7 +37,7 @@ module Fontcustom
36
37
  css_path = Pathname.new(@options[:output][:css]).realdirpath
37
38
  preview_path = Pathname.new(@options[:output][:preview]).realdirpath
38
39
  @font_path = File.join fonts_path.relative_path_from(css_path).to_s, name
39
- @font_path_alt = if @options[:preprocessor_path].nil?
40
+ @font_path_alt = if @options[:preprocessor_path].nil?
40
41
  @font_path
41
42
  elsif ! @options[:preprocessor_path] || @options[:preprocessor_path].empty?
42
43
  name
@@ -51,9 +52,9 @@ module Fontcustom
51
52
  existing = @manifest.get :templates
52
53
  created = []
53
54
  begin
54
- @options[:templates].each do |source|
55
+ @options[:templates].each do |template_name|
55
56
  begin
56
- source = get_source_path(source)
57
+ source = get_source_path(template_name)
57
58
  target = get_target_path(source)
58
59
  template source, target, :verbose => false, :force => true
59
60
  end
@@ -89,7 +90,7 @@ module Fontcustom
89
90
  packaged = %w|fontcustom-preview.html fontcustom.css _fontcustom.scss _fontcustom-rails.scss|
90
91
 
91
92
  target = if @options[:output].keys.include? base.to_sym
92
- File.join @options[:output][base.to_sym], source
93
+ File.join @options[:output][base.to_sym], base
93
94
  elsif ext && css_exts.include?(ext)
94
95
  File.join @options[:output][:css], base
95
96
  elsif source.match(/fontcustom-preview\.html/)
@@ -129,6 +130,7 @@ module Fontcustom
129
130
  font-family: "#{font_name}";
130
131
  src: #{url}("#{path}.eot");
131
132
  src: #{url}("#{path}.eot?#iefix") format("embedded-opentype"),
133
+ #{url}(#{woff_data_uri}),
132
134
  #{url}("#{path}.woff") format("woff"),
133
135
  #{url}("#{path}.ttf") format("truetype"),
134
136
  #{url}("#{path}.svg##{font_name}") format("svg");
@@ -144,6 +146,15 @@ module Fontcustom
144
146
  }|
145
147
  end
146
148
 
149
+ def woff_data_uri
150
+ "data:application/x-font-woff;charset=utf-8;base64,#{woff_base64}"
151
+ end
152
+
153
+ def woff_base64
154
+ woff_path = File.join(@options[:output][:fonts], "#{@font_path_alt}.woff")
155
+ Base64.encode64(File.read(File.join(woff_path))).gsub("\n", "")
156
+ end
157
+
147
158
  def glyph_selectors
148
159
  output = @glyphs.map do |name, value|
149
160
  @options[:css_selector].sub("{{glyph}}", name.to_s) + ":before"
@@ -90,7 +90,7 @@ module Fontcustom
90
90
  raise Fontcustom::Error,
91
91
  "CSS selector `#{@options[:css_selector]}` should contain the \"{{glyph}}\" placeholder."
92
92
  end
93
- @options[:css_selector] = @options[:css_selector].strip.gsub(/[^\.#\{\}\w]/, "-")
93
+ @options[:css_selector] = @options[:css_selector].strip.gsub(/[^&%=\[\]\.#\{\}""\d\w]/, "-")
94
94
  end
95
95
 
96
96
  def set_input_paths
@@ -28,20 +28,19 @@ options = manifest['options']
28
28
  # Font
29
29
  #
30
30
 
31
+ design_px = options['font_em'] / options['font_design_size']
32
+
31
33
  font = fontforge.font()
32
34
  font.encoding = 'UnicodeFull'
33
- font.design_size = 16
34
- font.em = 512
35
- font.ascent = 448
36
- font.descent = 64
35
+ font.design_size = options['font_design_size']
36
+ font.em = options['font_em']
37
+ font.ascent = options['font_ascent']
38
+ font.descent = options['font_descent']
37
39
  font.fontname = options['font_name']
38
40
  font.familyname = options['font_name']
39
41
  font.fullname = options['font_name']
40
42
  if options['autowidth']:
41
- font.autoWidth(0, 0, 512)
42
-
43
- # NOTE not referenced anywhere, safe to remove?
44
- KERNING = 15
43
+ font.autoWidth(0, 0, options['font_em'])
45
44
 
46
45
  #
47
46
  # Glyphs
@@ -73,7 +72,13 @@ def createGlyph( name, source, code ):
73
72
  glyph.left_side_bearing = glyph.right_side_bearing = 0
74
73
  glyph.round()
75
74
  else:
76
- glyph.width = 512
75
+ glyph.width = options['font_em']
76
+ width = glyph.width - glyph.left_side_bearing - glyph.right_side_bearing
77
+ aligned_to_pixel_grid = (width % design_px == 0)
78
+ if (aligned_to_pixel_grid):
79
+ shift = glyph.left_side_bearing % design_px
80
+ glyph.left_side_bearing = glyph.left_side_bearing - shift
81
+ glyph.right_side_bearing = glyph.right_side_bearing + shift
77
82
 
78
83
  for glyph, data in manifest['glyphs'].iteritems():
79
84
  name = createGlyph(glyph, data['source'], data['codepoint'])
@@ -12,3 +12,5 @@
12
12
  }
13
13
 
14
14
  <%= glyphs %>
15
+ <% @glyphs.each do |name, value| %>
16
+ $font-<%= font_name.gsub(/[^\w\d_]/, '-') %>-<%= name.to_s %>: "\<%= value[:codepoint].to_s(16) %>";<% end %>
@@ -154,7 +154,7 @@
154
154
  selector = @options[:css_selector].sub('{{glyph}}', name.to_s) %>
155
155
  <div class="glyph">
156
156
  <div class="preview-glyphs">
157
- <% scale.each do |n| %><span class="step size-<%= n %>"><span class="letters">Pp</span><i id="<%= selector[1..-1] %>" class="<%= selector[1..-1] %>"></i></span><% end %>
157
+ <% scale.each do |n| %><span class="step size-<%= n %>"><span class="letters">Pp</span><i id="<%= selector[1..-1] %>" class="<%= selector[1..-1].gsub('.', ' ') %>"></i></span><% end %>
158
158
  </div>
159
159
  <div class="preview-scale">
160
160
  <% scale.each do |n| %><span class="step"><%= n %></span><% end %>
@@ -5,6 +5,10 @@
5
5
  # --------------------------------------------------------------------------- #
6
6
 
7
7
  font_name: fontcustom
8
+ font_design_size: 16
9
+ font_em: 512
10
+ font_ascent: 448
11
+ font_descent: 64
8
12
  css_selector: .icon-{{glyph}}
9
13
  preprocessor_path: ""
10
14
  autowidth: false
@@ -1,3 +1,3 @@
1
1
  module Fontcustom
2
- VERSION = "1.3.3"
2
+ VERSION = "1.3.4"
3
3
  end
@@ -14,16 +14,7 @@ module Fontcustom
14
14
  packaged = %w|preview css scss scss-rails|
15
15
  templates.delete_if { |template| packaged.include?(template) }
16
16
 
17
- if templates.empty?
18
- @listener = Listen.to(@options[:input][:vectors])
19
- else
20
- @listener = Listen.to(@options[:input][:vectors], @options[:input][:templates])
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
17
+ create_listener(templates)
27
18
  end
28
19
 
29
20
  def watch
@@ -35,11 +26,32 @@ module Fontcustom
35
26
 
36
27
  private
37
28
 
29
+ def create_listener(templates)
30
+ listen_options = {}
31
+ listen_options[:polling_fallback_message] = false if @is_test
32
+
33
+ listen_dirs = [@options[:input][:vectors]]
34
+ listen_dirs << @options[:input][:templates] unless templates.empty?
35
+
36
+ if listen_eq2
37
+ listen_options[:only] = /(#{templates.join("|")}|.+\.svg)$/
38
+ @listener = Listen.to(listen_dirs, listen_options, &callback)
39
+ else
40
+ listen_options[:filter] = /(#{templates.join("|")}|.+\.svg)$/
41
+ listen_options[:relative_paths] = true
42
+ @listener = Listen::Listener.new(listen_dirs, listen_options, &callback)
43
+ end
44
+ end
45
+
38
46
  def start
39
47
  if @is_test # Non-blocking listener
40
48
  @listener.start
41
49
  else
42
- @listener.start!
50
+ if listen_eq2
51
+ @listener.start.join
52
+ else
53
+ @listener.start!
54
+ end
43
55
  end
44
56
  end
45
57
 
@@ -65,5 +77,14 @@ module Fontcustom
65
77
  def compile
66
78
  @base.compile
67
79
  end
80
+
81
+ def listen_eq2
82
+ begin
83
+ require 'listen/version'
84
+ ::Listen::VERSION =~ /^2\./
85
+ rescue LoadError
86
+ false
87
+ end
88
+ end
68
89
  end
69
90
  end
@@ -1,7 +1,4 @@
1
1
  /*
2
2
  <%= @glyphs.inspect %>
3
3
  */
4
- .foo { color: black; }
5
-
6
- .bar { color: red; }
7
- .bar { color: red; }
4
+ .foo { color: black; }
@@ -1,31 +1,31 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe Fontcustom::Base do
4
- before(:each) { Fontcustom::Manifest.any_instance.stub(:write_file) }
4
+ before(:each) { allow(Fontcustom::Manifest).to receive(:write_file) }
5
5
 
6
6
  context "#compile" do
7
7
  context "when [:checksum][:current] equals [:checksum][:previous]" do
8
8
  it "should show 'no change' message" do
9
- Fontcustom::Base.any_instance.stub :check_fontforge
9
+ allow(Fontcustom::Base).to receive(:check_fontforge)
10
10
  options = double("options")
11
- options.stub(:options).and_return({})
12
- Fontcustom::Options.stub(:new).and_return options
11
+ allow(options).to receive(:options).and_return({})
12
+ allow(Fontcustom::Options).to receive(:new).and_return options
13
13
 
14
14
  output = capture(:stdout) do
15
15
  base = Fontcustom::Base.new({})
16
16
  manifest = base.instance_variable_get :@manifest
17
- manifest.stub(:get).and_return :previous => "abc"
18
- base.stub(:checksum).and_return "abc"
17
+ expect(manifest).to receive(:get).and_return :previous => "abc"
18
+ expect(base).to receive(:checksum).and_return "abc"
19
19
  base.compile
20
20
  end
21
- output.should match(/No changes/)
21
+ expect(output).to match(/No changes/)
22
22
  end
23
23
  end
24
24
  end
25
25
 
26
26
  context ".check_fontforge" do
27
27
  it "should raise error if fontforge isn't installed" do
28
- Fontcustom::Base.any_instance.stub(:"`").and_return("")
28
+ allow_any_instance_of(Fontcustom::Base).to receive(:"`").and_return("")
29
29
  expect { Fontcustom::Base.new(:option => "foo") }.to raise_error Fontcustom::Error, /fontforge/
30
30
  end
31
31
  end
@@ -33,7 +33,7 @@ describe Fontcustom::Base do
33
33
  context ".checksum" do
34
34
  it "should return hash of all vectors and templates" do
35
35
  pending "SHA2 is different on CI servers. Why?"
36
- Fontcustom::Base.any_instance.stub :check_fontforge
36
+ allow(Fontcustom::Base).to receive(:check_fontforge)
37
37
  base = Fontcustom::Base.new({})
38
38
  base.instance_variable_set :@options, {
39
39
  :input => {:vectors => fixture("shared/vectors")},
@@ -7,8 +7,8 @@ describe Fontcustom::CLI do
7
7
  live_test do |testdir|
8
8
  Fontcustom::CLI.start ["compile", "vectors", "--quiet"]
9
9
  manifest = File.join testdir, ".fontcustom-manifest.json"
10
- Dir.glob(File.join(testdir, "fontcustom", "fontcustom_*\.{ttf,svg,woff,eot}")).length.should == 4
11
- File.read(manifest).should match(/"fonts":.+fontcustom\/fontcustom_.+\.ttf"/m)
10
+ expect(Dir.glob(File.join(testdir, "fontcustom", "fontcustom_*\.{ttf,svg,woff,eot}")).length).to eq(4)
11
+ expect(File.read(manifest)).to match(/"fonts":.+fontcustom\/fontcustom_.+\.ttf"/m)
12
12
  end
13
13
  end
14
14
  end
@@ -2,7 +2,7 @@ require "spec_helper"
2
2
 
3
3
  describe Fontcustom::Generator::Font do
4
4
  def generator
5
- Fontcustom::Manifest.any_instance.stub :write_file
5
+ allow_any_instance_of(Fontcustom::Manifest).to receive(:write_file)
6
6
  Fontcustom::Generator::Font.new("")
7
7
  end
8
8
 
@@ -12,9 +12,9 @@ describe Fontcustom::Generator::Font do
12
12
  test_manifest
13
13
  manifest = File.join Dir.pwd, ".fontcustom-manifest.json"
14
14
  gen = Fontcustom::Generator::Font.new manifest
15
- gen.stub :create_fonts
15
+ allow(gen).to receive(:create_fonts)
16
16
  gen.generate
17
- File.read(manifest).should match(/"glyphs":.+"C":/m)
17
+ expect(File.read(manifest)).to match(/"glyphs":.+"C":/m)
18
18
  end
19
19
  end
20
20
 
@@ -23,8 +23,8 @@ describe Fontcustom::Generator::Font do
23
23
  test_manifest
24
24
  manifest = File.join Dir.pwd, ".fontcustom-manifest.json"
25
25
  Fontcustom::Generator::Font.new(manifest).generate
26
- Dir.glob(File.join(testdir, "fontcustom", "fontcustom_*\.{ttf,svg,woff,eot}")).length.should == 4
27
- File.read(manifest).should match(/"fonts":.*fontcustom\/fontcustom_.+\.ttf"/m)
26
+ expect(Dir.glob(File.join(testdir, "fontcustom", "fontcustom_*\.{ttf,svg,woff,eot}")).length).to eq(4)
27
+ expect(File.read(manifest)).to match(/"fonts":.*fontcustom\/fontcustom_.+\.ttf"/m)
28
28
  end
29
29
  end
30
30
  end
@@ -37,8 +37,8 @@ describe Fontcustom::Generator::Font do
37
37
  :quiet => true
38
38
  }
39
39
  gen.instance_variable_set :@options, options
40
- gen.should_receive(:empty_directory).with("path/fonts", :verbose => false)
41
- gen.should_receive(:empty_directory).with("path/vectors", :verbose => false)
40
+ expect(gen).to receive(:empty_directory).with("path/fonts", :verbose => false)
41
+ expect(gen).to receive(:empty_directory).with("path/vectors", :verbose => false)
42
42
  gen.send :create_output_dirs
43
43
  end
44
44
  end
@@ -51,9 +51,9 @@ describe Fontcustom::Generator::Font do
51
51
 
52
52
  gen.send :set_glyph_info
53
53
  data = manifest.instance_variable_get(:@data)
54
- data[:glyphs][:C].should include(:codepoint => 61696)
55
- data[:glyphs][:D].should include(:codepoint => 61697)
56
- data[:glyphs][:"a_R3ally-eXotic-f1Le-Name"].should include(:codepoint => 61698)
54
+ expect(data[:glyphs][:C]).to include(:codepoint => 61696)
55
+ expect(data[:glyphs][:D]).to include(:codepoint => 61697)
56
+ expect(data[:glyphs][:"a_R3ally-eXotic-f1Le-Name"]).to include(:codepoint => 61698)
57
57
  end
58
58
 
59
59
  it "should not change codepoints of existing glyphs" do
@@ -64,9 +64,9 @@ describe Fontcustom::Generator::Font do
64
64
 
65
65
  gen.send :set_glyph_info
66
66
  data = manifest.instance_variable_get(:@data)
67
- data[:glyphs][:C].should include(:codepoint => 61699)
68
- data[:glyphs][:D].should include(:codepoint => 61700)
69
- data[:glyphs][:"a_R3ally-eXotic-f1Le-Name"].should include(:codepoint => 61701)
67
+ expect(data[:glyphs][:C]).to include(:codepoint => 61699)
68
+ expect(data[:glyphs][:D]).to include(:codepoint => 61700)
69
+ expect(data[:glyphs][:"a_R3ally-eXotic-f1Le-Name"]).to include(:codepoint => 61701)
70
70
  end
71
71
  end
72
72
  end
@@ -15,7 +15,7 @@ describe Fontcustom::Generator::Template do
15
15
  Fontcustom::Generator::Template.new(manifest).generate
16
16
 
17
17
  content = File.read manifest
18
- content.should match(/fontcustom\/fontcustom-preview.html/)
18
+ expect(content).to match(/fontcustom\/fontcustom-preview.html/)
19
19
  end
20
20
  end
21
21
  end
@@ -27,9 +27,9 @@ describe Fontcustom::Generator::Template do
27
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("../fonts")
31
- gen.instance_variable_get(:@font_path_alt).should match("../fonts")
32
- gen.instance_variable_get(:@font_path_preview).should match(".")
30
+ expect(gen.instance_variable_get(:@font_path)).to match("../fonts")
31
+ expect(gen.instance_variable_get(:@font_path_alt)).to match("../fonts")
32
+ expect(gen.instance_variable_get(:@font_path_preview)).to match(".")
33
33
  end
34
34
 
35
35
  it "should assign @font_path_alt if :preprocessor_path is set" do
@@ -39,7 +39,7 @@ describe Fontcustom::Generator::Template do
39
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
- gen.instance_variable_get(:@font_path_alt).should match("fonts/fontcustom")
42
+ expect(gen.instance_variable_get(:@font_path_alt)).to match("fonts/fontcustom")
43
43
  end
44
44
 
45
45
  it "should assign @font_path_alt as bare font name if :preprocessor_path is false" do
@@ -49,7 +49,7 @@ describe Fontcustom::Generator::Template do
49
49
  options[:output] = {:fonts => fixture("sandbox/test/fonts"), :css => fixture("sandbox/test/css"), :preview => fixture("sandbox/test")}
50
50
 
51
51
  gen.send :set_relative_paths
52
- gen.instance_variable_get(:@font_path_alt).should_not match("../fonts")
52
+ expect(gen.instance_variable_get(:@font_path_alt)).to_not match("../fonts")
53
53
  end
54
54
 
55
55
  it "should assign '.' when paths are the same" do
@@ -58,7 +58,31 @@ describe Fontcustom::Generator::Template do
58
58
  options[:output] = {:fonts => fixture("sandbox/test/fonts"), :css => fixture("sandbox/test/fonts"), :preview => fixture("sandbox/test/fonts")}
59
59
 
60
60
  gen.send :set_relative_paths
61
- gen.instance_variable_get(:@font_path).should match("./")
61
+ expect(gen.instance_variable_get(:@font_path)).to match("./")
62
+ end
63
+ end
64
+
65
+ context ".create_files" do
66
+ it "should not include the template path in custom output file paths" do
67
+ gen = Fontcustom::Generator::Template.new fixture("generators/.fontcustom-manifest.json")
68
+
69
+ # Set options to specify a custom CSS template with a custom output location.
70
+ options = gen.instance_variable_get :@options
71
+ options[:input][:templates] = fixture("shared/templates")
72
+ options[:templates] = ['custom.css']
73
+ options[:output][:'custom.css'] = fixture("sandbox/test")
74
+
75
+ # Don't update the manifest based on these options.
76
+ manifest = gen.instance_variable_get :@manifest
77
+ expect(manifest).to receive(:set)
78
+
79
+ # Confirm that the output file doesn't include the template path.
80
+ expect(gen).to receive(:template).once do |source, target|
81
+ expect(source).to match("shared/templates")
82
+ expect(target).to_not match("shared/templates")
83
+ end
84
+
85
+ gen.send :create_files
62
86
  end
63
87
  end
64
88
  end
@@ -10,7 +10,7 @@ describe Fontcustom::Manifest do
10
10
  Fontcustom::Manifest.new manifest, options
11
11
  end
12
12
  content = File.read File.join(testdir, ".fontcustom-manifest.json")
13
- content.should match(/"options":.+"input":/m)
13
+ expect(content).to match(/"options":.+"input":/m)
14
14
  end
15
15
  end
16
16
  end
@@ -8,8 +8,8 @@ describe Fontcustom::Options do
8
8
  end
9
9
 
10
10
  before(:each) do
11
- Fontcustom::Options.any_instance.stub :say_message
12
- Fontcustom::Options.any_instance.stub :parse_options
11
+ allow_any_instance_of(Fontcustom::Options).to receive(:say_message)
12
+ allow_any_instance_of(Fontcustom::Options).to receive(:parse_options)
13
13
  end
14
14
 
15
15
  context ".overwrite_examples" do
@@ -18,7 +18,7 @@ describe Fontcustom::Options do
18
18
  o.send :overwrite_examples
19
19
  cli = o.instance_variable_get(:@cli_options)
20
20
  Fontcustom::EXAMPLE_OPTIONS.keys.each do |key|
21
- cli[key].should == Fontcustom::DEFAULT_OPTIONS[key]
21
+ expect(cli[key]).to eq(Fontcustom::DEFAULT_OPTIONS[key])
22
22
  end
23
23
  end
24
24
  end
@@ -28,13 +28,13 @@ describe Fontcustom::Options do
28
28
  it "should use options[:config] if it's a file" do
29
29
  o = options :config => "options/any-file-name.yml"
30
30
  o.send :set_config_path
31
- o.instance_variable_get(:@cli_options)[:config].should == "options/any-file-name.yml"
31
+ expect(o.instance_variable_get(:@cli_options)[:config]).to eq("options/any-file-name.yml")
32
32
  end
33
33
 
34
34
  it "should search for fontcustom.yml if options[:config] is a dir" do
35
35
  o = options :config => "options/config-is-in-dir"
36
36
  o.send :set_config_path
37
- o.instance_variable_get(:@cli_options)[:config].should == "options/config-is-in-dir/fontcustom.yml"
37
+ expect(o.instance_variable_get(:@cli_options)[:config]).to eq("options/config-is-in-dir/fontcustom.yml")
38
38
  end
39
39
 
40
40
  it "should raise error if :config doesn't exist" do
@@ -48,7 +48,7 @@ describe Fontcustom::Options do
48
48
  FileUtils.cd fixture("options") do
49
49
  o = options
50
50
  o.send :set_config_path
51
- o.instance_variable_get(:@cli_options)[:config].should == "fontcustom.yml"
51
+ expect(o.instance_variable_get(:@cli_options)[:config]).to eq("fontcustom.yml")
52
52
  end
53
53
  end
54
54
 
@@ -56,14 +56,14 @@ describe Fontcustom::Options do
56
56
  FileUtils.cd fixture("options/rails-like") do
57
57
  o = options
58
58
  o.send :set_config_path
59
- o.instance_variable_get(:@cli_options)[:config].should == "config/fontcustom.yml"
59
+ expect(o.instance_variable_get(:@cli_options)[:config]).to eq("config/fontcustom.yml")
60
60
  end
61
61
  end
62
62
 
63
63
  it "should be false if nothing is found" do
64
64
  o = options :manifest => "options/no-config-here/.fontcustom-manifest.json"
65
65
  o.send :set_config_path
66
- o.instance_variable_get(:@cli_options)[:config].should == false
66
+ expect(o.instance_variable_get(:@cli_options)[:config]).to eq(false)
67
67
  end
68
68
  end
69
69
  end
@@ -72,7 +72,7 @@ describe Fontcustom::Options do
72
72
  it "should warn if fontcustom.yml is blank" do
73
73
  o = options
74
74
  o.instance_variable_set :@cli_options, {:config => fixture("options/fontcustom-empty.yml")}
75
- o.should_receive(:say_message).with :warn, /was empty/
75
+ expect(o).to receive(:say_message).with :warn, /was empty/
76
76
  o.send :load_config
77
77
  end
78
78
 
@@ -86,7 +86,7 @@ describe Fontcustom::Options do
86
86
  o = options
87
87
  o.instance_variable_set :@cli_options, {:config => false}
88
88
  o.send :load_config
89
- o.instance_variable_get(:@config_options).should == {}
89
+ expect(o.instance_variable_get(:@config_options)).to eq({})
90
90
  end
91
91
 
92
92
  context "when :debug is true" do
@@ -96,7 +96,7 @@ describe Fontcustom::Options do
96
96
  :config => fixture("options/any-file-name.yml"),
97
97
  :debug => true
98
98
  }
99
- o.should_receive(:say_message).with :debug, /Using settings/
99
+ expect(o).to receive(:say_message).with :debug, /Using settings/
100
100
  o.send :load_config
101
101
  end
102
102
  end
@@ -107,7 +107,7 @@ describe Fontcustom::Options do
107
107
  o = options
108
108
  o.instance_variable_set :@config_options, { :input => "config" }
109
109
  o.send :merge_options
110
- o.options[:input].should == "config"
110
+ expect(o.options[:input]).to eq("config")
111
111
  end
112
112
 
113
113
  it "should overwrite config file and defaults with CLI options" do
@@ -115,8 +115,8 @@ describe Fontcustom::Options do
115
115
  o.instance_variable_set :@config_options, { :input => "config", :output => "output" }
116
116
  o.instance_variable_set :@cli_options, { :input => "cli" }
117
117
  o.send :merge_options
118
- o.options[:input].should == "cli"
119
- o.options[:output].should == "output"
118
+ expect(o.options[:input]).to eq("cli")
119
+ expect(o.options[:output]).to eq("output")
120
120
  end
121
121
  end
122
122
 
@@ -125,7 +125,7 @@ describe Fontcustom::Options do
125
125
  o = options
126
126
  o.instance_variable_set :@options, { :font_name => " A_stR4nG3 nAm3 Ø& " }
127
127
  o.send :clean_font_name
128
- o.options[:font_name].should == "A_stR4nG3--nAm3---"
128
+ expect(o.options[:font_name]).to eq("A_stR4nG3--nAm3---")
129
129
  end
130
130
  end
131
131
 
@@ -144,7 +144,7 @@ describe Fontcustom::Options do
144
144
  o = options
145
145
  o.instance_variable_set :@options, { :input => { :vectors => "vectors" } }
146
146
  o.send :set_input_paths
147
- o.options[:input][:templates].should == "vectors"
147
+ expect(o.options[:input][:templates]).to eq("vectors")
148
148
  end
149
149
  end
150
150
 
@@ -153,7 +153,7 @@ describe Fontcustom::Options do
153
153
  o = options
154
154
  o.instance_variable_set :@options, { :input => { :vectors => "vectors", :templates => "templates" } }
155
155
  o.send :set_input_paths
156
- o.options[:input][:templates].should == "templates"
156
+ expect(o.options[:input][:templates]).to eq("templates")
157
157
  end
158
158
  end
159
159
 
@@ -183,8 +183,8 @@ describe Fontcustom::Options do
183
183
  o = options
184
184
  o.instance_variable_set :@options, { :input => "vectors" }
185
185
  o.send :set_input_paths
186
- o.options[:input].should have_key(:vectors)
187
- o.options[:input].should have_key(:templates)
186
+ expect(o.options[:input]).to have_key(:vectors)
187
+ expect(o.options[:input]).to have_key(:templates)
188
188
  end
189
189
  end
190
190
 
@@ -193,7 +193,7 @@ describe Fontcustom::Options do
193
193
  o = options
194
194
  o.instance_variable_set :@options, { :input => "vectors" }
195
195
  o.send :set_input_paths
196
- o.options[:input][:templates].should == "vectors"
196
+ expect(o.options[:input][:templates]).to eq("vectors")
197
197
  end
198
198
  end
199
199
 
@@ -219,7 +219,7 @@ describe Fontcustom::Options do
219
219
  :debug => true,
220
220
  :font_name => "Test-Font"
221
221
  }
222
- o.should_receive(:say_message).with :debug, /Test-Font/
222
+ expect(o).to receive(:say_message).with :debug, /Test-Font/
223
223
  o.send :set_output_paths
224
224
  end
225
225
  end
@@ -230,8 +230,8 @@ describe Fontcustom::Options do
230
230
  o = options
231
231
  o.instance_variable_set :@options, { :output => { :fonts => "output/fonts" } }
232
232
  o.send :set_output_paths
233
- o.options[:output][:css].should == "output/fonts"
234
- o.options[:output][:preview].should == "output/fonts"
233
+ expect(o.options[:output][:css]).to eq("output/fonts")
234
+ expect(o.options[:output][:preview]).to eq("output/fonts")
235
235
  end
236
236
 
237
237
  it "should preserve :css and :preview if they do exist" do
@@ -244,8 +244,8 @@ describe Fontcustom::Options do
244
244
  }
245
245
  }
246
246
  o.send :set_output_paths
247
- o.options[:output][:css].should == "output/styles"
248
- o.options[:output][:preview].should == "output/preview"
247
+ expect(o.options[:output][:css]).to eq("output/styles")
248
+ expect(o.options[:output][:preview]).to eq("output/preview")
249
249
  end
250
250
 
251
251
  it "should create additional paths if they are given" do
@@ -257,7 +257,7 @@ describe Fontcustom::Options do
257
257
  }
258
258
  }
259
259
  o.send :set_output_paths
260
- o.options[:output][:"special.js"].should == "assets/javascripts"
260
+ expect(o.options[:output][:"special.js"]).to eq("assets/javascripts")
261
261
  end
262
262
 
263
263
  it "should raise an error if :fonts isn't set" do
@@ -275,18 +275,18 @@ describe Fontcustom::Options do
275
275
  o = options
276
276
  o.instance_variable_set :@options, { :output => "output/fonts" }
277
277
  o.send :set_output_paths
278
- o.options[:output].should be_a(Hash)
279
- o.options[:output].should have_key(:fonts)
280
- o.options[:output].should have_key(:css)
281
- o.options[:output].should have_key(:preview)
278
+ expect(o.options[:output]).to be_a(Hash)
279
+ expect(o.options[:output]).to have_key(:fonts)
280
+ expect(o.options[:output]).to have_key(:css)
281
+ expect(o.options[:output]).to have_key(:preview)
282
282
  end
283
283
 
284
284
  it "should set :css and :preview to match :fonts" do
285
285
  o = options
286
286
  o.instance_variable_set :@options, { :output => "output/fonts" }
287
287
  o.send :set_output_paths
288
- o.options[:output][:css].should == "output/fonts"
289
- o.options[:output][:preview].should == "output/fonts"
288
+ expect(o.options[:output][:css]).to eq("output/fonts")
289
+ expect(o.options[:output][:preview]).to eq("output/fonts")
290
290
  end
291
291
 
292
292
  it "should raise an error if :fonts exists but isn't a directory" do
@@ -14,7 +14,7 @@ describe Fontcustom::Utility do
14
14
  it "should include Thor::Action methods" do
15
15
  gen = Generator.new
16
16
  %w|template add_file remove_file|.each do |method|
17
- gen.should respond_to(method.to_sym)
17
+ expect(gen).to respond_to(method.to_sym)
18
18
  end
19
19
  end
20
20
 
@@ -22,7 +22,7 @@ describe Fontcustom::Utility do
22
22
  it "should turn string keys into symbols" do
23
23
  gen = Generator.new
24
24
  hash = gen.symbolize_hash "foo" => "bar"
25
- hash.should == { :foo => "bar" }
25
+ expect(hash).to eq({ :foo => "bar" })
26
26
  end
27
27
  end
28
28
 
@@ -30,14 +30,14 @@ describe Fontcustom::Utility do
30
30
  it "should define getter method" do
31
31
  gen = Generator.new
32
32
  hash = gen.methodize_hash :foo => "bar"
33
- hash.foo.should == "bar"
33
+ expect(hash.foo).to eq("bar")
34
34
  end
35
35
 
36
36
  it "should define setter method" do
37
37
  gen = Generator.new
38
38
  hash = gen.methodize_hash :foo => "bar"
39
39
  hash.foo = "baz"
40
- hash.foo.should == "baz"
40
+ expect(hash.foo).to eq("baz")
41
41
  end
42
42
  end
43
43
 
@@ -45,8 +45,8 @@ describe Fontcustom::Utility do
45
45
  it "should replace the contents of a file" do
46
46
  gen = Generator.new
47
47
  file = double "file"
48
- File.should_receive(:open).with(fixture("shared/test"), "w").and_yield file
49
- file.should_receive(:write).with("testing")
48
+ expect(File).to receive(:open).with(fixture("shared/test"), "w").and_yield file
49
+ expect(file).to receive(:write).with("testing")
50
50
  gen.write_file fixture("shared/test"), "testing"
51
51
  end
52
52
  end
@@ -9,8 +9,8 @@ describe Fontcustom::Watcher do
9
9
  #end
10
10
 
11
11
  def watcher(options)
12
- Fontcustom::Manifest.any_instance.stub :write_file
13
- Fontcustom::Base.any_instance.stub :compile
12
+ allow_any_instance_of(Fontcustom::Manifest).to receive(:write_file)
13
+ allow_any_instance_of(Fontcustom::Base).to receive(:compile)
14
14
 
15
15
  # undocumented — non-blocking use of watcher for testing
16
16
  Fontcustom::Watcher.new options, true
@@ -18,7 +18,7 @@ describe Fontcustom::Watcher do
18
18
 
19
19
  context "#watch" do
20
20
  it "should compile on init" do
21
- Fontcustom::Base.any_instance.should_receive(:compile).once
21
+ expect_any_instance_of(Fontcustom::Base).to receive(:compile).once
22
22
 
23
23
  w = watcher(
24
24
  :input => "shared/vectors",
@@ -33,7 +33,7 @@ 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::Base.any_instance.should_not_receive(:compile)
36
+ expect_any_instance_of(Fontcustom::Base).to_not receive(:compile).once
37
37
 
38
38
  w = watcher(
39
39
  :input => "shared/vectors",
@@ -48,7 +48,7 @@ describe Fontcustom::Watcher do
48
48
  end
49
49
 
50
50
  it "should call generators when vectors change" do
51
- Fontcustom::Base.any_instance.should_receive(:compile).once
51
+ expect_any_instance_of(Fontcustom::Base).to receive(:compile).once
52
52
 
53
53
  w = watcher(
54
54
  :input => "shared/vectors",
@@ -70,13 +70,13 @@ describe Fontcustom::Watcher do
70
70
  end
71
71
 
72
72
  it "should call generators when custom templates change" do
73
- Fontcustom::Base.any_instance.should_receive(:compile).once
73
+ expect_any_instance_of(Fontcustom::Base).to receive(:compile).once
74
74
 
75
75
  w = watcher(
76
76
  :input => {:vectors => "shared/vectors", :templates => "shared/templates"},
77
77
  :templates => %w|css preview custom.css|,
78
78
  :output => "output",
79
- :skip_first => true
79
+ :skip_first => false
80
80
  )
81
81
 
82
82
  capture(:stdout) do
@@ -86,6 +86,7 @@ describe Fontcustom::Watcher do
86
86
  new = content + "\n.bar { color: red; }"
87
87
 
88
88
  w.watch
89
+ sleep 1
89
90
  File.open(template, "w") { |file| file.write(new) }
90
91
  sleep 1
91
92
  ensure
@@ -97,7 +98,7 @@ describe Fontcustom::Watcher do
97
98
  end
98
99
 
99
100
  it "should do nothing when non-vectors change" do
100
- Fontcustom::Base.any_instance.should_not_receive(:compile)
101
+ expect_any_instance_of(Fontcustom::Base).to_not receive(:compile).once
101
102
 
102
103
  w = watcher(
103
104
  :input => "shared/vectors",
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.3
4
+ version: 1.3.4
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: 2014-02-20 00:00:00.000000000 Z
12
+ date: 2014-10-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
@@ -43,56 +43,62 @@ dependencies:
43
43
  name: listen
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - ~>
46
+ - - ! '>='
47
47
  - !ruby/object:Gem::Version
48
48
  version: '1.0'
49
+ - - <
50
+ - !ruby/object:Gem::Version
51
+ version: '3.0'
49
52
  type: :runtime
50
53
  prerelease: false
51
54
  version_requirements: !ruby/object:Gem::Requirement
52
55
  requirements:
53
- - - ~>
56
+ - - ! '>='
54
57
  - !ruby/object:Gem::Version
55
58
  version: '1.0'
59
+ - - <
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
56
62
  - !ruby/object:Gem::Dependency
57
63
  name: rake
58
64
  requirement: !ruby/object:Gem::Requirement
59
65
  requirements:
60
- - - '>='
66
+ - - ! '>='
61
67
  - !ruby/object:Gem::Version
62
68
  version: '0'
63
69
  type: :development
64
70
  prerelease: false
65
71
  version_requirements: !ruby/object:Gem::Requirement
66
72
  requirements:
67
- - - '>='
73
+ - - ! '>='
68
74
  - !ruby/object:Gem::Version
69
75
  version: '0'
70
76
  - !ruby/object:Gem::Dependency
71
77
  name: bundler
72
78
  requirement: !ruby/object:Gem::Requirement
73
79
  requirements:
74
- - - '>='
80
+ - - ! '>='
75
81
  - !ruby/object:Gem::Version
76
82
  version: '0'
77
83
  type: :development
78
84
  prerelease: false
79
85
  version_requirements: !ruby/object:Gem::Requirement
80
86
  requirements:
81
- - - '>='
87
+ - - ! '>='
82
88
  - !ruby/object:Gem::Version
83
89
  version: '0'
84
90
  - !ruby/object:Gem::Dependency
85
91
  name: rspec
86
92
  requirement: !ruby/object:Gem::Requirement
87
93
  requirements:
88
- - - '>='
94
+ - - ! '>='
89
95
  - !ruby/object:Gem::Version
90
96
  version: '0'
91
97
  type: :development
92
98
  prerelease: false
93
99
  version_requirements: !ruby/object:Gem::Requirement
94
100
  requirements:
95
- - - '>='
101
+ - - ! '>='
96
102
  - !ruby/object:Gem::Version
97
103
  version: '0'
98
104
  description: Font Custom makes using vector icons easy. Generate icon fonts and supporting
@@ -116,6 +122,7 @@ files:
116
122
  - TODO.md
117
123
  - bin/fontcustom
118
124
  - fontcustom.gemspec
125
+ - gemfiles/Gemfile.listen_1
119
126
  - lib/fontcustom.rb
120
127
  - lib/fontcustom/base.rb
121
128
  - lib/fontcustom/cli.rb
@@ -173,24 +180,25 @@ files:
173
180
  homepage: http://fontcustom.com
174
181
  licenses: []
175
182
  metadata: {}
176
- post_install_message: '>> Thanks for installing Font Custom! Please ensure that fontforge
177
- is installed before compiling any icons. Visit <http://fontcustom.com> for instructions.'
183
+ post_install_message: ! '>> Thanks for installing Font Custom! Please ensure that
184
+ fontforge is installed before compiling any icons. Visit <http://fontcustom.com>
185
+ for instructions.'
178
186
  rdoc_options: []
179
187
  require_paths:
180
188
  - lib
181
189
  required_ruby_version: !ruby/object:Gem::Requirement
182
190
  requirements:
183
- - - '>='
191
+ - - ! '>='
184
192
  - !ruby/object:Gem::Version
185
193
  version: '0'
186
194
  required_rubygems_version: !ruby/object:Gem::Requirement
187
195
  requirements:
188
- - - '>='
196
+ - - ! '>='
189
197
  - !ruby/object:Gem::Version
190
198
  version: '0'
191
199
  requirements: []
192
200
  rubyforge_project:
193
- rubygems_version: 2.1.9
201
+ rubygems_version: 2.2.2
194
202
  signing_key:
195
203
  specification_version: 4
196
204
  summary: Generate icon fonts from the command line.