heroicons_helper 0.1.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,6 +7,7 @@ module HeroiconsHelper
7
7
 
8
8
  VARIANT_OUTLINE = "outline"
9
9
  VARIANT_SOLID = "solid"
10
+ VARIANTS = [VARIANT_OUTLINE, VARIANT_SOLID].freeze
10
11
 
11
12
  def initialize(symbol, variant, attributes: {})
12
13
  @symbol = symbol
@@ -54,15 +55,21 @@ module HeroiconsHelper
54
55
  end
55
56
 
56
57
  def get_heroicon(symbol, variant)
57
- icon = HeroiconsHelper::ICON_SYMBOLS[symbol]
58
- 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
+ variant_s = variant.to_s
61
+ raise ArgumentError, "Variant `#{variant.inspect}` is invalid; must be one of #{VARIANTS.join(", ")}" unless VARIANTS.include?(variant_s)
59
62
 
60
- icon_in_variant = icon["variants"][variant]
61
- raise "Heroicons symbol for #{@symbol.inspect} don't have variant #{@variant.inspect}" unless icon_in_variant
63
+ icon = HeroiconsHelper::ICON_SYMBOLS[symbol_s]
64
+
65
+ raise ArgumentError, "Couldn't find Heroicon for `#{symbol.inspect}`" unless icon
66
+
67
+ icon_in_variant = icon["variants"][variant_s]
68
+ raise ArgumentError, "Heroicon for `#{symbol.inspect}` doesn't have variant `#{variant.inspect}`" unless icon_in_variant
62
69
 
63
70
  {
64
71
  "name" => icon["name"],
65
- "variant" => variant,
72
+ "variant" => variant_s,
66
73
  "width" => icon_in_variant["width"],
67
74
  "height" => icon_in_variant["height"],
68
75
  "path" => icon_in_variant["path"],
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HeroiconsHelper
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.2"
5
5
  end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "heroicons_helper/version"
4
+ require_relative "heroicons_helper/cache"
4
5
  require_relative "heroicons_helper/icon"
5
6
  require "json"
6
7
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: heroicons_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.2
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-06-09 00:00:00.000000000 Z
11
+ date: 2022-06-10 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A package that distributes Heroicons as a gem, for easy inclusion in
14
14
  Ruby projects.
@@ -26,6 +26,7 @@ files:
26
26
  - Rakefile
27
27
  - heroicons_helper.gemspec
28
28
  - lib/heroicons_helper.rb
29
+ - lib/heroicons_helper/cache.rb
29
30
  - lib/heroicons_helper/data.json
30
31
  - lib/heroicons_helper/icon.rb
31
32
  - lib/heroicons_helper/version.rb
@@ -57,7 +58,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
57
58
  - !ruby/object:Gem::Version
58
59
  version: '0'
59
60
  requirements: []
60
- rubygems_version: 3.3.13
61
+ rubygems_version: 3.3.7
61
62
  signing_key:
62
63
  specification_version: 4
63
64
  summary: Heroicons port for Ruby