heroicons_helper 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bbbab8ccd0d05be04deb3df081747364d962a5e21e581d427b0ebbeff67b54ae
4
- data.tar.gz: fcff746233b82222604d54d5f5e01cfd5760de65892532c8cfb4ad4c5cc64505
3
+ metadata.gz: 5da4c0b0f7f44f07d6503285f56e845985f40dafa7684bc1f9f0dbbaad9a01a4
4
+ data.tar.gz: dc0e4700c426c4d40d0e8006bcd554b448be6ee2fc8a0394bd6258084ef14c93
5
5
  SHA512:
6
- metadata.gz: e539907cca91fa6a1f9ed11651238721bb8b7949184d4f8270ea58a5b73855257714d5ed97378cc7613857e31dd1dbcf927be05bbb487dc1fbc462f3c8a990fa
7
- data.tar.gz: 36b3b4fe61cd709b59e36c61f8a05d2a2ce024bc11d6ff6bd54bce07990954516eb63df36f4caeddb384153ae711aa496ad64d338391e1fcea0ee2cc1e79ee61
6
+ metadata.gz: 71e76c5abdc3054576e00408126357b6393d7d0eea9f0f447e0cf9f5c404fc6c0b02901669333d2d7dbe5d9aec67ed8e22cfdbfc20817b879a61128e89bdc567
7
+ data.tar.gz: af25792b836859a2f929458552f626e97cf71223b82a8e700659c461e8a1d335360817597af63a5198a21ba1dff7d958f18e729928aab5bbc2e7d9fc67b56396
data/Gemfile CHANGED
@@ -5,6 +5,10 @@ source "https://rubygems.org"
5
5
  # Specify your gem's dependencies in heroicons_helper.gemspec
6
6
  gemspec
7
7
 
8
+ group :development do
9
+ gem "bundler", "~> 2.0"
10
+ end
11
+
8
12
  group :development, :test do
9
13
  gem "amazing_print"
10
14
  gem "debug"
@@ -16,6 +16,10 @@ Gem::Specification.new do |spec|
16
16
 
17
17
  spec.metadata["homepage_uri"] = spec.homepage
18
18
  spec.metadata["source_code_uri"] = spec.homepage
19
+ spec.metadata = {
20
+ "funding_uri" => "https://github.com/sponsors/gjtorikian/",
21
+ "rubygems_mfa_required" => "true",
22
+ }
19
23
 
20
24
  # Specify which files should be added to the gem when it is released.
21
25
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
@@ -28,6 +32,8 @@ Gem::Specification.new do |spec|
28
32
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
29
33
  spec.require_paths = ["lib"]
30
34
 
35
+ spec.add_runtime_dependency("activesupport", ">= 6")
36
+
31
37
  # Uncomment to register a new dependency of your gem
32
38
  # spec.add_dependency "example-gem", "~> 1.0"
33
39
 
@@ -6,8 +6,15 @@ module HeroiconsHelper
6
6
  LOOKUP = {}
7
7
 
8
8
  class << self
9
- def get_key(name:, variant:, width: nil, height: nil)
10
- attrs = { name: name, variant: variant, width: width, height: height }
9
+ def get_key(name:, variant:, unsafe: false, width: nil, height: nil)
10
+ attrs = { name: name, variant: variant, unsafe: unsafe, width: width, height: height }
11
+ if unsafe
12
+ attrs[:unsafe] = true
13
+ else
14
+ attrs.delete(:unsafe)
15
+ attrs[:safe] = true
16
+ end
17
+
11
18
  attrs.compact!
12
19
  attrs.hash
13
20
  end
@@ -52,8 +59,9 @@ module HeroiconsHelper
52
59
  cache_key = HeroiconsHelper::Cache.get_key(
53
60
  name: icon["name"],
54
61
  variant: icon["variant"],
62
+ unsafe: icon["unsafe"] || false,
55
63
  height: height,
56
- width: width
64
+ width: width,
57
65
  )
