esvg 2.8.9 → 2.8.10
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/CHANGELOG.md +3 -0
- data/exe/esvg +0 -4
- data/lib/esvg/svg.rb +13 -19
- 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: 7f1213db1c8babf0143f05a93ab2e18a677a2207
|
4
|
+
data.tar.gz: d149e49116c60aa64adf6335680d1f4676d7e94c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e6a99543e715908e3713fc9a412530f91871365af61db8143c0879816cada1d6b7a82f3d0bc133a38f8b5f34603c1ab0637034a5e581a9071999da39efe662d3
|
7
|
+
data.tar.gz: 12b33696959aa397bdfc37f444fd946b248f8a1103f13a869ac06655472568b14da825297f83cc700db031e273005212d7f626e37b7aaaf9b1068161bee70866
|
data/CHANGELOG.md
CHANGED
data/exe/esvg
CHANGED
@@ -28,10 +28,6 @@ OptionParser.new do |opts|
|
|
28
28
|
options[:optimize] = svgo
|
29
29
|
end
|
30
30
|
|
31
|
-
opts.on("-n", "--npm", String, "Path to node_modules director") do |path|
|
32
|
-
options[:npm_path] = path
|
33
|
-
end
|
34
|
-
|
35
31
|
opts.on("-v", "--version", "Print version") do |version|
|
36
32
|
options[:version] = true
|
37
33
|
end
|
data/lib/esvg/svg.rb
CHANGED
@@ -9,7 +9,6 @@ module Esvg
|
|
9
9
|
base_class: 'svg-icon',
|
10
10
|
namespace: 'icon',
|
11
11
|
optimize: false,
|
12
|
-
npm_path: false,
|
13
12
|
namespace_before: true,
|
14
13
|
font_size: '1em',
|
15
14
|
verbose: false,
|
@@ -27,7 +26,6 @@ module Esvg
|
|
27
26
|
def initialize(options={})
|
28
27
|
config(options)
|
29
28
|
|
30
|
-
@svgo = nil
|
31
29
|
@last_read = nil
|
32
30
|
@svgs = {}
|
33
31
|
|
@@ -277,7 +275,7 @@ module Esvg
|
|
277
275
|
end
|
278
276
|
|
279
277
|
def write_svg(svg)
|
280
|
-
path = File.join(config[:path], '.esvg-
|
278
|
+
path = File.join((config[:tmp_path] || config[:path]), '.esvg-tmp')
|
281
279
|
write_file path, svg
|
282
280
|
path
|
283
281
|
end
|
@@ -352,9 +350,9 @@ module Esvg
|
|
352
350
|
end
|
353
351
|
|
354
352
|
def optimize(svg)
|
355
|
-
if config[:optimize] && svgo
|
353
|
+
if config[:optimize] && svgo_path = find_node_module('svgo')
|
356
354
|
path = write_svg(svg)
|
357
|
-
svg = `#{
|
355
|
+
svg = `#{svgo_path} '#{path}' -o -`
|
358
356
|
FileUtils.rm(path)
|
359
357
|
end
|
360
358
|
|
@@ -435,22 +433,18 @@ if(typeof(module) != 'undefined') { module.exports = esvg }
|
|
435
433
|
}
|
436
434
|
end
|
437
435
|
|
438
|
-
def
|
439
|
-
|
440
|
-
npm_path = "#{config[:npm_path] || Dir.pwd}/node_modules"
|
441
|
-
local_path = File.join(npm_path, "svgo/bin/svgo")
|
436
|
+
def find_node_module(cmd)
|
437
|
+
require 'open3'
|
442
438
|
|
443
|
-
|
444
|
-
abort "NPM Path not found: #{File.expand_path(config[:npm_path])}"
|
445
|
-
end
|
439
|
+
response = Open3.capture3("npm ls #{cmd}")
|
446
440
|
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
441
|
+
# Check for error
|
442
|
+
if response[1].empty?
|
443
|
+
"$(npm bin)/#{cmd}"
|
444
|
+
|
445
|
+
# Attempt global module path
|
446
|
+
elsif Open3.capture3("npm ls -g #{cmd}")[1].empty?
|
447
|
+
cmd
|
454
448
|
end
|
455
449
|
end
|
456
450
|
|
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.8.
|
4
|
+
version: 2.8.10
|
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-
|
11
|
+
date: 2016-07-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|