Class: Squib::Conf Private

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#antialiasObject

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

#backendObject

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_formatObject

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_colorsObject

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

#dirObject

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_dirObject

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

#prefixObject

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_barsObject

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 progress_bars
  @config_hash['progress_bars']
end

#text_hintObject

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_sObject

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

#typographerObject

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.

Returns:

  • (Boolean)


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.

Returns:

  • (Boolean)


120
121
122
# File 'lib/squib/conf.rb', line 120

def warn_png_scale?
  @config_hash['warn_png_scale']
end