esvg 4.3.1 → 4.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/esvg/symbol.rb +19 -34
- 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: 051d0f7f2d698b4e1514aac9c3aa45701db91c4e
|
4
|
+
data.tar.gz: 9e6c581c464a7f931992f3598cab24b98ac6e2eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ab57771920663c7b14891349355ef96d19aaf874491d566eea8842865954e4b0bb8914caabbb2548ddade85b4d7ba5184cd43ee3e3f1621a1402cc41e951084
|
7
|
+
data.tar.gz: a2b94f14a41c831b61ab49be31ac9c89cefe7ca59954f92a7ae97cd497e390bf64d83e454d7d5af057ae00a3b8c309434f8aa4219d3e21fad87fcc375cbeac32
|
data/lib/esvg/symbol.rb
CHANGED
@@ -67,36 +67,37 @@ module Esvg
|
|
67
67
|
end
|
68
68
|
|
69
69
|
def use(options={})
|
70
|
-
|
71
|
-
|
72
|
-
|
70
|
+
options.delete(:fallback)
|
71
|
+
content = options.delete(:content) || ''
|
72
|
+
|
73
|
+
if desc = options.delete(:desc)
|
74
|
+
content = "<desc>#{desc}</desc>#{content}"
|
75
|
+
end
|
76
|
+
if title = options.delete(:title)
|
77
|
+
content = "<title>#{title}</title>#{content}"
|
73
78
|
end
|
74
79
|
|
80
|
+
use_attr = {
|
81
|
+
height: options[:height],
|
82
|
+
width: options[:width],
|
83
|
+
scale: options[:scale],
|
84
|
+
}.merge(options.delete(:use) || {})
|
85
|
+
|
75
86
|
svg_attr = {
|
76
|
-
class: [@config[:class], @config[:prefix]+"-"+@name, options
|
87
|
+
class: [@config[:class], @config[:prefix]+"-"+@name, options.delete(:class)].compact.join(' '),
|
77
88
|
viewBox: @size[:viewBox],
|
78
|
-
style: options[:style],
|
79
|
-
fill: options[:fill],
|
80
89
|
role: 'img'
|
81
|
-
}
|
90
|
+
}.merge(options)
|
82
91
|
|
83
92
|
# If user doesn't pass a size or set scale: true
|
84
|
-
if
|
93
|
+
if svg_attr[:width].nil? && svg_attr[:height].nil? && !svg_attr[:scale]
|
85
94
|
svg_attr[:width] = width
|
86
95
|
svg_attr[:height] = height
|
87
|
-
else
|
88
|
-
# Add sizes (nil options will be stripped)
|
89
|
-
svg_attr[:width] = options[:width]
|
90
|
-
svg_attr[:height] = options[:height]
|
91
96
|
end
|
92
97
|
|
93
|
-
|
94
|
-
height: options[:height],
|
95
|
-
width: options[:width],
|
96
|
-
scale: options[:scale],
|
97
|
-
}
|
98
|
+
svg_attr.delete(:scale)
|
98
99
|
|
99
|
-
%Q{<svg #{attributes(svg_attr)}>#{use_tag(use_attr)}#{
|
100
|
+
%Q{<svg #{attributes(svg_attr)}>#{use_tag(use_attr)}#{content}</svg>}
|
100
101
|
end
|
101
102
|
|
102
103
|
def use_tag(options={})
|
@@ -113,22 +114,6 @@ module Esvg
|
|
113
114
|
%Q{<use #{attributes(options)}/>}
|
114
115
|
end
|
115
116
|
|
116
|
-
def title(options)
|
117
|
-
if options[:title]
|
118
|
-
"<title>#{options[:title]}</title>"
|
119
|
-
else
|
120
|
-
''
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
def desc(options)
|
125
|
-
if options[:desc]
|
126
|
-
"<desc>#{options[:desc]}</desc>"
|
127
|
-
else
|
128
|
-
''
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
117
|
def svgo?
|
133
118
|
@config[:optimize] && !!Esvg.node_module('svgo')
|
134
119
|
end
|
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: 4.3.
|
4
|
+
version: 4.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Mathis
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-06-
|
11
|
+
date: 2017-06-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|