Class: Glyphs::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/glyphs/configuration.rb

Constant Summary collapse

DEFAULT_FALLBACK_ICONS =
{
  lucide: "circle-question-mark",
  phosphor: "question",
  heroicons: "question-mark-circle"
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



26
27
28
29
30
31
32
33
# File 'lib/glyphs/configuration.rb', line 26

def initialize
  @raise_on_missing = defined?(Rails) ? Rails.env.local? : true
  @on_missing_icon = nil
  @fallback_icons = DEFAULT_FALLBACK_ICONS.dup
  @cache_svgs = true
  @keep_icons = []
  @prune_source_globs = nil
end

Instance Attribute Details

#cache_svgsObject

raise_on_missing: boolean; when true, Icons::IconNotFound is re-raised. Defaults to true in local Rails environments (and outside Rails). on_missing_icon: optional callable(error, name:, library:, variant:), invoked before the fallback renders when not raising. fallback_icons: { library => icon_name } rendered instead of a missing icon. cache_svgs: memoize rendered SVG strings per [library, variant, name, attributes]. keep_icons: icons the pruner must keep despite no static reference (dynamic / data-driven names). A flat list of names/globs, or a { library => [names/globs] } hash. fallback_icons are always kept. prune_source_globs: extra locations the pruner's scanner text-scans IN ADDITION to the built-in Ruby/template defaults — e.g. a config file that names icons. Never replaces the defaults (nil = defaults only).



23
24
25
# File 'lib/glyphs/configuration.rb', line 23

def cache_svgs
  @cache_svgs
end

#fallback_iconsObject

raise_on_missing: boolean; when true, Icons::IconNotFound is re-raised. Defaults to true in local Rails environments (and outside Rails). on_missing_icon: optional callable(error, name:, library:, variant:), invoked before the fallback renders when not raising. fallback_icons: { library => icon_name } rendered instead of a missing icon. cache_svgs: memoize rendered SVG strings per [library, variant, name, attributes]. keep_icons: icons the pruner must keep despite no static reference (dynamic / data-driven names). A flat list of names/globs, or a { library => [names/globs] } hash. fallback_icons are always kept. prune_source_globs: extra locations the pruner's scanner text-scans IN ADDITION to the built-in Ruby/template defaults — e.g. a config file that names icons. Never replaces the defaults (nil = defaults only).



23
24
25
# File 'lib/glyphs/configuration.rb', line 23

def fallback_icons
  @fallback_icons
end

#keep_iconsObject

raise_on_missing: boolean; when true, Icons::IconNotFound is re-raised. Defaults to true in local Rails environments (and outside Rails). on_missing_icon: optional callable(error, name:, library:, variant:), invoked before the fallback renders when not raising. fallback_icons: { library => icon_name } rendered instead of a missing icon. cache_svgs: memoize rendered SVG strings per [library, variant, name, attributes]. keep_icons: icons the pruner must keep despite no static reference (dynamic / data-driven names). A flat list of names/globs, or a { library => [names/globs] } hash. fallback_icons are always kept. prune_source_globs: extra locations the pruner's scanner text-scans IN ADDITION to the built-in Ruby/template defaults — e.g. a config file that names icons. Never replaces the defaults (nil = defaults only).



23
24
25
# File 'lib/glyphs/configuration.rb', line 23

def keep_icons
  @keep_icons
end

#on_missing_iconObject

raise_on_missing: boolean; when true, Icons::IconNotFound is re-raised. Defaults to true in local Rails environments (and outside Rails). on_missing_icon: optional callable(error, name:, library:, variant:), invoked before the fallback renders when not raising. fallback_icons: { library => icon_name } rendered instead of a missing icon. cache_svgs: memoize rendered SVG strings per [library, variant, name, attributes]. keep_icons: icons the pruner must keep despite no static reference (dynamic / data-driven names). A flat list of names/globs, or a { library => [names/globs] } hash. fallback_icons are always kept. prune_source_globs: extra locations the pruner's scanner text-scans IN ADDITION to the built-in Ruby/template defaults — e.g. a config file that names icons. Never replaces the defaults (nil = defaults only).



23
24
25
# File 'lib/glyphs/configuration.rb', line 23

def on_missing_icon
  @on_missing_icon
end

#prune_source_globsObject

raise_on_missing: boolean; when true, Icons::IconNotFound is re-raised. Defaults to true in local Rails environments (and outside Rails). on_missing_icon: optional callable(error, name:, library:, variant:), invoked before the fallback renders when not raising. fallback_icons: { library => icon_name } rendered instead of a missing icon. cache_svgs: memoize rendered SVG strings per [library, variant, name, attributes]. keep_icons: icons the pruner must keep despite no static reference (dynamic / data-driven names). A flat list of names/globs, or a { library => [names/globs] } hash. fallback_icons are always kept. prune_source_globs: extra locations the pruner's scanner text-scans IN ADDITION to the built-in Ruby/template defaults — e.g. a config file that names icons. Never replaces the defaults (nil = defaults only).



23
24
25
# File 'lib/glyphs/configuration.rb', line 23

def prune_source_globs
  @prune_source_globs
end

#raise_on_missingObject

raise_on_missing: boolean; when true, Icons::IconNotFound is re-raised. Defaults to true in local Rails environments (and outside Rails). on_missing_icon: optional callable(error, name:, library:, variant:), invoked before the fallback renders when not raising. fallback_icons: { library => icon_name } rendered instead of a missing icon. cache_svgs: memoize rendered SVG strings per [library, variant, name, attributes]. keep_icons: icons the pruner must keep despite no static reference (dynamic / data-driven names). A flat list of names/globs, or a { library => [names/globs] } hash. fallback_icons are always kept. prune_source_globs: extra locations the pruner's scanner text-scans IN ADDITION to the built-in Ruby/template defaults — e.g. a config file that names icons. Never replaces the defaults (nil = defaults only).



23
24
25
# File 'lib/glyphs/configuration.rb', line 23

def raise_on_missing
  @raise_on_missing
end