graphite-sass 0.5.1 → 0.5.2

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: f83a2c263986ff2a7713352ae9ff8da343ffd401
4
- data.tar.gz: 53a308a5ba232df2e0ea833bd3ab3f6fc73e1f96
3
+ metadata.gz: 58a9a1ad71ae66275e238b9313e0d55c747b0a01
4
+ data.tar.gz: 08990247011ae05879404065d3b2942ad22fd528
5
5
  SHA512:
6
- metadata.gz: c27b66d8cb9175a74e9172cd026b7950ac1fb2e645af364b5d7e90673231c06326f6b26b7ef15600ec43080904e35186d512509ec5b73a97b00381a68dc8cbf1
7
- data.tar.gz: bda13e55849cbe21ae7fea791624266d9bd0e3ea1e53a84b33546337f4ffaad76795b5e7f998f202ff9c3489b575b4a2cfd7018c05a6a90126eb5c6f90b9edad
6
+ metadata.gz: c1eb1fb4b782bcdaeddcf421667470d20117c190dd3d7260b2d1c716d253606c53eddef793116d56eaaffe261fde018f79f7edfdfb92ea12c3d5b1e092204795
7
+ data.tar.gz: 832cd1de591aafeccec9b6688a06fe155f2397d818e1c120c141ec00920f2a2625c788ac1b0fbdfe4ed5bf223713e432e7610351c1cba8b9334e70835ab130f0
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Graphite [![Gem Version](https://badge.fury.io/rb/graphite-sass.svg)](http://badge.fury.io/rb/graphite-sass)
2
2
 
3
- Graphite allows you to import fonts into your stylesheet in a syntax similar to Google Fonts. Quick and simple.
3
+ Graphite allows you to import fonts into your stylesheet in a syntax similar to Google Fonts. Quick and simple. _Graphite is completely Ruby-based, so if you're not using a Ruby compiler (like libsass), then the plugin will not work without a Ruby wrapper._
4
4
 
5
5
  ## Requirements
6
6
 
@@ -19,18 +19,21 @@ Graphite allows you to import fonts into your stylesheet in a syntax similar to
19
19
  Each font-family should have it's own folder inside of the top-level fonts directory. The font-family directory name should match the name specified in the actual font filename.
20
20
 
21
21
  ```
22
- root
23
- ├── fonts
24
- │ ├── helvetica-neue
22
+ root/
23
+ ├── fonts/
24
+ │ ├── helvetica-neue/
25
25
  │ │ ├── helvetica-neue-400-italic.woff
26
26
  │ │ ├── helvetica-neue-400-normal.woff
27
27
  │ │ ├── helvetica-neue-700-italic.woff
28
28
  │ │ ├── helvetica-neue-700-normal.woff
29
29
  │ │ ├── ...
30
- │ ├── font-family...
31
- │ │ ├── fonts...
32
- ├── sass
30
+ │ ├── another-font-family/
31
+ │ │ ├── ...
32
+ ├── sass/
33
33
  │ ├── style.scss
34
+ ├── css/
35
+ │ ├── style.css
36
+ ...
34
37
  ```
35
38
 
36
39
  ### File naming convention
@@ -49,6 +52,8 @@ Example,
49
52
 
50
53
  ### Usage
51
54
 
55
+ Font paths are relative to your `config.rb` or your `$LOAD_PATH`, so not necessarily the Sass file you're importing from. Graphite will automatically exit your Sass directory with `../` when outputting your fonts.
56
+
52
57
  ```scss
53
58
  @import "fonts/lato?styles=200,700,200-italic,700-italic";
54
59
  @import "fonts/helvetica-neue?styles=500";
@@ -88,7 +93,7 @@ The output is similar to what Google Fonts does with their CSS. All fonts share
88
93
  font-weight: 500;
89
94
  font-style: normal;
90
95
  src: url("../fonts/helvetica-neue/helvetica-neue-500.eot");
91
- src: url("../fonts/helvetica-neue/helvetica-neue-500.eot?#iefix") format("embedded-opentype"), url("fonts/helvetica-neue/helvetica-neue-500.woff") format("woff"), url("fonts/helvetica-neue/helvetica-neue-500.ttf") format("truetype"), url("fonts/helvetica-neue/helvetica-neue-500.svg#helvetica-neue") format("svg");
96
+ src: url("../fonts/helvetica-neue/helvetica-neue-500.eot?#iefix") format("embedded-opentype"), url("../fonts/helvetica-neue/helvetica-neue-500.woff") format("woff"), url("../fonts/helvetica-neue/helvetica-neue-500.ttf") format("truetype"), url("../fonts/helvetica-neue/helvetica-neue-500.svg#helvetica-neue") format("svg");
92
97
  }
93
98
  ```
94
99
 
@@ -85,12 +85,18 @@ module Graphite
85
85
 
86
86
  # Loop over each extension
87
87
  FONT_EXTENSIONS.each do |ext|
88
+ # Build out the file path
89
+ file = "#{@font_family_path}/#{@font_family_name}-#{style}.#{ext}"
88
90
  # Check if the file exists with passed param
89
- if File.exists?("#{@font_family_path}/#{@font_family_name}-#{style}.#{ext}")
91
+ if File.exists? file
90
92
  # Save ext
91
93
  extensions << ext unless extensions.include? ext
92
- # Grab path
93
- path = "#{@font_family_path}/#{@font_family_name}-#{style}"
94
+ # Absolute path of font file
95
+ font_dir = Pathname.new(file).dirname.expand_path
96
+ # Absolute path of sass file
97
+ sass_dir = Pathname.new(base).dirname.expand_path
98
+ # Get relative path from Sass dir to font dir
99
+ path = "#{font_dir.relative_path_from(sass_dir)}/#{@font_family_name}-#{style}" if path.empty?
94
100
  end
95
101
  end
96
102
 
@@ -164,7 +170,7 @@ module Graphite
164
170
 
165
171
  # Include this for IE9
166
172
  if atts["extensions"].include? "eot"
167
- content += "\tsrc: url('../#{atts["path"]}.eot');\n"
173
+ content += "\tsrc: url('#{atts["path"]}.eot');\n"
168
174
  end
169
175
 
170
176
  # Create array of src urls
@@ -172,22 +178,22 @@ module Graphite
172
178
 
173
179
  # Push extensions to src arr if match
174
180
  if atts["extensions"].include? "eot"
175
- src << "url('../#{atts["path"]}.eot?#iefix') format('embedded-opentype')"
181
+ src << "url('#{atts["path"]}.eot?#iefix') format('embedded-opentype')"
176
182
  end
177
183
  if atts["extensions"].include? "woff2"
178
- src << "url('../#{atts["path"]}.woff2') format('woff2')"
184
+ src << "url('#{atts["path"]}.woff2') format('woff2')"
179
185
  end
180
186
  if atts["extensions"].include? "woff"
181
- src << "url('../#{atts["path"]}.woff') format('woff')"
187
+ src << "url('#{atts["path"]}.woff') format('woff')"
182
188
  end
183
189
  if atts["extensions"].include? "otf"
184
- src << "url('../#{atts["path"]}.otf') format('opentype')"
190
+ src << "url('#{atts["path"]}.otf') format('opentype')"
185
191
  end
186
192
  if atts["extensions"].include? "ttf"
187
- src << "url('../#{atts["path"]}.ttf') format('truetype')"
193
+ src << "url('#{atts["path"]}.ttf') format('truetype')"
188
194
  end
189
195
  if atts["extensions"].include? "svg"
190
- src << "url('../#{atts["path"]}.svg##{font}') format('svg')"
196
+ src << "url('#{atts["path"]}.svg##{font}') format('svg')"
191
197
  end
192
198
 
193
199
  # Join src together
@@ -1,4 +1,3 @@
1
1
  module Graphite
2
- VERSION = "0.5.1"
3
- DATE = "2014-10-07"
2
+ VERSION = "0.5.2"
4
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphite-sass
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ezekiel Gabrielse
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-07 00:00:00.000000000 Z
11
+ date: 2014-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sass