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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fb8e640110063dbdfbbafa067e3a46b1cb6312cb
4
- data.tar.gz: f544c21a203eef867fe5579b3737ce9705153662
3
+ metadata.gz: 7f1213db1c8babf0143f05a93ab2e18a677a2207
4
+ data.tar.gz: d149e49116c60aa64adf6335680d1f4676d7e94c
5
5
  SHA512:
6
- metadata.gz: 6144b4bddd911155e0d9b72a6c4ac8869a8c4b98bd6fa932987a55ea1b6ba1c22d71503b26d95205eba09f9c529f9ae5bf21c562910cd1114dbe558aa7f60036
7
- data.tar.gz: c64e3128426de249f0eb22f7f16d59bbf8a8979e0b8903e70147556df114794f5a69c5a4b194fb26478bd66e20575bd4eb4a593dd95c47be63561f9b67dadd91
6
+ metadata.gz: e6a99543e715908e3713fc9a412530f91871365af61db8143c0879816cada1d6b7a82f3d0bc133a38f8b5f34603c1ab0637034a5e581a9071999da39efe662d3
7
+ data.tar.gz: 12b33696959aa397bdfc37f444fd946b248f8a1103f13a869ac06655472568b14da825297f83cc700db031e273005212d7f626e37b7aaaf9b1068161bee70866
@@ -1,5 +1,8 @@
1
1
  # Changelog
2
2
 
3
+ ### 2.8.10 (2016-07-01)
4
+ - Fix: Improved svgo detection; no longer requires svgo_path.
5
+
3
6
  ### 2.8.9 (2016-06-29)
4
7
  - Fix: Now write path is returned after write.
5
8
 
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
@@ -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-cache')
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 = `#{@svgo} '#{path}' -o -`
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 svgo?
439
- @svgo ||= begin
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
- if config[:npm_path] && !File.exist?(npm_path)
444
- abort "NPM Path not found: #{File.expand_path(config[:npm_path])}"
445
- end
439
+ response = Open3.capture3("npm ls #{cmd}")
446
440
 
447
- if File.exist?(local_path)
448
- local_path
449
- elsif `npm ls -g svgo`.match(/empty/).nil?
450
- "svgo"
451
- else
452
- false
453
- end
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
 
@@ -1,3 +1,3 @@
1
1
  module Esvg
2
- VERSION = "2.8.9"
2
+ VERSION = "2.8.10"
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.9
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-06-29 00:00:00.000000000 Z
11
+ date: 2016-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler