railsui_icon 1.0.9 → 1.1.0
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 +4 -4
- data/lib/railsui_icon/icon.rb +18 -10
- data/lib/railsui_icon/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 51a9a0836425ce4622b7d00588f61b5db119a8b3d3c009bf9c029a3edd7281b7
|
4
|
+
data.tar.gz: dc8f4cd8f33e54f772a28e16c517ef79dd00ba41990bf32ae1000c6e473a2778
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66dd52f85985d981f2021a4d4900ecf340aaab5746ade40f030aa29e4ebc01dbad55b66d6042c62c2b7b636d5aa590c03b440bd2ca40a36c41e18285c0bb436a
|
7
|
+
data.tar.gz: 7b001043b1787db770e7532a9687d89d4a2e2901528d1a56f4e9cb2a0b5eff38e11cff854af524d9fc8b8fce36b8e9b29787234b62e6a7bd8a159949a7819265
|
data/lib/railsui_icon/icon.rb
CHANGED
@@ -43,21 +43,18 @@ module RailsuiIcon
|
|
43
43
|
def render_custom_path(custom_path)
|
44
44
|
return warning if custom_path.blank?
|
45
45
|
|
46
|
-
|
47
|
-
|
46
|
+
# Strip leading slashes from custom_path
|
47
|
+
sanitized_path = custom_path.sub(%r{^/}, '')
|
48
48
|
|
49
|
-
|
50
|
-
|
51
|
-
asset_path = engine_asset_path if File.exist?(engine_asset_path)
|
52
|
-
end
|
49
|
+
# Extract file name from sanitized_path
|
50
|
+
file_name = File.basename(URI.parse(sanitized_path).path)
|
53
51
|
|
54
|
-
|
55
|
-
|
56
|
-
asset_path = app_asset_path.to_s if File.exist?(app_asset_path)
|
57
|
-
end
|
52
|
+
# Attempt to find the asset in subdirectories of app/assets/images
|
53
|
+
asset_path = find_asset_path(sanitized_path)
|
58
54
|
|
59
55
|
raise ArgumentError, "Asset path cannot be found" if asset_path.nil?
|
60
56
|
|
57
|
+
# Read the SVG content
|
61
58
|
svg_content = File.read(asset_path)
|
62
59
|
doc = Nokogiri::HTML::DocumentFragment.parse(svg_content)
|
63
60
|
svg = doc.at_css('svg')
|
@@ -73,6 +70,17 @@ module RailsuiIcon
|
|
73
70
|
warning
|
74
71
|
end
|
75
72
|
|
73
|
+
private
|
74
|
+
|
75
|
+
def find_asset_path(file_name)
|
76
|
+
# Check in the main app/assets/images directory
|
77
|
+
path = Rails.root.join('app/assets/images', file_name)
|
78
|
+
return path.to_s if File.exist?(path)
|
79
|
+
|
80
|
+
# Check in any subdirectories within app/assets/images
|
81
|
+
Dir[Rails.root.join('app/assets/images/**/*', file_name)].first
|
82
|
+
end
|
83
|
+
|
76
84
|
def file_path
|
77
85
|
File.join(RailsuiIcon.root, "lib/railsui_icon/icons/#{variant}/#{name}.svg")
|
78
86
|
end
|
data/lib/railsui_icon/version.rb
CHANGED
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
|
4
|
+
version: 1.1.0
|
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-
|
11
|
+
date: 2024-09-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|