esvg 2.7.0 → 2.8.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 +4 -0
- data/lib/esvg.rb +4 -0
- data/lib/esvg/svg.rb +28 -13
- 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: 63077454777a28a3ddee5f9aca2f4ea000a3f131
|
4
|
+
data.tar.gz: 3d9343e86d77843bcfb4806c4bcd8e2c8aa2c7fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c43ee0a52b09ddf416392e6d5098b6039b99ddeca46f9d81c1d1593834f58f29a866a41272a0aeef647b2c6b99d843eb6f0137dfca528cd0d16c46a05d32d23
|
7
|
+
data.tar.gz: 1c3e29da770342ea03243064a1da60ab3256ae2e2251b84f04f546e3e2ea06e08bfab9e56a03cf6b4ceaa39eebc08fc23e518dc21e22ce1765935a977b6dbe86
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
### 2.8.0 (2015-12-16)
|
4
|
+
- New: Added exist? method to ask if an icon exists.
|
5
|
+
- New: `fallback` option allows svgs to provide a fallback icon if one is not found.
|
6
|
+
|
3
7
|
### 2.7.0 (2015-12-08)
|
4
8
|
- New: Now option style can append to inlines styles
|
5
9
|
|
data/lib/esvg.rb
CHANGED
data/lib/esvg/svg.rb
CHANGED
@@ -146,17 +146,29 @@ module Esvg
|
|
146
146
|
end
|
147
147
|
|
148
148
|
def svg_icon(file, options={})
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
embed = embed.sub(/style="(.+?)"/, 'style="\1; '+options[:style]+'"')
|
149
|
+
|
150
|
+
if !exist?(file)
|
151
|
+
if fallback = options.delete(:fallback)
|
152
|
+
svg_icon(fallback, options)
|
154
153
|
else
|
155
|
-
|
154
|
+
raise "no svg named '#{get_alias(file)}' exists at #{config[:path]}"
|
156
155
|
end
|
156
|
+
else
|
157
|
+
|
158
|
+
embed = use_icon(file)
|
159
|
+
|
160
|
+
embed.sub!(/class="(.+?)"/, 'class="\1 '+options[:class]+'"') if options[:class]
|
161
|
+
|
162
|
+
if options[:style]
|
163
|
+
if embed.match(/style/)
|
164
|
+
embed.sub!(/style="(.+?)"/, 'style="\1; '+options[:style]+'"')
|
165
|
+
else
|
166
|
+
embed.sub!(/><use/, %Q{ style="#{options[:style]}"><use})
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
embed.sub(/><\/svg/, ">#{title(options)}#{desc(options)}</svg")
|
157
171
|
end
|
158
|
-
embed = embed.sub(/><\/svg/, ">#{title(options)}#{desc(options)}</svg")
|
159
|
-
embed
|
160
172
|
end
|
161
173
|
|
162
174
|
def dimensions(input)
|
@@ -171,13 +183,16 @@ module Esvg
|
|
171
183
|
|
172
184
|
def use_icon(name)
|
173
185
|
name = get_alias(name)
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
186
|
+
svgs[name][:use]
|
187
|
+
end
|
188
|
+
|
189
|
+
def exist?(name)
|
190
|
+
name = get_alias(name)
|
191
|
+
!svgs[name].nil?
|
179
192
|
end
|
180
193
|
|
194
|
+
alias_method :exists?, :exist?
|
195
|
+
|
181
196
|
def classname(name)
|
182
197
|
name = dasherize(name)
|
183
198
|
if config[:namespace_before]
|
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.8.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: 2015-12-
|
11
|
+
date: 2015-12-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|