fontcustom 1.3.0.beta2 → 1.3.0.beta3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a89156ba7ef7d8a12424e06e6768e0973270b6cf
4
- data.tar.gz: 83bbb3c5f0aa93ab04b089e642f1b57e3f9bc04d
3
+ metadata.gz: a863f3b75e4669343c50c8f137aaae1c5c5df1fd
4
+ data.tar.gz: 4997708bd8b627e3ec060c32fa0c06a7a6de4835
5
5
  SHA512:
6
- metadata.gz: 576122be6d77bcdf8fc9f4b577fc124b84efabd8370121404b9f137263f1d315f69e1a48d975a90cb37a1bb2be19af0655250ced8fb52d14d9f38c303f531c36
7
- data.tar.gz: d1f6317e39596082c8c9ffe884f227a62867590140eb548cade80bf3f50d4dcd966296a29a4a62bd0ef7c0fa3a10a9ffe310ee9199a20020abb13e03f85dace1
6
+ metadata.gz: 3743b80862699178d2c6754a198af545c38358db18563d3ffe5110b777c7350e47a1e505720e14a8620b1ae03f048e34dc091ad60ec15f224b934b56ef2368f6
7
+ data.tar.gz: 8f977e595ebf6232b06d7e69b2aead55be38727c104092340fcf20617b3b691d1f6bdf6a31d6c3a1c37a6c3080467eceb4e2f7524509c5c35a4c9d3ba643950e
data/README.md CHANGED
@@ -42,31 +42,22 @@ fontcustom help # See all options
42
42
  ### Configuration
43
43
 
44
44
  To preserve options between compiles, create a configuration file with
45
- `fontcustom config`. This should live in the directory where you plan on
46
- running `fontcustom` commands. Most of the following can also be used as
47
- command line flags (`--css-selector`, etc.).
45
+ `fontcustom config`. This should live in the directory where you run
46
+ all `fontcustom` commands. Each of the following has its own command
47
+ line flag (`--css-selector`, etc.). Defaults values are shown.
48
+
49
+ **Basics**
48
50
 
49
51
  ```yml
50
- # (defaults shown)
51
- font_name: fontcustom # Names the font and sets the name and directory
52
- # of generated files
53
52
  project_root: (pwd) # Context for all relative paths
54
53
  input: (project_root) # Where vectors and templates are located
55
54
  output: (project_root)/(font name) # Where generated files will be saved
56
55
  config: (pwd)/fontcustom.yml # Optional path to a configuration file
57
- templates: [ css, preview ] # Templates to generate alongside fonts
58
- # Possible values: preview, css, scss, scss-rails
59
- css_selector: .icon-{{glyph}} # Template for CSS classes
60
- 6
61
- preprocessor_path: "" # Font path used in proprocessor templates (Sass, etc.)
62
- no_hash: false # Don't add asset-busting hashes to font files
63
- autowidth: false # Automatically size glyphs based on the width of
64
- # their individual vectors
65
56
  debug: false # Output raw messages from fontforge
66
57
  quiet: false # Silence all messages except errors
67
58
 
68
- # For more control over file locations,
69
- # set input and output as Yaml hashes
59
+ # For more control over file locations, set
60
+ # input and output as hashes instead of strings
70
61
  input:
71
62
  vectors: path/to/vectors # required
72
63
  templates: path/to/templates
@@ -75,9 +66,39 @@ output:
75
66
  fonts: app/assets/fonts # required
76
67
  css: app/assets/stylesheets
77
68
  preview: app/views/styleguide
78
- 6
79
69
  ```
80
70
 
71
+ **Fonts**
72
+
73
+ ```yml
74
+ font_name: fontcustom # Also sets the default output directory and
75
+ # the name of generated stock templates
76
+ no_hash: false # Don't add asset-busting hashes to font files
77
+ autowidth: false # Automatically size glyphs based on the width of
78
+ # their individual vectors
79
+ ```
80
+
81
+ **Templates**
82
+
83
+ ```yml
84
+ templates: [ css, preview ] # List of templates to generate alongside fonts
85
+ # Possible values: preview, css, scss, scss-rails
86
+ css_selector: .icon-{{glyph}} # CSS selector format (`{{glyph}}` is replaced)
87
+ preprocessor_path: "" # Font path used in CSS proprocessor templates
88
+
89
+ # Custom templates should live in the `input`
90
+ # or `input[:templates]` directory and be added
91
+ # to `templates` as their basename:
92
+ templates: [ preview, VectorIcons.less ]
93
+ ```
94
+
95
+ Custom templates have access to `@options`, `@manifest`, and the following ERB helpers:
96
+
97
+ * `font_name`
98
+ * `font_face`: FontSpring's [Bulletproof @font-face syntax](http://www.fontspring.com/blog/further-hardening-of-the-bulletproof-syntax)
99
+ * `glyph_selectors`: comma-separated list of all selectors
100
+ * `glyphs`: all selectors and their codepoint assignments (`.icon-example:before { content: "\f103"; }`)
101
+
81
102
  ### SVG Guidelines
82
103
 
83
104
  * All colors will be rendered identically — including white fills.
data/TODO.md CHANGED
@@ -2,11 +2,10 @@
2
2
 
3
3
  ### 1.3.0
4
4
 
5
- * tests, error messages, and docs for template generator
6
5
  * store relative paths in manifest (rebuild in generator/util)
7
6
 
7
+ * reactivate watcher
8
8
  * Detect old manifest / show error message
9
- * In template/fontcustom.yml, clarify that input/output can be hashes
10
9
 
11
10
  * Add more travis CLI rubies / thor versions?
12
11
  * documentation for template helpers
@@ -49,6 +49,9 @@ module Fontcustom
49
49
  name = File.basename file, ".svg"
50
50
  name = name.strip.gsub(/\W/, "-")
51
51
  glyphs[name.to_sym] = { :source => file }
52
+ if File.read(file).include? "rgba"
53
+ say_message :warn, "`#{relative_path(file)}` contains transparency and will be skipped."
54
+ end
52
55
  end
53
56
 
54
57
  # Dir.glob returns a different order depending on ruby
@@ -73,13 +76,10 @@ module Fontcustom
73
76
  stdout = stdout.split("\n")
74
77
  stdout = stdout[1..-1] if stdout[0] == "CreateAllPyModules()"
75
78
 
76
- if stderr.include? "Failed to parse color rgba("
77
- say_message :warn, "Transparent glyphs are not supported. Check your SVGs."
78
- end
79
-
80
79
  debug_msg = " Try again with --debug for more details."
81
80
  if @options[:debug]
82
- say_message :debug, "#{stderr}\n#{' ' * 14}#{stdout}"
81
+ messages = stderr.split("\n") + stdout
82
+ say_message :debug, messages.join(line_break)
83
83
  debug_msg = ""
84
84
  end
85
85
 
@@ -42,30 +42,14 @@ module Fontcustom
42
42
  def create_files
43
43
  @glyphs = @manifest[:glyphs]
44
44
  created = []
45
- packaged = %w|fontcustom-bootstrap-ie7.css fontcustom.css _fontcustom-bootstrap-ie7.scss _fontcustom-rails.scss
46
- fontcustom-bootstrap.css fontcustom-preview.html _fontcustom-bootstrap.scss _fontcustom.scss|
47
- css_exts = %w|.css .scss .sass .less .stylus|
48
45
  begin
49
46
  @options[:templates].each do |source|
50
- name = File.basename source
51
- ext = File.extname source
52
- target = name.dup
53
-
54
- if packaged.include?(name) && @options[:font_name] != DEFAULT_OPTIONS[:font_name]
55
- target.sub! DEFAULT_OPTIONS[:font_name], @options[:font_name]
56
- end
57
-
58
- target = if @options[:output].keys.include? name.to_sym
59
- File.join @options[:output][name.to_sym], target
60
- elsif css_exts.include? ext
61
- File.join @options[:output][:css], target
62
- elsif name == "fontcustom-preview.html"
63
- File.join @options[:output][:preview], target
64
- else
65
- File.join @options[:output][:fonts], target
47
+ begin
48
+ target = template_target source
49
+ template source, target, :verbose => false, :force => true
50
+ rescue => e
51
+ raise Fontcustom::Error, "Could not generate template `#{relative_path(source)}`:#{line_break + e.message}"
66
52
  end
