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',
  'cell_px'       => 37.5,
  'count_format'  => '%02d',
  'custom_colors' => {},
  'dir'           => '_output',
  'hint'          => :none,
  'img_dir'       => '.',
  'img_missing'   => :warn,
  '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.



52
53
54
55
56
# 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

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



60
61
62
63
64
65
66
67
68
# File 'lib/squib/conf.rb', line 60

def self.load(file)
  yaml = {}
  if File.exist? 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.



114
115
116
# File 'lib/squib/conf.rb', line 114

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.



118
119
120
# File 'lib/squib/conf.rb', line 118

def backend
  @config_hash['backend']
end

#cell_pxObject

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.



98
99
100
# File 'lib/squib/conf.rb', line 98

def cell_px
  @config_hash['cell_px'].to_f
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.



110
111
112
# File 'lib/squib/conf.rb', line 110

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.



122
123
124
# File 'lib/squib/conf.rb', line 122

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.



102
103
104
# File 'lib/squib/conf.rb', line 102

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.



74
75
76
# File 'lib/squib/conf.rb', line 74

def img_dir
  @config_hash['img_dir']
end

#img_missingObject

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.



78
79
80
# File 'lib/squib/conf.rb', line 78

def img_missing
  @config_hash['img_missing'].to_sym
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.



106
107
108
# File 'lib/squib/conf.rb', line 106

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.



90
91
92
# File 'lib/squib/conf.rb', line 90

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.



82
83
84
# File 'lib/squib/conf.rb', line 82

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.



86
87
88
# File 'lib/squib/conf.rb', line 86

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.



70
71
72
# File 'lib/squib/conf.rb', line 70

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.



94
95
96
# File 'lib/squib/conf.rb', line 94

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)


126
127
128
# File 'lib/squib/conf.rb', line 126

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)


130
131
132
# File 'lib/squib/conf.rb', line 130

def warn_png_scale?
  @config_hash['warn_png_scale']
end