sprockets-svg 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sprockets/svg.rb +1 -0
- data/lib/sprockets/svg/png.rb +4 -4
- data/lib/sprockets/svg/server.rb +7 -7
- data/lib/sprockets/svg/version.rb +1 -1
- data/sprockets-svg.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 34c19a6e6008f0f6c26f09c00c13a8bfa0660d40
|
4
|
+
data.tar.gz: 6851edc2b6d76c197f9b1aec20895b73819a9ec1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8615176894845f70698d1ac5955d69b43214f7ddf14bc1afac69cdb364c2a0ec1e9280f0f97340deb172bd25fb23fae40a5a73f75baf84285733d9c297560ed0
|
7
|
+
data.tar.gz: c1b69899478297928607814259b7ed6d1768a63df687b15557cf5baa86078d87f7e7c1632cf63083280795f7c71f6d2664475d347d94ffb05fdda53099bb1d0d
|
data/lib/sprockets/svg.rb
CHANGED
@@ -18,6 +18,7 @@ require_relative 'svg/png'
|
|
18
18
|
require_relative 'svg/server'
|
19
19
|
|
20
20
|
Sprockets::Asset.send(:include, Sprockets::Svg::Png)
|
21
|
+
Sprockets::StaticAsset.send(:include, Sprockets::Svg::Png)
|
21
22
|
Sprockets::Environment.send(:include, Sprockets::Svg::Server)
|
22
23
|
|
23
24
|
require_relative 'svg/railtie' if defined?(Rails)
|
data/lib/sprockets/svg/png.rb
CHANGED
@@ -4,12 +4,12 @@ module Sprockets
|
|
4
4
|
module Svg
|
5
5
|
module Png
|
6
6
|
def self.included(base)
|
7
|
-
base.send(:alias_method, :
|
8
|
-
base.send(:alias_method, :write_to, :
|
7
|
+
base.send(:alias_method, :write_to_without_png_conversion, :write_to)
|
8
|
+
base.send(:alias_method, :write_to, :write_to_with_png_conversion)
|
9
9
|
end
|
10
10
|
|
11
|
-
def
|
12
|
-
|
11
|
+
def write_to_with_png_conversion(path, options={})
|
12
|
+
write_to_without_png_conversion(path, options)
|
13
13
|
if path.ends_with?('.svg')
|
14
14
|
Png.convert(path, path + '.png')
|
15
15
|
end
|
data/lib/sprockets/svg/server.rb
CHANGED
@@ -6,17 +6,17 @@ module Sprockets
|
|
6
6
|
module Server
|
7
7
|
|
8
8
|
def self.included(base)
|
9
|
-
base.send(:alias_method, :
|
10
|
-
base.send(:alias_method, :find_asset, :
|
9
|
+
base.send(:alias_method, :find_asset_without_conversion, :find_asset)
|
10
|
+
base.send(:alias_method, :find_asset, :find_asset_with_conversion)
|
11
11
|
end
|
12
12
|
|
13
|
-
def
|
13
|
+
def find_asset_with_conversion(path, options = {})
|
14
14
|
convert = false
|
15
15
|
if path.ends_with?('.svg.png')
|
16
16
|
path = path.gsub(/\.png/, '')
|
17
17
|
convert = true
|
18
18
|
end
|
19
|
-
asset =
|
19
|
+
asset = find_asset_without_conversion(path, options)
|
20
20
|
|
21
21
|
if convert
|
22
22
|
asset = svg_asset_to_static_png(asset)
|
@@ -30,9 +30,9 @@ module Sprockets
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def svg_asset_to_static_png(svg_asset)
|
33
|
-
|
34
|
-
svg_asset.write_to(
|
35
|
-
::Sprockets::StaticAsset.new(self, svg_asset.logical_path + '.png', Pathname.new(
|
33
|
+
tmp_path = Tempfile.new(['svg2png', '.svg']).path
|
34
|
+
svg_asset.write_to(tmp_path)
|
35
|
+
::Sprockets::StaticAsset.new(self, svg_asset.logical_path + '.png', Pathname.new(tmp_path + '.png'))
|
36
36
|
end
|
37
37
|
|
38
38
|
end
|
data/sprockets-svg.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ['jean.boussier@gmail.com']
|
11
11
|
spec.summary = %q{SVG toolchain for sprockets}
|
12
12
|
spec.description = %q{Minify SVG assets, and optionally convert them to PNG for browser compatibility.}
|
13
|
-
spec.homepage = ''
|
13
|
+
spec.homepage = 'https://github.com/byroot/sprockets-svg'
|
14
14
|
spec.license = 'MIT'
|
15
15
|
|
16
16
|
spec.files = `git ls-files`.split($/)
|
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.2
|
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-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -100,7 +100,7 @@ files:
|
|
100
100
|
- lib/sprockets/svg/server.rb
|
101
101
|
- lib/sprockets/svg/version.rb
|
102
102
|
- sprockets-svg.gemspec
|
103
|
-
homepage:
|
103
|
+
homepage: https://github.com/byroot/sprockets-svg
|
104
104
|
licenses:
|
105
105
|
- MIT
|
106
106
|
metadata: {}
|