class Squib::Conf
@api private
Constants
- ANTIALIAS_OPTS
Translate the hints to the methods.
- DEFAULTS
Public Class Methods
load(file)
click to toggle source
Load the configuration file, if exists, overriding hardcoded defaults @api private
# File lib/squib/conf.rb, line 60 def self.load(file) yaml = {} if File.exists? file Squib::logger.info { " using config: #{file}" } yaml = YAML.load_file(file) || {} end warn_unrecognized(yaml) Conf.new(DEFAULTS.merge(yaml)) end
new(config_hash = DEFAULTS)
click to toggle source
# File lib/squib/conf.rb, line 52 def initialize(config_hash = DEFAULTS) @config_hash = config_hash.merge USER_CONFIG # programmatic overrides yml @typographer = Args::Typographer.new(config_hash) normalize_antialias end
Private Class Methods
warn_unrecognized(yaml)
click to toggle source
Were there any unrecognized options in the config file?
# File lib/squib/conf.rb, line 141 def self.warn_unrecognized(yaml) unrec = yaml.keys - DEFAULTS.keys if unrec.any? Squib::logger.warn "Unrecognized configuration option(s): #{unrec.join(',')}" end end
Public Instance Methods
antialias()
click to toggle source
# File lib/squib/conf.rb, line 114 def antialias @config_hash['antialias'] end
backend()
click to toggle source
# File lib/squib/conf.rb, line 118 def backend @config_hash['backend'] end
cell_px()
click to toggle source
# File lib/squib/conf.rb, line 98 def cell_px @config_hash['cell_px'].to_f end
count_format()
click to toggle source
# File lib/squib/conf.rb, line 110 def count_format @config_hash['count_format'] end
custom_colors()
click to toggle source
# File lib/squib/conf.rb, line 122 def custom_colors @config_hash['custom_colors'] end
dir()
click to toggle source
# File lib/squib/conf.rb, line 102 def dir @config_hash['dir'] end
img_dir()
click to toggle source
# File lib/squib/conf.rb, line 74 def img_dir @config_hash['img_dir'] end
img_missing()
click to toggle source
# File lib/squib/conf.rb, line 78 def img_missing @config_hash['img_missing'].to_sym end
prefix()
click to toggle source
# File lib/squib/conf.rb, line 106 def prefix @config_hash['prefix'] end
progress_bars()
click to toggle source
# File lib/squib/conf.rb, line 90 def progress_bars @config_hash['progress_bars'] end
text_hint()
click to toggle source
# File lib/squib/conf.rb, line 82 def text_hint @config_hash['text_hint'] end
text_hint=(hint)
click to toggle source
# File lib/squib/conf.rb, line 86 def text_hint=(hint) @config_hash['text_hint'] = hint end
to_s()
click to toggle source
# File lib/squib/conf.rb, line 70 def to_s "Conf: #{@config_hash.to_s}" end
typographer()
click to toggle source
# File lib/squib/conf.rb, line 94 def typographer @typographer end
warn_ellipsize?()
click to toggle source
# File lib/squib/conf.rb, line 126 def warn_ellipsize? @config_hash['warn_ellipsize'] end
warn_png_scale?()
click to toggle source
# File lib/squib/conf.rb, line 130 def warn_png_scale? @config_hash['warn_png_scale'] end
Private Instance Methods
normalize_antialias()
click to toggle source
# File lib/squib/conf.rb, line 136 def normalize_antialias @config_hash['antialias'] = ANTIALIAS_OPTS[@config_hash['antialias'].downcase.strip] end