58
66
 
59
67
  cache_icon = HeroiconsHelper::Cache.read(cache_key)
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "set"
4
+ require "active_support/core_ext/string/output_safety"
4
5
 
5
6
  module HeroiconsHelper
6
7
  # Icon to show heroicons by name and variant.
@@ -12,13 +13,14 @@ module HeroiconsHelper
12
13
  VARIANT_MINI = "mini"
13
14
  VALID_VARIANTS = Set.new([VARIANT_OUTLINE, VARIANT_SOLID, VARIANT_MINI]).freeze
14
15
 
15
- def initialize(name, variant, attributes: {})
16
+ def initialize(name, variant, unsafe: false, attributes: {})
16
17
  @name = name.to_s
17
18
  @variant = variant.to_s
19
+ @unsafe = unsafe
18
20
 
19
21
  heroicon = get_heroicon(@name, @variant)
20
22
 
21
- @path = heroicon["path"]
23
+ @path = safe? ? ActiveSupport::SafeBuffer.new(heroicon["path"]) : heroicon["path"]
22
24
  @width = heroicon["width"]
23
25
  @height = heroicon["height"]
24
26
  @keywords = heroicon["keywords"]
@@ -36,6 +38,10 @@ module HeroiconsHelper
36
38
  "<!-- Heroicon name: #{@variant}/#{@name} --><svg xmlns=\"http://www.w3.org/2000/svg\" #{html_attributes}>#{@path}</svg>"
37
39
  end
38
40
 
41
+ private def safe?
42
+ !@unsafe
43
+ end
44
+
39
45
  private def html_attributes
40
46
  attrs = []
41
47
  @attributes.each_pair { |attr, value| attrs << "#{attr}=\"#{value}\"" }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HeroiconsHelper
4
- VERSION = "0.6.0"
4
+ VERSION = "0.7.0"
5
5
  end
@@ -9,18 +9,19 @@ module HeroiconsHelper
9
9
  file_data = File.read(File.join(File.dirname(__FILE__), "./heroicons_helper/data.json"))
10
10
  ICON_NAMES = JSON.parse(file_data).freeze
11
11
 
12
- def heroicon(name, variant:, **attributes)
12
+ def heroicon(name, variant:, unsafe: false, **attributes)
13
13
  cache_key = HeroiconsHelper::Cache.get_key(
14
14
  name: name,
15
15
  variant: variant,
16
+ unsafe: unsafe,
16
17
  height: attributes[:height],
17
- width: attributes[:width]
18
+ width: attributes[:width],
18
19
  )
19
20
 
20
21
  cached_heroicon = HeroiconsHelper::Cache.read(cache_key)
21
22
  return cached_heroicon unless cached_heroicon.nil?
22
23
 
23
- heroicon = ::HeroiconsHelper::Icon.new(name, variant, attributes: attributes)
24
+ heroicon = ::HeroiconsHelper::Icon.new(name, variant, unsafe: unsafe, attributes: attributes)
24
25
  HeroiconsHelper::Cache.set(cache_key, heroicon)
25
26
 
26
27
  heroicon
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: heroicons_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Garen J. Torikian
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-08-26 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2022-09-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '6'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '6'
13
27
  description: A package that distributes Heroicons as a gem, for easy inclusion in
14
28
  Ruby projects.
15
29
  email:
@@ -38,8 +52,8 @@ homepage: https://github.com/gjtorikian/heroicons_helper
38
52
  licenses:
39
53
  - MIT
40
54
  metadata:
41
- homepage_uri: https://github.com/gjtorikian/heroicons_helper
42
- source_code_uri: https://github.com/gjtorikian/heroicons_helper
55
+ funding_uri: https://github.com/sponsors/gjtorikian/
56
+ rubygems_mfa_required: 'true'
43
57
  post_install_message:
44
58
  rdoc_options: []
45
59
  require_paths: