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'       => '.',
  '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.



51
52
53
54
55
# File 'lib/squib/conf.rb', line 51

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



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

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.



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

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.



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

def backend
  @config_hash['backend']
end

#cell_px ⇒ 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.



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

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



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

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.



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

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.



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

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.



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

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.



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

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.



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

def progress_bars
  @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.



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

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.



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

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.



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

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.



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

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)


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

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)


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

def warn_png_scale?
  @config_hash['warn_png_scale']
end