railsui_icon 1.0.9 → 1.1.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9e3a5c13ff65a6d4671c5550561a0af226c8df1ea0c992a8ff7e1f67df9d0840
4
- data.tar.gz: e44adae26817aa4fba39c9139f5b1a70d7cfee80d021e2da5eff35fb33201203
3
+ metadata.gz: 14738c847e9ef5bad1d94862883ad07fed5b21426081fcdee645057b4ab14e7f
4
+ data.tar.gz: 0e978fcf987391a6561165be63336e2b43f42598c6092c78ee31cdcdbf8eff4c
5
5
  SHA512:
6
- metadata.gz: 4c9f911dad3a914805c739c63514d31236984770b6083c8dfe8e8e7ff593508801aebe0667cac6880b3b4debb7a3ca7151a39483c219e334d0d5252b1ef70e72
7
- data.tar.gz: 4f137ba098e63dcd10bd808b6ccef8b7b8117b780b4e98fd1d85faf76fcdbacb2f8f2982c40ffbbf033b2d41e25aa3e53d2c68cfef82305433ca823b4a411b57
6
+ metadata.gz: 29e4c13a2e624ad91cb34555d4f8bb7eb0b564dd0fc598134ecb77dcc5b1f1f90c33040c33f4ddd30919a6b3441b9bddf6b8d2e3284d14699f3d95d4edaec8c0
7
+ data.tar.gz: 9bf3cd2a99b18b21cb5c070939e3a62d0ec4517427de5eb3e70f6b1972e5618bda7d314f28eb68074f8b320090ea94e6d9c21f41cc90a7dd940e9d79709508cc
@@ -43,21 +43,15 @@ module RailsuiIcon
43
43
  def render_custom_path(custom_path)
44
44
  return warning if custom_path.blank?
45
45
 
46
+ # Extract file name from custom_path
46
47
  file_name = File.basename(URI.parse(custom_path).path)
47
- asset_path = nil
48
48
 
49
- if defined?(Railsui::Engine) && Railsui::Engine.root.present?
50
- engine_asset_path = Railsui::Engine.root.join("app/assets/images", file_name)
51
- asset_path = engine_asset_path if File.exist?(engine_asset_path)
52
- end
53
-
54
- unless asset_path
55
- app_asset_path = Rails.root.join("app/assets/images", file_name)
56
- asset_path = app_asset_path.to_s if File.exist?(app_asset_path)
57
- end
49
+ # Attempt to find the asset in subdirectories of app/assets/images
50
+ asset_path = find_asset_path(file_name)
58
51
 
59
52
  raise ArgumentError, "Asset path cannot be found" if asset_path.nil?
60
53
 
54
+ # Read the SVG content
61
55
  svg_content = File.read(asset_path)
62
56
  doc = Nokogiri::HTML::DocumentFragment.parse(svg_content)
63
57
  svg = doc.at_css('svg')
@@ -73,6 +67,27 @@ module RailsuiIcon
73
67
  warning
74
68
  end
75
69
 
70
+ private
71
+
72
+ def find_asset_path(file_name)
73
+ # Check in the main app/assets/images directory
74
+ path = Rails.root.join('app/assets/images', file_name)
75
+ return path.to_s if File.exist?(path)
76
+
77
+ # Check in any subdirectories within app/assets/images
78
+ Dir[Rails.root.join('app/assets/images/**/*', file_name)].first
79
+ end
80
+ private
81
+
82
+ def find_asset_path(file_name)
83
+ # Check in the main app/assets/images directory
84
+ path = Rails.root.join('app/assets/images', file_name)
85
+ return path.to_s if File.exist?(path)
86
+
87
+ # Check in any subdirectories within app/assets/images
88
+ Dir[Rails.root.join('app/assets/images/**/*', file_name)].first
89
+ end
90
+
76
91
  def file_path
77
92
  File.join(RailsuiIcon.root, "lib/railsui_icon/icons/#{variant}/#{name}.svg")
78
93
  end
@@ -1,3 +1,3 @@
1
1
  module RailsuiIcon
2
- VERSION = "1.0.9"
2
+ VERSION = "1.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: railsui_icon
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.9
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Leverenz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-08-30 00:00:00.000000000 Z
11
+ date: 2024-09-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails