compass-fontcustom 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a503c96a46269f387121518502e538e211077cf9
4
- data.tar.gz: 76eec2fa2928c3da1f65dd2de53d962be18bef04
3
+ metadata.gz: 09fd173b97e0decca5edd88875fa5933a0563fbf
4
+ data.tar.gz: 5aa0dd9935ab4fc1d858ffa79f6069243230addf
5
5
  SHA512:
6
- metadata.gz: a9a72d46c048d49a2367d352681216441043028770279f571f9c25034ba26cda5fefc60003c6b18eabbdc853033da4a1ee12fb03161d3f81052124fd3e6185d0
7
- data.tar.gz: 6a509cec8776ce4592be0832c39c84a0ceba91a6e0b3ab9c7c98f4c5b6165da2169ebdee3e43ef00c5668c89fac15537c2eadd67600eaddbda90eabf3791c8aa
6
+ metadata.gz: 5927c5e83d08a64cb9c374174a03700b18a9546a1798e84377515d0cf9b6f3ee72f26ac0ab2691b8d2658afeff14d73772a3a41f94c609a0a2af33a70819b872
7
+ data.tar.gz: 6dbb765920258fafc1bcb9e804e2f7e3a383577cf2cc4d1fb09f7fc89a4f72293de09563e243ce7edb777cbbd7d417e3662f22e6fe7e1a6c1205e2c79e633c2d
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ **1.1.0** Minor release
4
+
5
+ - Bundles Fontcustom 1.1.0
6
+ - Adds proper support for Rails' asset pipeline. Should work with Rails >= 3.1, tested with 4.0.
7
+ - Changes/fixes behavior of naming CSS classes: Special characters, other than a-z and 0-9, are now being stripped when generating class names from glyph file names to prevent CSS from throwing up:
8
+
9
+ File name `google+.svg` becomes class name `.icon-yourfont-google` -- without the `+` sign.
10
+
3
11
  **1.0.0** Feature release
4
12
 
5
13
  - Adding mixin for generating custom glyph classes
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.required_ruby_version = '>= 1.9.3'
22
22
 
23
23
  spec.add_dependency "compass"
24
- spec.add_dependency "fontcustom", "~> 1.0.0"
24
+ spec.add_dependency "fontcustom", "~> 1.1.0"
25
25
 
26
26
  spec.add_development_dependency "bundler", "~> 1.3"
27
27
  spec.add_development_dependency "rake"
@@ -17,4 +17,6 @@ module Compass
17
17
 
18
18
  Sass.load_paths << FontImporter.new
19
19
  end
20
- end
20
+ end
21
+
22
+ require "compass/fontcustom/rails" if defined?(Rails)
@@ -54,18 +54,22 @@ module Compass
54
54
  path
55
55
  end
56
56
 
57
+ def search_paths
58
+ [Compass.configuration.images_path.to_s]
59
+ end
60
+
57
61
  # Returns all glyph names inside the folder at `uri`.
58
62
  # @param uri [String] the uri to glob files from
59
63
  # @return [Array]
60
64
  def glyph_names(uri)
61
- folder = Compass.configuration.images_path.to_s
62
- files = Dir[File.join(folder, uri)]
65
+ files = []
66
+ search_paths.each { |p| files.concat Dir[File.join(p, uri)] }
63
67
 
64
68
  if files.empty?
