esvg 2.0.2 → 2.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +1 -0
- data/CHANGELOG.md +3 -0
- data/README.md +1 -1
- data/esvg.gemspec +0 -2
- data/exe/esvgo +18 -0
- data/lib/esvg.rb +0 -1
- data/lib/esvg/svg.rb +35 -7
- data/lib/esvg/version.rb +1 -1
- metadata +5 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ce03f468b00edef2311bb762573567e6be4dc210
|
4
|
+
data.tar.gz: b3e999343131df4bf21abaa1f5e69625c09a7bd9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 234e339099f30cb2390e64d2da36b035ab9865b6d6b3667f99a56a380b2236d37171d1b9070aa6c30197c662a0ca2f7923a98dc2be5ec93313e8fe741601ea09
|
7
|
+
data.tar.gz: 0469ebe8dd5d341709e1887a5df5dc8185f6957aa3a55238a15a781af7e904c93ca8da80c322becaa8dad0e7e3508ee5fd8068751297d150e05fdff981616aba
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
data/esvg.gemspec
CHANGED
@@ -18,8 +18,6 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_runtime_dependency "svg_optimizer", "~> 0.0.2"
|
22
|
-
|
23
21
|
spec.add_development_dependency "bundler", "~> 1.10"
|
24
22
|
spec.add_development_dependency "rake", "~> 10.0"
|
25
23
|
spec.add_development_dependency "pry-byebug"
|
data/exe/esvgo
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift(File.expand_path("../lib", File.dirname(__FILE__)))
|
4
|
+
|
5
|
+
require 'optparse'
|
6
|
+
require 'esvg'
|
7
|
+
|
8
|
+
options = {}
|
9
|
+
|
10
|
+
OptionParser.new do |opts|
|
11
|
+
opts.on("-c", "--config PATH", String, "Path to a config file (default: esvg.yml, config/esvg.yml)") do |path|
|
12
|
+
options[:config_file] = path
|
13
|
+
end
|
14
|
+
end.parse!
|
15
|
+
|
16
|
+
options[:path] = ARGV.shift
|
17
|
+
|
18
|
+
esvg = Esvg::SVG.new(options).optimize
|
data/lib/esvg.rb
CHANGED
data/lib/esvg/svg.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
1
3
|
module Esvg
|
2
4
|
class SVG
|
3
5
|
attr_accessor :files
|
@@ -6,6 +8,7 @@ module Esvg
|
|
6
8
|
path: Dir.pwd,
|
7
9
|
base_class: 'svg-icon',
|
8
10
|
namespace: 'icon',
|
11
|
+
optimize: false,
|
9
12
|
namespace_before: true,
|
10
13
|
font_size: '1em',
|
11
14
|
output_path: Dir.pwd,
|
@@ -39,6 +42,12 @@ module Esvg
|
|
39
42
|
@mtime != mtime
|
40
43
|
end
|
41
44
|
|
45
|
+
def svgo?
|
46
|
+
@svgo ||= begin
|
47
|
+
!(`npm ls -g svgo`.match(/empty/) && `npm ls svgo`.match(/emtpy/))
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
42
51
|
def cache_name(input, options)
|
43
52
|
input + options.flatten.join('-')
|
44
53
|
end
|
@@ -52,8 +61,27 @@ module Esvg
|
|
52
61
|
@mtime = File.mtime(found.last)
|
53
62
|
|
54
63
|
found.each do |f|
|
55
|
-
|
56
|
-
|
64
|
+
@files[File.basename(f, ".*")] = read(f)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def read(file)
|
69
|
+
if config[:optimize] && svgo?
|
70
|
+
# Compress files outputting to $STDOUT
|
71
|
+
`svgo #{file} -o -`
|
72
|
+
else
|
73
|
+
File.read(file)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
# Optiize all svg source files
|
78
|
+
#
|
79
|
+
def optimize
|
80
|
+
if svgo?
|
81
|
+
puts "Optimzing #{config[:path]}"
|
82
|
+
system "svgo -f #{config[:path]}"
|
83
|
+
else
|
84
|
+
abort 'To optimize files, please install svgo; `npm install svgo -g`'
|
57
85
|
end
|
58
86
|
end
|
59
87
|
|
@@ -185,13 +213,13 @@ document.addEventListener("DOMContentLoaded", function(event) { esvg.embed() })
|
|
185
213
|
@config ||= begin
|
186
214
|
paths = [options[:config_file], 'config/esvg.yml', 'esvg.yml'].compact
|
187
215
|
|
188
|
-
config =
|
189
|
-
|
190
|
-
|
191
|
-
|
216
|
+
config = CONFIG
|
217
|
+
config.merge!(CONFIG_RAILS) if Esvg.rails?
|
218
|
+
|
219
|
+
if path = paths.select{ |p| File.exist?(p)}.first
|
220
|
+
config.merge!(symbolize_keys(YAML.load(File.read(path) || {})))
|
192
221
|
end
|
193
222
|
|
194
|
-
config.merge!(CONFIG_RAILS) if Esvg.rails?
|
195
223
|
config.merge!(options)
|
196
224
|
|
197
225
|
config[:js_path] ||= File.join(config[:output_path], 'esvg.js')
|
data/lib/esvg/version.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: esvg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Mathis
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: svg_optimizer
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 0.0.2
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: 0.0.2
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: bundler
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -85,6 +71,7 @@ email:
|
|
85
71
|
- brandon@imathis.com
|
86
72
|
executables:
|
87
73
|
- esvg
|
74
|
+
- esvgo
|
88
75
|
extensions: []
|
89
76
|
extra_rdoc_files: []
|
90
77
|
files:
|
@@ -100,6 +87,7 @@ files:
|
|
100
87
|
- bin/setup
|
101
88
|
- esvg.gemspec
|
102
89
|
- exe/esvg
|
90
|
+
- exe/esvgo
|
103
91
|
- lib/esvg.rb
|
104
92
|
- lib/esvg/helpers.rb
|
105
93
|
- lib/esvg/railties.rb
|
@@ -125,7 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
125
113
|
version: '0'
|
126
114
|
requirements: []
|
127
115
|
rubyforge_project:
|
128
|
-
rubygems_version: 2.4.
|
116
|
+
rubygems_version: 2.4.5
|
129
117
|
signing_key:
|
130
118
|
specification_version: 4
|
131
119
|
summary: Embed svgs in HTML or CSS
|