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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7f1213db1c8babf0143f05a93ab2e18a677a2207
4
- data.tar.gz: d149e49116c60aa64adf6335680d1f4676d7e94c
3
+ metadata.gz: 24c44ea3e068939c63866e73847817b2ae0b775e
4
+ data.tar.gz: cbd0c934f3cb92170dee3d4d2fff774e206610bf
5
5
  SHA512:
6
- metadata.gz: e6a99543e715908e3713fc9a412530f91871365af61db8143c0879816cada1d6b7a82f3d0bc133a38f8b5f34603c1ab0637034a5e581a9071999da39efe662d3
7
- data.tar.gz: 12b33696959aa397bdfc37f444fd946b248f8a1103f13a869ac06655472568b14da825297f83cc700db031e273005212d7f626e37b7aaaf9b1068161bee70866
6
+ metadata.gz: 131ca0178d2497c234e1af04a8e1e4d95f27e5138bba9ca3bc874c325ca341a47dbb99c77a99fbae7c339881375802e393a6b5c1ddc0eac48e04abde6aeee53a
7
+ data.tar.gz: 269d4b855617971d605e68db2d43c77037d4ed1ac6e865b204b28c5388e30e5ecaa56043fb74152fa389bf854b7453cfb50d7a3006e4b590464a8b0e43b21b9a
@@ -1,5 +1,8 @@
1
1
  # Changelog
2
2
 
3
+ ### 2.9.0 (2016-07-18)
4
+ - New: `icon` method accepts fill, color, height, and width
5
+
3
6
  ### 2.8.10 (2016-07-01)
4
7
  - Fix: Improved svgo detection; no longer requires svgo_path.
5
8
 
@@ -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[:style]
184
- if embed.match(/style/)
185
- embed = embed.sub(/style="(.+?)"/, 'style="\1; '+options[:style]+'"')
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
@@ -1,3 +1,3 @@
1
1
  module Esvg
2
- VERSION = "2.8.10"
2
+ VERSION = "2.9.0"
3
3
  end
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.8.10
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-01 00:00:00.000000000 Z
11
+ date: 2016-07-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler