esvg 2.8.10 → 2.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/esvg/svg.rb +21 -6
- data/lib/esvg/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 24c44ea3e068939c63866e73847817b2ae0b775e
|
4
|
+
data.tar.gz: cbd0c934f3cb92170dee3d4d2fff774e206610bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 131ca0178d2497c234e1af04a8e1e4d95f27e5138bba9ca3bc874c325ca341a47dbb99c77a99fbae7c339881375802e393a6b5c1ddc0eac48e04abde6aeee53a
|
7
|
+
data.tar.gz: 269d4b855617971d605e68db2d43c77037d4ed1ac6e865b204b28c5388e30e5ecaa56043fb74152fa389bf854b7453cfb50d7a3006e4b590464a8b0e43b21b9a
|
data/CHANGELOG.md
CHANGED
data/lib/esvg/svg.rb
CHANGED
@@ -180,14 +180,16 @@ module Esvg
|
|
180
180
|
embed = use_icon(name)
|
181
181
|
embed = embed.sub(/class="(.+?)"/, 'class="\1 '+options[:class]+'"') if options[:class]
|
182
182
|
|
183
|
-
if options[:
|
184
|
-
|
185
|
-
|
186
|
-
else
|
187
|
-
embed = embed.sub(/><use/, %Q{ style="#{options[:style]}"><use})
|
188
|
-
end
|
183
|
+
if options[:color]
|
184
|
+
options[:style] ||= ''
|
185
|
+
options[:style] += ";color:#{options[:color]};"
|
189
186
|
end
|
190
187
|
|
188
|
+
embed = add_attribute(embed, 'style', options[:style], ';')
|
189
|
+
embed = add_attribute(embed, 'fill', options[:fill])
|
190
|
+
embed = add_attribute(embed, 'height', options[:height])
|
191
|
+
embed = add_attribute(embed, 'width', options[:width])
|
192
|
+
|
191
193
|
embed = embed.sub(/><\/svg/, ">#{title(options)}#{desc(options)}</svg")
|
192
194
|
|
193
195
|
if Esvg.rails?
|
@@ -198,6 +200,19 @@ module Esvg
|
|
198
200
|
end
|
199
201
|
end
|
200
202
|
|
203
|
+
def add_attribute(tag, attr, content=nil, append=false)
|
204
|
+
return tag if content.nil?
|
205
|
+
if tag.match(/#{attr}/)
|
206
|
+
if append
|
207
|
+
tag.sub(/#{attr}="(.+?)"/, attr+'="\1'+append+content+'"')
|
208
|
+
else
|
209
|
+
tag.sub(/#{attr}=".+?"/, attr+'="'+content+'"')
|
210
|
+
end
|
211
|
+
else
|
212
|
+
tag.sub(/><use/, %Q{ #{attr}="#{content}"><use})
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
201
216
|
def dimensions(input)
|
202
217
|
dimension = input.scan(/<svg.+(viewBox=["'](.+?)["'])/).flatten
|
203
218
|
viewbox = dimension.first
|
data/lib/esvg/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: esvg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Mathis
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|