67
-
68
- template source, target, :verbose => false, :force => true
69
53
  created << target
70
54
  end
71
55
  ensure
@@ -75,6 +59,28 @@ module Fontcustom
75
59
  end
76
60
  end
77
61
 
62
+ def template_target(source)
63
+ packaged = %w|fontcustom.css _fontcustom.scss _fontcustom-rails.scss fontcustom-preview.html|
64
+ css_exts = %w|.css .scss .sass .less .stylus|
65
+ name = File.basename source
66
+ ext = File.extname source
67
+ target = name.dup
68
+
69
+ if packaged.include?(name) && @options[:font_name] != DEFAULT_OPTIONS[:font_name]
70
+ target.sub! DEFAULT_OPTIONS[:font_name], @options[:font_name]
71
+ end
72
+
73
+ if @options[:output].keys.include? name.to_sym
74
+ File.join @options[:output][name.to_sym], target
75
+ elsif css_exts.include? ext
76
+ File.join @options[:output][:css], target
77
+ elsif name == "fontcustom-preview.html"
78
+ File.join @options[:output][:preview], target
79
+ else
80
+ File.join @options[:output][:fonts], target
81
+ end
82
+ end
83
+
78
84
  #
79
85
  # Template Helpers
80
86
  #
@@ -50,7 +50,7 @@ module Fontcustom
50
50
  File.join path, "fontcustom.yml"
51
51
 
52
52
  else
53
- raise Fontcustom::Error, "No configuration file found at `#{relative_to_root(path)}`."
53
+ raise Fontcustom::Error, "No configuration file found at `#{relative_path(path)}`."
54
54
  end
55
55
  else
56
56
  # fontcustom.yml is in the project_root
@@ -70,16 +70,16 @@ module Fontcustom
70
70
  def load_config
71
71
  @config_options = {}
72
72
  if @cli_options[:config]
73
- say_message :debug, "Using settings from `#{relative_to_root(@cli_options[:config])}`." if @cli_options[:debug]
73
+ say_message :debug, "Using settings from `#{relative_path(@cli_options[:config])}`." if @cli_options[:debug]
74
74
  begin
75
75
  config = YAML.load File.open(@cli_options[:config])
76
76
  if config # empty YAML returns false
77
77
  @config_options = symbolize_hash(config)
78
78
  else
79
- say_message :warn, "`#{relative_to_root(@cli_options[:config])}` was empty. Using defaults."
79
+ say_message :warn, "`#{relative_path(@cli_options[:config])}` was empty. Using defaults."
80
80
  end
81
81
  rescue Exception => e
82
- raise Fontcustom::Error, "Error parsing `#{relative_to_root(@cli_options[:config])}`:\n#{e.message}"
82
+ raise Fontcustom::Error, "Error parsing `#{relative_path(@cli_options[:config])}`:\n#{e.message}"
83
83
  end
84
84
  end
85
85
  end
@@ -98,7 +98,7 @@ module Fontcustom
98
98
  raise Fontcustom::Error,
99
99
  "CSS selector `#{@options[:css_selector]}` should contain the \"{{glyph}}\" placeholder."
100
100
  end
