heroicons_helper 0.2.0 → 0.3.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: 95ec724478d383801f98ffeeb2bd8d0f5f14fea4c6eee777b59b9bc5e0337d78
4
- data.tar.gz: 18e9be3121ca73f11a472a36ed35d31b2c157a12a4d177395e82ea7d5dacf993
3
+ metadata.gz: ea79c1638e02674896f2f251375b879df8e289d10c39bd1b6550b35f65bb667e
4
+ data.tar.gz: 49e4f89e38f7ceec4e09970d9864f859424f4e59f314b40353df87e73ff128b9
5
5
  SHA512:
6
- metadata.gz: 5ab5881814e673ef1d7ee9e24f454a05796c4558baaa780a3c0d7a1365dec92e67858c535b41e046b3cf548b9265a9446fbdb38fc10631e3e1475566f074a742
7
- data.tar.gz: 4fee60bcdd51cb3109fc48acde1693a702f965ab3475f9f9ebce6ed9e26110f5cc668febde294e4d20f30cbe6de64d07aae1e686ec7f62d742987a3ca98aa111
6
+ metadata.gz: c4c7715c0dc796769dd80fd26e38a56bbccadb1c00418ac0ff8911722679bd571e2a2cb058ecbf3931e9c6da3020628239ee5500ef90b05aed66c53f856bec5c
7
+ data.tar.gz: 0257f55a823a70b7147b4ac0d7c3051fd407febea7577b0ffd2cc9bb2e14b7582299daae2a425f273de59ca7bd4dd5ddd51181baeb5ac40cdd47c1006224a324
data/README.md CHANGED
@@ -22,10 +22,10 @@ require "heroicons_helper"
22
22
  include HeroiconsHelper
23
23
  ```
24
24
 
25
- You'll have a brand new method called `heroicons` whose signature looks like this:
25
+ You'll have a brand new method called `heroicon` whose signature looks like this:
26
26
 
27
27
  ```ruby
28
- heroicons(symbol, variant, attributes: {})
28
+ heroicon(symbol, variant, attributes: {})
29
29
  ```
30
30
 
31
31
  where
@@ -37,7 +37,7 @@ where
37
37
  This one method call returns an object that represents the Heroicon, and you should call `to_svg` to get the resulting SVG string:
38
38
 
39
39
  ```ruby
40
- outline_icon = heroicons("x", "outline")
40
+ outline_icon = heroicon("x", "outline")
41
41
  puts outline_icon.to_svg
42
42
  ```
43
43
  ```
@@ -58,7 +58,7 @@ icons_to_preload = [{
58
58
  },]
59
59
 
60
60
  HeroiconsHelper::Cache.preload!(icons_to_preload) do |found, icon|
61
- # An instance of `FakeClass` is stored in the cache
61
+ # An instance of `FakeClass` will be stored in the cache
62
62
  FakeClass.new(icon) unless found
63
63
  end
64
64
  ```
@@ -55,15 +55,22 @@ module HeroiconsHelper
55
55
  end
56
56
 
57
57
  def get_heroicon(symbol, variant)
58
- icon = HeroiconsHelper::ICON_SYMBOLS[symbol]
59
- raise "Couldn't find heroicons symbol for #{@symbol.inspect}" unless icon
58
+ symbol_s = symbol.to_s
59
+ raise ArgumentError, "Icon name can't be empty" if symbol_s.empty?
60
60
 
61
- icon_in_variant = icon["variants"][variant]
62
- raise "Heroicons symbol for #{@symbol.inspect} doesn't have variant #{@variant.inspect}" unless icon_in_variant
61
+ variant_s = variant.to_s
62
+ raise ArgumentError, "Variant `#{variant.inspect}` is invalid; must be one of #{VARIANTS.join(", ")}" unless VARIANTS.include?(variant_s)
63
+
64
+ icon = HeroiconsHelper::ICON_SYMBOLS[symbol_s]
65
+
66
+ raise ArgumentError, "Couldn't find Heroicon for `#{symbol.inspect}`" unless icon
67
+
68
+ icon_in_variant = icon["variants"][variant_s]
69
+ raise ArgumentError, "Heroicon for `#{symbol.inspect}` doesn't have variant `#{variant.inspect}`" unless icon_in_variant
63
70
 
64
71
  {
65
72
  "name" => icon["name"],
66
- "variant" => variant,
73
+ "variant" => variant_s,
67
74
  "width" => icon_in_variant["width"],
68
75
  "height" => icon_in_variant["height"],
69
76
  "path" => icon_in_variant["path"],
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HeroiconsHelper
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.0"
5
5
  end
@@ -9,7 +9,7 @@ module HeroiconsHelper
9
9
  file_data = File.read(File.join(File.dirname(__FILE__), "./heroicons_helper/data.json"))
10
10
  ICON_SYMBOLS = JSON.parse(file_data).freeze
11
11
 
12
- def heroicons(symbol, variant, attributes: {})
12
+ def heroicon(symbol, variant, attributes: {})
13
13
  ::HeroiconsHelper::Icon.new(symbol, variant, attributes: attributes)
14
14
  end
15
15
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: heroicons_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Garen J. Torikian
@@ -58,7 +58,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
58
58
  - !ruby/object:Gem::Version
59
59
  version: '0'
60
60
  requirements: []
61
- rubygems_version: 3.3.13
61
+ rubygems_version: 3.3.7
62
62
  signing_key:
63
63
  specification_version: 4
64
64
  summary: Heroicons port for Ruby