Why the last rebuild could not deliver: the exception it died on, and
the icons it left out of the sprite.
61
62
63
# File 'lib/fontico.rb', line 61defbuild_error@build_errorend
.css_class ⇒ Object
Base class on every emitted
32
# File 'lib/fontico.rb', line 32defcss_class=@css_class||="ico"
.inline_sprite=(value) ⇒ Object(writeonly)
Sets the attribute inline_sprite
Parameters:
value
—
the value to set the attribute inline_sprite to.
29
30
31
# File 'lib/fontico.rb', line 29definline_sprite=(value)@inline_sprite=valueend
.manifest_path ⇒ Object
36
# File 'lib/fontico.rb', line 36defmanifest_path=@manifest_path||=File.join(root,"icons.yml")
.output_dir ⇒ Object
35
# File 'lib/fontico.rb', line 35defoutput_dir=@output_dir||="app/assets/builds"
.root ⇒ Object
34
# File 'lib/fontico.rb', line 34defroot=@root||=Dir.pwd
Class Method Details
.build(**opts) ⇒ Object
45
# File 'lib/fontico.rb', line 45defbuild(**opts)=Builder.new(manifest,root:root,output:output_dir,**opts).call
.check!(name = nil) ⇒ Object
Raised at the call site, because that is the only place with anything
useful to say. An icon left out of the sprite still resolves through the
manifest and renders a perfectly valid
Free in production: only the dev reloader ever fills these in.
# File 'lib/fontico.rb', line 72defcheck!(name=nil)raiseError,"icons.yml did not build: #{@build_error.message}"if@build_errorreason=missing_icons[name]raiseError,"icon #{name.inspect} was left out of the sprite: #{reason}"ifreasonend
.codepoint(name) ⇒ Object
The character to print when drawing this icon from the font — for Prawn,
where you write the glyph literally. Pinned append-only in icons.lock so
a reference in Ruby source never goes stale.
# File 'lib/fontico.rb', line 86defcodepoint(name)cp=lockfile.codepoint_for(name.to_s)raiseError,"no icon named #{name.inspect}; run rake fontico:build"ifcp.nil?cpend
# File 'lib/fontico.rb', line 96defconfigure=yield(self)
.font_file ⇒ Object
81
# File 'lib/fontico.rb', line 81deffont_file=File.join(root,output_dir,"icons.ttf")
.glyph(name) ⇒ Object
93
# File 'lib/fontico.rb', line 93defglyph(name)=[codepoint(name)].pack("U")
.inline_sprite? ⇒ Boolean
Inline mode embeds definitions in the layout instead of
referencing an external file — required when assets are served from a
CDN, where cross-origin
Returns:
(Boolean)
43
# File 'lib/fontico.rb', line 43definline_sprite?=!!@inline_sprite
.lockfile ⇒ Object
79
# File 'lib/fontico.rb', line 79deflockfile=Lockfile.new(File.join(root,"icons.lock"))
.manifest ⇒ Object
37
# File 'lib/fontico.rb', line 37defmanifest=@manifest||=Manifest.load(manifest_path)
.missing_icons ⇒ Object
63
# File 'lib/fontico.rb', line 63defmissing_icons=@missing_icons||={}
.rebuild! ⇒ Object
The dev reloader's build, and the only caller that records what went
wrong. Building stays forgiving on purpose — one typo must not stop the
other 199 icons — so nothing raises here; the complaint is held until
someone actually draws an icon. See #check!.
51
52
53
54
55
56
57
# File 'lib/fontico.rb', line 51defrebuild!@build_error=nil@missing_icons=build.missing||{}rescueStandardError=>e@build_error=e@missing_icons={}end
.reset! ⇒ Object
94
# File 'lib/fontico.rb', line 94defreset!=(@manifest=@build_error=@missing_icons=nil)
.sprite_file ⇒ Object
38
# File 'lib/fontico.rb', line 38defsprite_file=File.join(root,output_dir,"icons.svg")