sprockets-svg 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/sprockets/svg/png.rb +7 -1
- data/lib/sprockets/svg/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: 20ce718493c386f82a692df0b2164270e68d1646
|
4
|
+
data.tar.gz: edf737ce5bdb7e0a450b07db04a0ca74f1e0723e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6d6859848b0ee077d6a79a4c770168609797e181f3ac351e8fba884daf6a08e9a0b6d48b1cbd1f73788190fb5622204e04626f591c7150a9695aff93fb1be8c
|
7
|
+
data.tar.gz: c8426d7080ef64fc5f41e6178ebf7aac49e844ce23116df4767d32be349b453e2b673e02a2a89f40a923f37bea666dc34a41e5fb6fcba1494a60c33c3b9e080f
|
data/lib/sprockets/svg/png.rb
CHANGED
@@ -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)
|
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.
|
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-
|
11
|
+
date: 2014-04-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|