65
69
  raise Compass::SpriteException, %Q{No glyph images were found matching "#{uri}" in the images path. Your current images path is: #{folder}}
66
70
  end
67
71
 
68
- files.map { |f| File.basename(f)[0..-5].gsub(' ', '-') }
72
+ files.map { |f| File.basename(f)[0..-5].gsub(/[^0-9A-Za-z]/, '') }
69
73
  end
70
74
 
71
75
  # Returns `Sass::Engine` options with defaults
@@ -114,9 +118,9 @@ module Compass
114
118
  # @param uri [String] the uri to glob files from
115
119
  # @return [Array]
116
120
  def files(uri)
117
- folder = Compass.configuration.images_path.to_s
118
- files = Dir[File.join(folder, uri)]
119
- files
121
+ [].tap do |files|
122
+ search_paths.each { |p| files.concat Dir[File.join p, uri] }
123
+ end
120
124
  end
121
125
 
122
126
  end # end class methods
@@ -1,4 +1,4 @@
1
- require 'fontcustom/generator/font'
1
+ require 'fontcustom'
2
2
  require 'compass/fontcustom/configurable'
3
3
 
4
4
  module Compass
@@ -11,10 +11,19 @@ module Compass
11
11
  # @param context [Object] usually an instance of FontImporter
12
12
  def self.from_uri(uri, context)
13
13
  path, name = FontImporter.path_and_name uri
14
- glyphs = FontImporter.files(uri).sort.map { |file| File.basename(file)[0..-5] }
14
+ glyphs = FontImporter.files(uri).sort
15
+
16
+ # TODO: improve extraction of aboslute path
17
+ path = File.dirname glyphs.first
18
+ glyphs.map! { |file| File.basename(file)[0..-5].gsub(/[^0-9A-Za-z]/, '') }
19
+
15
20
  new glyphs, path, name, context
16
21
  end
17
22
 
23
+ # @param glyphs [Array] all the glyphs found at path
24
+ # @param path [String] the absolute path where glyphs are stored
25
+ # @param name [String] the name of the glyph font
26
+ # @param context [Object] the invoking object
18
27
  def initialize(glyphs, path, name, context)
19
28
  raise StandardError, "No glyphs found at '#{path}'" if glyphs.empty?
20
29
  @glyphs = glyphs
@@ -32,13 +41,13 @@ module Compass
32
41
  unless exists?
33
42
  args = self.class.config.generator_options || {}
34
43
  args.merge!(
35
- :input => File.join(Compass.configuration.images_path.to_s, self.path),
44
+ :input => path,
36
45
  :output => output_dir,
37
46
  :font_name => @name,
38
- :file_hash => Compass.configuration.fontcustom_hash,
39
- :verbose => false
47
+ :no_hash => !Compass.configuration.fontcustom_hash,
48
+ :quiet => true
40
49
  )
41
- ::Fontcustom::Generator::Font.start [args]
50
+ ::Fontcustom::Generator::Font.start [::Fontcustom::Options.new(args)]
42
51
  end
43
52
  end
44
53
 
@@ -0,0 +1,11 @@
1
+ module Compass
2
+ module Fontcustom
3
+
4
+ class FontImporter
5
+ def self.search_paths
6
+ Rails.application.config.assets.paths
7
+ end
8
+ end
9
+
10
+ end
11
+ end
@@ -10,11 +10,11 @@ $<%= name %>-glyphs: glyph-map("<%= uri %>");
10
10
 
11
11
  @mixin all-<%= name %>-glyphs {
12
12
  @include fontcustom-font-face($<%= name %>-glyphs);
13
- @include glyphs($<%= name %>-glyphs, <%= glyph_names.join " " %>, $<%= name %>-font-base-class)
13
+ @include glyphs($<%= name %>-glyphs, <%= glyph_names.map{ |g| "'#{g}'" }.join " " %>, $<%= name %>-font-base-class)
14
14
  }
15
15
 
16
16
  @mixin <%= name %>-glyph($glyph-name) {
17
17
  @extend #{$<%= name %>-font-base-class};
18
- $index: index(<%= glyph_names.join " " %>, $glyph-name);
18
+ $index: index(<%= glyph_names.map{ |g| "'#{g}'" }.join " " %>, $glyph-name);
19
19
  &:before { content: glyph($index); }
20
20
  }
@@ -1,5 +1,5 @@
1
1
  module Compass
2
2
  module Fontcustom
3
- VERSION = "1.0.0"
3
+ VERSION = "1.1.0"
4
4
  end
5
5
  end
@@ -0,0 +1,21 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
+ <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
5
+ width="415px" height="415px" viewBox="0 0 415 415" enable-background="new 0 0 415 415" xml:space="preserve">
6
+ <g>
7
+ <polygon points="368.346,131.916 314.569,131.916 314.569,78.139 301.125,78.139 301.125,131.916 247.348,131.916 247.348,145.36
8
+ 301.125,145.36 301.125,199.137 314.569,199.137 314.569,145.36 368.346,145.36 "/>
9
+ <path d="M188.43,232.613c-7.512-5.317-21.877-18.25-21.877-25.851c0-8.908,2.543-13.298,15.951-23.774
10
+ c13.745-10.74,23.472-25.836,23.472-43.4c0-20.905-9.311-41.283-26.79-48.004h26.352l18.599-13.445c0,0-62.333,0-83.108,0
11
+ c-37.26,0-72.326,28.228-72.326,60.926c0,33.413,25.398,60.381,63.304,60.381c2.636,0,5.197-0.052,7.705-0.232
12
+ c-2.46,4.709-4.219,10.015-4.219,15.521c0,9.286,4.995,16.815,11.312,22.96c-4.771,0-9.381,0.138-14.407,0.138
13
+ c-46.15,0-81.671,29.393-81.671,59.872c0,30.017,38.94,48.795,85.092,48.795c52.613,0,81.672-29.853,81.672-59.872
14
+ C217.488,262.557,210.387,248.142,188.43,232.613L188.43,232.613z M144.031,190.975L144.031,190.975
15
+ c-21.414-0.64-41.762-23.955-45.458-52.069c-3.695-28.119,10.661-49.641,32.069-49.001c21.406,0.644,41.763,23.205,45.46,51.32
16
+ C179.796,169.344,165.436,191.614,144.031,190.975L144.031,190.975z M135.646,333.229L135.646,333.229
17
+ c-31.898,0-54.938-20.192-54.938-44.449c0-23.773,28.576-43.562,60.475-43.218c7.445,0.079,14.382,1.277,20.681,3.315
18
+ c17.315,12.042,29.737,18.847,33.241,32.57c0.66,2.784,1.018,5.646,1.018,8.57C196.123,314.273,180.493,333.229,135.646,333.229z"
19
+ />
20
+ </g>
21
+ </svg>
@@ -50,6 +50,7 @@ class FontImporterTest < Test::Unit::TestCase
50
50
  assert css =~ %r{.#{fontname}-font}, "base font class missing"
51
51
  assert css =~ %r{.icon-#{fontname}-c}i, "icon c css class missing"
52
52
  assert css =~ %r{.icon-#{fontname}-d}i, "icon d css class missing"
53
+ assert css =~ %r{.icon-#{fontname}-google}i, "icon google+ css class missing"
53
54
  end
54
55
 
55
56
  def test_should_skip_file_name_hashes_if_option_is_set
@@ -16,4 +16,10 @@ class GlyphMapTest < Test::Unit::TestCase
16
16
  assert_equal 0, @glyph_map.index_for_glyph('C')
17
17
  end
18
18
 
19
+ def test_glyph_name_normalization
20
+ glyphs = @glyph_map.instance_variable_get(:@glyphs)
21
+ assert ! glyphs.include?('google+')
22
+ assert glyphs.include?('google')
23
+ end
24
+
19
25
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: compass-fontcustom
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - glaszig
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-04 00:00:00.000000000 Z
11
+ date: 2013-09-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: compass
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - ~>
32
32
  - !ruby/object:Gem::Version
33
- version: 1.0.0
33
+ version: 1.1.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ~>
39
39
  - !ruby/object:Gem::Version
40
- version: 1.0.0
40
+ version: 1.1.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -97,6 +97,7 @@ files:
97
97
  - lib/compass/fontcustom/configurable.rb
98
98
  - lib/compass/fontcustom/font_importer.rb
99
99
  - lib/compass/fontcustom/glyph_map.rb
100
+ - lib/compass/fontcustom/rails.rb
100
101
  - lib/compass/fontcustom/sass_extensions.rb
101
102
  - lib/compass/fontcustom/templates/stylesheet.scss.erb
102
103
  - lib/compass/fontcustom/version.rb
@@ -104,6 +105,7 @@ files:
104
105
  - test/fixtures/myfont/C.svg
105
106
  - test/fixtures/myfont/D.svg
106
107
  - test/fixtures/myfont/a_R3ally-eXotic f1Le Name.svg
108
+ - test/fixtures/myfont/google+.svg
107
109
  - test/test_helper.rb
108
110
  - test/unit/font_importer_test.rb
109
111
  - test/unit/glyph_map_test.rb
@@ -135,6 +137,7 @@ test_files:
135
137
  - test/fixtures/myfont/C.svg
136
138
  - test/fixtures/myfont/D.svg
137
139
  - test/fixtures/myfont/a_R3ally-eXotic f1Le Name.svg
140
+ - test/fixtures/myfont/google+.svg
138
141
  - test/test_helper.rb
139
142
  - test/unit/font_importer_test.rb
140
143
  - test/unit/glyph_map_test.rb