101
- @options[:css_selector] = @options[:css_selector].strip.gsub(/[^\{\}\w]/, "-")
101
+ @options[:css_selector] = @options[:css_selector].strip.gsub(/[^\.#\{\}\w]/, "-")
102
102
  end
103
103
 
104
104
  def set_manifest_path
@@ -135,7 +135,7 @@ module Fontcustom
135
135
  end
136
136
 
137
137
  if Dir[File.join(@options[:input][:vectors], "*.svg")].empty?
138
- raise Fontcustom::Error, "`#{relative_to_root(@options[:input][:vectors])}` doesn't contain any SVGs."
138
+ raise Fontcustom::Error, "`#{relative_path(@options[:input][:vectors])}` doesn't contain any SVGs."
139
139
  end
140
140
  end
141
141
 
@@ -151,7 +151,7 @@ module Fontcustom
151
151
  @options[:output][key] = expand_path val
152
152
  if File.exists?(val) && ! File.directory?(val)
153
153
  raise Fontcustom::Error,
154
- "Output `#{relative_to_root(@options[:output][key])}` exists but isn't a directory. Check your options."
154
+ "Output `#{relative_path(@options[:output][key])}` exists but isn't a directory. Check your options."
155
155
  end
156
156
  end
157
157
 
@@ -162,11 +162,11 @@ module Fontcustom
162
162
  output = expand_path @options[:output]
163
163
  if File.exists?(output) && ! File.directory?(output)
164
164
  raise Fontcustom::Error,
165
- "Output `#{relative_to_root(output)}` exists but isn't a directory. Check your options."
165
+ "Output `#{relative_path(output)}` exists but isn't a directory. Check your options."
166
166
  end
167
167
  else
168
168
  output = File.join @options[:project_root], @options[:font_name]
169
- say_message :debug, "Generated files will be saved to `#{relative_to_root(output)}/`." if @options[:debug]
169
+ say_message :debug, "Generated files will be saved to `#{relative_path(output)}/`." if @options[:debug]
170
170
  end
171
171
 
172
172
  @options[:output] = {
@@ -207,7 +207,7 @@ module Fontcustom
207
207
  template = File.expand_path File.join(@options[:input][:templates], template) unless template[0] == "/"
208
208
  unless File.exists? template
209
209
  raise Fontcustom::Error,
210
- "Custom template `#{relative_to_root(template)}` doesn't exist. Check your options."
210
+ "Custom template `#{relative_path(template)}` doesn't exist. Check your options."
211
211
  end
212
212
  template
213
213
  end
@@ -217,10 +217,10 @@ module Fontcustom
217
217
  def check_input(dir)
218
218
  if ! File.exists? dir
219
219
  raise Fontcustom::Error,
220
- "Input `#{relative_to_root(dir)}` doesn't exist. Check your options."
220
+ "Input `#{relative_path(dir)}` doesn't exist. Check your options."
221
221
  elsif ! File.directory? dir
222
222
  raise Fontcustom::Error,
223
- "Input `#{relative_to_root(dir)}` isn't a directory. Check your options."
223
+ "Input `#{relative_path(dir)}` isn't a directory. Check your options."
224
224
  end
225
225
  end
226
226
  end
@@ -1,6 +1,6 @@
1
1
  # --------------------------------------------------------------------------- #
2
2
  # Project Info
3
- # Default values shown. Learn more about these options by running
3
+ # Defaults shown. Learn more about these options by running
4
4
  # `fontcustom help` or visiting <http://fontcustom.com>.
5
5
  # --------------------------------------------------------------------------- #
6
6
 
@@ -15,20 +15,27 @@
15
15
 
16
16
 
17
17
  # --------------------------------------------------------------------------- #
18
- # Project Paths
19
- # Relative paths are expanded from PROJECT_ROOT (defaults to the directory
20
- # where the fontcustom command is run). INPUT and OUTPUT can be strings or
21
- # hashes or file types / names.
18
+ # Input Paths
22
19
  # --------------------------------------------------------------------------- #
23
20
 
24
- #project_root: some/other/place
25
- #manifest: tmp/fontcustom
21
+ #input: assets/fonts/fontcustom/source # as a string
26
22
 
27
- #input:
23
+ # OR
24
+
25
+ #input: # as a hash
28
26
  # vectors: app/assets/fonts/fontcustom/vectors # required
29
27
  # templates: app/assets/fonts/fontcustom/templates
30
28
 
31
- #output:
29
+
30
+ # --------------------------------------------------------------------------- #
31
+ # Output Paths
32
+ # --------------------------------------------------------------------------- #
33
+
34
+ #output: assets/fonts/fontcustom # as a string
35
+
36
+ # OR
37
+
38
+ #output: # as a hash
32
39
  # fonts: app/assets/fonts # required
33
40
  # css: app/assets/stylesheets
34
41
  # preview: app/views/styleguide
@@ -37,10 +44,12 @@
37
44
 
38
45
  # --------------------------------------------------------------------------- #
39
46
  # Templates
40
- # Included in Font Custom:
41
- # preview, css, scss, scss-rails
47
+ # Included in Font Custom: preview, css, scss, scss-rails
42
48
  # Custom templates should be saved in the INPUT[:templates] directory and
43
- # referenced by their base file name.
49
+ # referenced by their baserame.
44
50
  # --------------------------------------------------------------------------- #
45
51
 
46
- #templates: [ scss, preview, my-custom-template.yml ]
52
+ #templates:
53
+ # - scss
54
+ # - preview
55
+ # - my-custom-template.yml
@@ -70,7 +70,7 @@ module Fontcustom
70
70
  end
71
71
 
72
72
  # TODO Is this robust enough?
73
- def relative_to_root(path)
73
+ def relative_path(path)
74
74
  path = path.sub(_options[:project_root], "")
75
75
  path = path[1..-1] if path[0] == "/"
76
76
  path = "." if path.empty?
@@ -84,7 +84,7 @@ module Fontcustom
84
84
  def write_file(file, content = "", message = nil, message_body = nil)
85
85
  File.open(file, "w") { |f| f.write(content) }
86
86
  if message
87
- body = message_body || relative_to_root(file)
87
+ body = message_body || relative_path(file)
88
88
  say_message message, body
89
89
  end
90
90
  end
@@ -95,7 +95,7 @@ module Fontcustom
95
95
  JSON.parse(json, :symbolize_names => true)
96
96
  rescue JSON::ParserError
97
97
  raise Fontcustom::Error,
98
- "Couldn't parse `#{relative_to_root file}`. Fix the invalid "\
98
+ "Couldn't parse `#{relative_path file}`. Fix the invalid "\
99
99
  "JSON or delete the file to start from scratch."
100
100
  end
101
101
  end
@@ -133,8 +133,13 @@ module Fontcustom
133
133
 
134
134
  def say_changed(status, changed)
135
135
  return if _options[:quiet]
136
- message = changed.map { |file| relative_to_root(file) }
137
- say_status status, message.join("\n#{" " * 14}"), :green # magic number
136
+ message = changed.map { |file| relative_path(file) }
137
+ say_status status, message.join(line_break)
138
+ end
139
+
140
+ # magic number for Thor say_status line breaks
141
+ def line_break
142
+ "\n#{" " * 14}"
138
143
  end
139
144
 
140
145
  private
@@ -1,3 +1,3 @@
1
1
  module Fontcustom
2
- VERSION = "1.3.0.beta2"
2
+ VERSION = "1.3.0.beta3"
3
3
  end
@@ -118,16 +118,16 @@ describe Fontcustom::Utility do
118
118
  end
119
119
  end
120
120
 
121
- context "#relative_to_root" do
121
+ context "#relative_path" do
122
122
  it "should trim project root from paths" do
123
123
  gen = Generator.new
124
- path = gen.relative_to_root fixture "test/path"
124
+ path = gen.relative_path fixture "test/path"
125
125
  path.should == "test/path"
126
126
  end
127
127
 
128
128
  it "should trim beginning slash" do
129
129
  gen = Generator.new
130
- path = gen.relative_to_root "/test/path"
130
+ path = gen.relative_path "/test/path"
131
131
  path.should == "test/path"
132
132
  end
133
133
  end
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.beta2
4
+ version: 1.3.0.beta3
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-11-29 00:00:00.000000000 Z
12
+ date: 2013-12-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json