Class: Squib::Conf Private
- Inherits:
-
Object
- Object
- Squib::Conf
- Defined in:
- lib/squib/conf.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Constant Summary collapse
- DEFAULTS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
{ 'antialias' => 'best', 'backend' => 'memory', 'count_format' => '%02d', 'custom_colors' => {}, 'dir' => '_output', 'hint' => :none, 'img_dir' => '.', 'progress_bars' => false, 'prefix' => 'card_', 'ldquote' => "\u201C", # UTF8 chars 'rdquote' => "\u201D", 'lsquote' => "\u2018", 'rsquote' => "\u2019", 'em_dash' => "\u2014", 'en_dash' => "\u2013", 'ellipsis' => "\u2026", 'smart_quotes' => true, 'text_hint' => 'off', 'warn_ellipsize' => true, 'warn_png_scale' => true, }
- ANTIALIAS_OPTS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Translate the hints to the methods.
{ nil => 'subpixel', 'best' => 'subpixel', 'good' => 'gray', 'fast' => 'gray', 'gray' => 'gray', 'subpixel' => 'subpixel' }
Class Method Summary collapse
-
.load(file) ⇒ Object
private
Load the configuration file, if exists, overriding hardcoded defaults.
Instance Method Summary collapse
- #antialias ⇒ Object private
- #backend ⇒ Object private
- #count_format ⇒ Object private
- #custom_colors ⇒ Object private
- #dir ⇒ Object private
- #img_dir ⇒ Object private
-
#initialize(config_hash = DEFAULTS) ⇒ Conf
constructor
private
A new instance of Conf.
- #prefix ⇒ Object private
- #progress_bars ⇒ Object private
- #text_hint ⇒ Object private
- #text_hint=(hint) ⇒ Object private
- #to_s ⇒ Object private
- #typographer ⇒ Object private
- #warn_ellipsize? ⇒ Boolean private
- #warn_png_scale? ⇒ Boolean private
Constructor Details
#initialize(config_hash = DEFAULTS) ⇒ Conf
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Conf.
50 51 52 53 54 |
# File 'lib/squib/conf.rb', line 50 def initialize(config_hash = DEFAULTS) @config_hash = config_hash.merge USER_CONFIG # programmatic overrides yml @typographer = Args::Typographer.new(config_hash) normalize_antialias end |
Class Method Details
.load(file) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Load the configuration file, if exists, overriding hardcoded defaults
58 59 60 61 62 63 64 65 66 |
# File 'lib/squib/conf.rb', line 58 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 |
Instance Method Details
#antialias ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
104 105 106 |
# File 'lib/squib/conf.rb', line 104 def antialias @config_hash['antialias'] end |
#backend ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
108 109 110 |
# File 'lib/squib/conf.rb', line 108 def backend @config_hash['backend'] end |
#count_format ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
100 101 102 |
# File 'lib/squib/conf.rb', line 100 def count_format @config_hash['count_format'] end |
#custom_colors ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
112 113 114 |
# File 'lib/squib/conf.rb', line 112 def custom_colors @config_hash['custom_colors'] end |
#dir ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
92 93 94 |
# File 'lib/squib/conf.rb', line 92 def dir @config_hash['dir'] end |
#img_dir ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
72 73 74 |
# File 'lib/squib/conf.rb', line 72 def img_dir @config_hash['img_dir'] end |
#prefix ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
96 97 98 |
# File 'lib/squib/conf.rb', line 96 def prefix @config_hash['prefix'] end |
#progress_bars ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
84 85 86 |
# File 'lib/squib/conf.rb', line 84 def @config_hash['progress_bars'] end |
#text_hint ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
76 77 78 |
# File 'lib/squib/conf.rb', line 76 def text_hint @config_hash['text_hint'] end |
#text_hint=(hint) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
80 81 82 |
# File 'lib/squib/conf.rb', line 80 def text_hint=(hint) @config_hash['text_hint'] = hint end |
#to_s ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
68 69 70 |
# File 'lib/squib/conf.rb', line 68 def to_s "Conf: #{@config_hash.to_s}" end |
#typographer ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
88 89 90 |
# File 'lib/squib/conf.rb', line 88 def typographer @typographer end |
#warn_ellipsize? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
116 117 118 |
# File 'lib/squib/conf.rb', line 116 def warn_ellipsize? @config_hash['warn_ellipsize'] end |
#warn_png_scale? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
120 121 122 |
# File 'lib/squib/conf.rb', line 120 def warn_png_scale? @config_hash['warn_png_scale'] end |