faw_icon 1.2.1 → 1.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: de5480bbb14198a0b481e2ae8096b42825adcda417b12ab7903078bf179d7755
4
- data.tar.gz: 5b962f280976cf45fa5b957787a8af52cf2c3460e606c62a1ed654a2e13800fd
3
+ metadata.gz: 21c386a35bb9d5e124131e5ee19bc647d2a603f719a66a50b7158e0a1037b7fa
4
+ data.tar.gz: d19ef48041f3533e5d731670f31fba402140fbd1c3a77242858512377f2bdb03
5
5
  SHA512:
6
- metadata.gz: 03b1b0464f81aeab522848538dd9bd11d633b34826d7f3b86d2bd19bada259d6e65aea6958f7cbc3d1e200da5381f6f59817180297ac226c3c470e0e07a1cdfe
7
- data.tar.gz: 4bc8ce452b76ddee9999007093cbd01be9e3bc695542eebc90f1a23b98f6e08cbbfd3d9d97b42cf60abb8416f8728410ae28e8ff03d1da03e07550cb1fc269b3
6
+ metadata.gz: 36fe80a571302bc4662adb591638f64be0d02227058e4e8ec454315c8f3a9c08ce4256f4ecbb20f3e6135ae35857864a400a3d78646d104fbbe6fb7834c1ae48
7
+ data.tar.gz: 87ee7cb28b3cff7bed85ec792068bf959565d6d764d7e72e5587e4c21411fd199e4233ae2fe7d471796678eeb69f9bb2c2771532267b047eb763437263db821a
data/Gemfile.lock CHANGED
@@ -1,11 +1,13 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- faw_icon (1.2.1)
4
+ faw_icon (1.4.0)
5
+ nokolexbor (~> 0.6.0)
5
6
 
6
7
  GEM
7
8
  remote: https://rubygems.org/
8
9
  specs:
10
+ nokolexbor (0.6.0-x86_64-linux)
9
11
  rake (10.5.0)
10
12
 
11
13
  PLATFORMS
data/faw_icon.gemspec CHANGED
@@ -21,6 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
22
  spec.require_paths = ["lib"]
23
23
 
24
+ spec.add_runtime_dependency "nokolexbor", "~> 0.6.0"
24
25
  spec.add_development_dependency "bundler", "~> 2.2"
25
26
  spec.add_development_dependency "rake", "~> 10.0"
26
27
  # spec.required_ruby_version = '>= 2.5.0'
@@ -1,6 +1,6 @@
1
1
  require "faw_icon/version"
2
2
  require "faw_icon/configuration"
3
- require "rexml/document"
3
+ require "nokolexbor"
4
4
 
5
5
  module FawIcon
6
6
  def faw_icon(style, name, options = {})
@@ -34,17 +34,23 @@ module FawIcon
34
34
  icons = JSON.parse(File.read(FawIcon.configuration.icons_path))
35
35
 
36
36
  if icons[name].present? && icons[name]['svg'][style].present?
37
- doc = REXML::Document.new(icons[name]['svg'][style]['raw'])
38
- svg = doc.root
37
+ doc = Nokolexbor::HTML(icons[name]['svg'][style]['raw'])
38
+ svg = doc.at_css("svg")
39
39
  end
40
40
 
41
41
  fa_tag(svg, html_props)
42
42
  end
43
43
 
44
44
  def by_raw(style, name, html_props)
45
- if File.exist? Rails.root.join(FawIcon.configuration.raw_svg_path, style, "#{name}.svg")
46
- doc = File.open(Rails.root.join(FawIcon.configuration.raw_svg_path, style, "#{name}.svg")) { |f| REXML::Document.new(f) }
47
- svg = doc.root
45
+ image_path = FawIcon.configuration.raw_svg_path
46
+
47
+ if (faw_spec = Gem.loaded_specs['faw_files'])
48
+ image_path = "#{faw_spec.full_gem_path}/vendor/assets/images/fa/raw-svg"
49
+ end
50
+
51
+ if File.exist? Rails.root.join(image_path, style, "#{name}.svg")
52
+ doc = File.open(Rails.root.join(image_path, style, "#{name}.svg")) { |f| Nokolexbor::HTML(f) }
53
+ svg = doc.at_css('svg')
48
54
  end
49
55
 
50
56
  fa_tag(svg, html_props)
@@ -52,26 +58,26 @@ module FawIcon
52
58
 
53
59
  def by_sprite(style, name, html_props)
54
60
  if File.exist? Rails.root.join(FawIcon.configuration.svg_sprites_path, "fa-#{style}.svg")
55
- doc = REXML::Document.new("<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\"><use href=\"/fa5/svg-sprites/fa-#{style}.svg##{name}\"></use></svg>")
56
- svg = doc.root
61
+ doc = Nokolexbor::HTML("<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\"><use href=\"/fa5/svg-sprites/fa-#{style}.svg##{name}\"></use></svg>")
62
+ svg = doc.at_css("svg")
57
63
  end
58
64
 
59
65
  fa_tag(svg, html_props)
60
66
  end
61
67
 
62
68
  def by_js(html_props)
63
- doc = REXML::Document.new('<i>&nbsp;</i>')
69
+ doc = Nokolexbor::HTML('<i>&nbsp;</i>')
64
70
 
65
- fa_tag(doc.root, html_props)
71
+ fa_tag(doc.at_css("i"), html_props)
66
72
  end
67
73
 
68
74
  def fa_tag(svg = nil, html_props)
69
75
  svg = svg_not_found if svg.nil?
70
76
 
71
- svg.attributes['class'] = html_props[:class].join(' ')
72
- svg.attributes['data-fa-transform'] = html_props[:transform] if html_props[:transform]
73
- svg.attributes['data-fa-mask'] = html_props[:mask] if html_props[:mask]
74
- svg.attributes['data-source-type'] = html_props[:source_type] if html_props[:source_type]
77
+ svg['class'] = html_props[:class].join(' ')
78
+ svg['data-fa-transform'] = html_props[:transform] if html_props[:transform]
79
+ svg['data-fa-mask'] = html_props[:mask] if html_props[:mask]
80
+ svg['data-source-type'] = html_props[:source_type] if html_props[:source_type]
75
81
 
76
82
  svg.to_s.html_safe
77
83
  end
@@ -92,8 +98,8 @@ module FawIcon
92
98
  end
93
99
 
94
100
  def svg_not_found
95
- doc = REXML::Document.new(FawIcon.configuration.icon_not_found)
101
+ doc = Nokolexbor::HTML(FawIcon.configuration.icon_not_found)
96
102
 
97
- doc.root
103
+ doc.at_css("svg")
98
104
  end
99
105
  end
@@ -1,3 +1,3 @@
1
1
  module FawIcon
2
- VERSION = "1.2.1"
2
+ VERSION = "1.4.0"
3
3
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: faw_icon
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - alexwebgr
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-01-20 00:00:00.000000000 Z
11
+ date: 2025-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: nokolexbor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.6.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.6.0
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -78,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
78
92
  - !ruby/object:Gem::Version
79
93
  version: '0'
80
94
  requirements: []
81
- rubygems_version: 3.2.3
95
+ rubygems_version: 3.3.7
82
96
  signing_key:
83
97
  specification_version: 4
84
98
  summary: A simple helper for Font-Awesome 5 using raw SVG and SVG-with-JS