svg_optimizer 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of svg_optimizer might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 59eadfc68915559182e085a2f122874d2248fb2a
4
- data.tar.gz: 35e56a3a5085279f4736bac7b8742d2ae677945e
3
+ metadata.gz: 8b58103eace64dcab3740e83ce4a1c328dd6ae06
4
+ data.tar.gz: 68ee27f69693afcd6eab21e0b1ffa57905d1c90b
5
5
  SHA512:
6
- metadata.gz: 632f0a5d429a6f9c5f3696af63adb973034f4d4c8d9c9f78764d21916186948094d5102ed21c867161c19cfc7fa6678e8b06570727eca69cd3a576643d6d26b8
7
- data.tar.gz: c66b98f89cf0dab885246af11ed53ab20eef217f7ce12c900964820811dc399de942531de48f73517e51c5b5c2180cd09b0f24df483f15c48394162f5a7b5697
6
+ metadata.gz: '08e57257160f937494ee265a804e887033e59246d1e5a74b903ba99d8a5b4bc47687fd0e0ad9f1affa4afee2c6aa4bbd0d37c1ef5be1fe2d0036473f83c983b5'
7
+ data.tar.gz: f6b6caf4b7ff9f4ae069d23a1c22267e55cde26d134fc2368ff5f26efabd767e03687a1e1c21060a9313124e12c14809498e9128f2dd72201fb71e1830fc7a57
@@ -9,6 +9,7 @@ module SvgOptimizer
9
9
  ].freeze
10
10
 
11
11
  IDS = LETTERS.dup.concat(LETTERS.combination(2).to_a).freeze
12
+ XLINK_NAMESPACE = "http://www.w3.org/1999/xlink".freeze
12
13
 
13
14
  def ids
14
15
  @ids ||= IDS.dup
@@ -57,8 +58,15 @@ module SvgOptimizer
57
58
  nodes.any?
58
59
  end
59
60
 
61
+ def xlink_namespace?
62
+ xml.root.namespace_definitions.map(&:href).include?(XLINK_NAMESPACE)
63
+ end
64
+
60
65
  def replace_href_references(old_id, new_id)
61
- nodes = xml.css("[href='##{old_id}'], [xlink|href='##{old_id}']")
66
+ scopes = ["[href='##{old_id}']"]
67
+ scopes << "[xlink|href='##{old_id}']" if xlink_namespace?
68
+
69
+ nodes = xml.css(scopes.join(","))
62
70
 
63
71
  nodes.each do |node|
64
72
  node.attributes.map(&:last).each do |attr|
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SvgOptimizer
4
- VERSION = "0.2.1".freeze
4
+ VERSION = "0.2.2".freeze
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: svg_optimizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nando Vieira
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-30 00:00:00.000000000 Z
11
+ date: 2017-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri