Sha256: 01a73ee1d4ad938dc43a963dded275a528df1faf2b7121d65c973e91c16adce8
Contents?: true
Size: 972 Bytes
Versions: 1
Compression:
Stored size: 972 Bytes
Contents
module Fontist class Finder def initialize(name) @name = name end def self.find(name) new(name).find end def find find_system_font || downloadable_font || raise_invalid_error end private attr_reader :name def find_system_font Fontist::SystemFont.find(name) end def remote_source Fontist::Source.all.remote.to_h.select do |key, value| !value.fonts.grep(/#{name}/i).empty? end end def downloadable_font unless remote_source.empty? raise( Fontist::Errors::MissingFontError, "Fonts are missing, please run" \ "Fontist::Installer.download(name, confirmation: 'yes') to " \ "download these fonts" ) end end def raise_invalid_error raise( Fontist::Errors::NonSupportedFontError, "Could not find the #{name} font in any of the supported downlodable" ) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fontist-0.2.0 | lib/fontist/finder.rb |