sprockets-svg 0.0.3 → 0.0.4

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: 36f041813c81a15a4b9391a85938133f5cc587dc
4
- data.tar.gz: 6b5119ffe9ac0d0acda91d3ac0a3a973f53ac351
3
+ metadata.gz: 20ce718493c386f82a692df0b2164270e68d1646
4
+ data.tar.gz: edf737ce5bdb7e0a450b07db04a0ca74f1e0723e
5
5
  SHA512:
6
- metadata.gz: cad8f7141df604f4562cc0220ce2c5a59a5947ef626d579832ad6612a0a4883ec6c21d615d21ab0f542043fb9881c4c82f0287df574bc31911798c1702ee169f
7
- data.tar.gz: cfac69ba2ba905a54f35b5e9fc44439950851d3e9f564bf20d811d1d8650aa41ddab4c36f64aedcdb71836f8659385ba3605977e5fcf8b34ee1fa2cee38b4012
6
+ metadata.gz: a6d6859848b0ee077d6a79a4c770168609797e181f3ac351e8fba884daf6a08e9a0b6d48b1cbd1f73788190fb5622204e04626f591c7150a9695aff93fb1be8c
7
+ data.tar.gz: c8426d7080ef64fc5f41e6178ebf7aac49e844ce23116df4767d32be349b453e2b673e02a2a89f40a923f37bea666dc34a41e5fb6fcba1494a60c33c3b9e080f
@@ -10,12 +10,18 @@ module Sprockets
10
10
 
11
11
  def write_to_with_png_conversion(path, options={})
12
12
  write_to_without_png_conversion(path, options)
13
- if path.ends_with?('.svg')
13
+ if path.ends_with?('.svg') && image?(path)
14
14
  Png.convert(path, path + '.png')
15
15
  end
16
16
  nil
17
17
  end
18
18
 
19
+ def image?(path)
20
+ document = Nokogiri::XML(File.read(path))
21
+ svg = document.css('svg')
22
+ svg.attribute('height') && svg.attribute('width')
23
+ end
24
+
19
25
  # TODO: integrate svgo instead: https://github.com/svg/svgo
20
26
  # See https://github.com/lautis/uglifier on how to integrate a npm package as a gem.
21
27
  def self.convert(svg_path, png_path)
@@ -1,5 +1,5 @@
1
1
  module Sprockets
2
2
  module Svg
3
- VERSION = '0.0.3'
3
+ VERSION = '0.0.4'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sprockets-svg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean Boussier
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-14 00:00:00.000000000 Z
11
+ date: 2014-04-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler