Repository navigation
Expand file tree
/
Copy pathlucide-rails.rb
More file actions
62 lines (53 loc) · 1.77 KB
/
Copy pathlucide-rails.rb
File metadata and controls
62 lines (53 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# frozen_string_literal: true
require "active_support/gzip"
require_relative "lucide-rails/version"
require_relative "lucide-rails/icon_provider"
if defined?(Rails)
require_relative "lucide-rails/rails_helper"
require_relative "lucide-rails/railtie"
end
module LucideRails
# Extracted from options contained in svg tags from original/*.svg
DEFAULT_OPTIONS = {
"aria-hidden" => "true",
"width" => "24",
"height" => "24",
"viewBox" => "0 0 24 24",
"fill" => "none",
"stroke" => "currentColor",
"stroke-width" => "2",
"stroke-linecap" => "round",
"stroke-linejoin" => "round"
}.freeze
module_function
# Public: Defines the default provider for icons. The library can either load
# icons from the filesystem as required, or use a memory cache for all icons,
# avoiding filesystem accesses for each required icon on the cost of a
# slightly extra memory usage.
#
# type - Type of provider to use. Accepts either :memory (default), or
# :filesystem
#
# Returns nothing.
def provider=(type)
unless [:memory, :filesystem, nil].include? type
raise ArgumentError, "Unknown provider #{type}, valid options are :memory, :filesystem"
end
@provider = type
end
# Internal: Returns either the set provider, falling back to the default one.
def provider
@provider || :memory
end
# Public: Overrides default options for every svg generated by the library.
# See LucideRails::DEFAULT_OPTIONS for reference.
def default_options=(value)
@default_options = value
end
# Internal: Returns the overriden default options, or the builtin one in case
# no override occurred.
def default_options
@default_options || DEFAULT_OPTIONS
end
GEM_ROOT = Pathname.new(File.dirname(__FILE__)).join("..")
end