faw_icon 1.3.0 → 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: 7189106f2aa311399924cabc6ea478078dff205971f60ec3d8146673076ef985
4
- data.tar.gz: '09821b560c5c90eae015410b4244dc32b0a850d34f02bb4d0c40d48c7acf0c59'
3
+ metadata.gz: 21c386a35bb9d5e124131e5ee19bc647d2a603f719a66a50b7158e0a1037b7fa
4
+ data.tar.gz: d19ef48041f3533e5d731670f31fba402140fbd1c3a77242858512377f2bdb03
5
5
  SHA512:
6
- metadata.gz: ae7e75dbccd1b4d7bafb73fb6123ee91c9149247c854deac44d26b80c3c48fa485ad3f3cce3ea8a420675b66f1753d8a19b4c3134b4427145b8c739d3e8b752e
7
- data.tar.gz: 394e6b9687f475e593e7e7142fc7726bb5f25af39145170d49a4c40086e86c578d8e265be25ae313069038160af6a45ab36e9c130ab0a476550e515cf748f519
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,27 +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 (faw_spec = Gem.loaded_specs['faw_files'])
46
- gem_folder = faw_spec.full_gem_path, 'vendor', 'assets', 'images', 'fa', 'raw-svg'
47
- if File.exist? Rails.root.join(gem_folder.join("/"), style, "#{name}.svg")
48
- doc = File.open(Rails.root.join(gem_folder.join("/"), style, "#{name}.svg")) { |f| REXML::Document.new(f) }
49
- svg = doc.root
50
- end
45
+ image_path = FawIcon.configuration.raw_svg_path
51
46
 
52
- return fa_tag(svg, html_props)
47
+ if (faw_spec = Gem.loaded_specs['faw_files'])
48
+ image_path = "#{faw_spec.full_gem_path}/vendor/assets/images/fa/raw-svg"
53
49
  end
54
50
 
55
- if File.exist? Rails.root.join(FawIcon.configuration.raw_svg_path, style, "#{name}.svg")
56
- doc = File.open(Rails.root.join(FawIcon.configuration.raw_svg_path, style, "#{name}.svg")) { |f| REXML::Document.new(f) }
57
- svg = doc.root
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')
58
54
  end
59
55
 
60
56
  fa_tag(svg, html_props)
@@ -62,26 +58,26 @@ module FawIcon
62
58
 
63
59
  def by_sprite(style, name, html_props)
64
60
  if File.exist? Rails.root.join(FawIcon.configuration.svg_sprites_path, "fa-#{style}.svg")
65
- 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>")
66
- 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")
67
63
  end
68
64
 
69
65
  fa_tag(svg, html_props)
70
66
  end
71
67
 
72
68
  def by_js(html_props)
73
- doc = REXML::Document.new('<i>&nbsp;</i>')
69
+ doc = Nokolexbor::HTML('<i>&nbsp;</i>')
74
70
 
75
- fa_tag(doc.root, html_props)
71
+ fa_tag(doc.at_css("i"), html_props)
76
72
  end
77
73
 
78
74
  def fa_tag(svg = nil, html_props)
79
75
  svg = svg_not_found if svg.nil?
80
76
 
81
- svg.attributes['class'] = html_props[:class].join(' ')
82
- svg.attributes['data-fa-transform'] = html_props[:transform] if html_props[:transform]
83
- svg.attributes['data-fa-mask'] = html_props[:mask] if html_props[:mask]
84
- 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]
85
81
 
86
82
  svg.to_s.html_safe
87
83
  end
@@ -102,8 +98,8 @@ module FawIcon
102
98
  end
103
99
 
104
100
  def svg_not_found
105
- doc = REXML::Document.new(FawIcon.configuration.icon_not_found)
101
+ doc = Nokolexbor::HTML(FawIcon.configuration.icon_not_found)
106
102
 
107
- doc.root
103
+ doc.at_css("svg")
108
104
  end
109
105
  end
@@ -1,3 +1,3 @@
1
1
  module FawIcon
2
- VERSION = "1.3.0"
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.3.0
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: 2025-04-25 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