esvg 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/esvg/svg.rb +12 -10
- 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: 22b09f33bb221a8e3e0ca935a7e1ee2b958d4503
|
4
|
+
data.tar.gz: d0415a87014d73b3363fc29f5879bbb06e81bf55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bc4b112d6b50c3189dfdad7c16493b4c79fddb4dd3671b2b8422d8bc208abd431141736d70ade7a50613de0df1c96d4da6e0a4c5c757228867191027774c01e6
|
7
|
+
data.tar.gz: f3a7e00e22411e3dd4ab823be0077fd0509aae1ce9df3eefae7a2014a74828bb33d30f49c5e6d3d26465bbe365218080047e214d5a21d2f7f54925d34ea62442
|
data/CHANGELOG.md
CHANGED
data/lib/esvg/svg.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
module Esvg
|
2
2
|
class SVG
|
3
|
-
|
4
3
|
attr_accessor :files
|
5
4
|
|
6
5
|
CONFIG = {
|
@@ -21,20 +20,23 @@ module Esvg
|
|
21
20
|
|
22
21
|
def initialize(options={})
|
23
22
|
config(options)
|
24
|
-
|
25
|
-
@mtime = File.mtime(config[:path])
|
26
23
|
read_icons
|
27
24
|
end
|
28
25
|
|
29
26
|
def modified?
|
30
|
-
|
27
|
+
mtime = File.mtime(find_files.last)
|
28
|
+
@mtime != mtime
|
31
29
|
end
|
32
30
|
|
33
31
|
def read_icons
|
34
32
|
@files = {}
|
33
|
+
@mtime = {}
|
35
34
|
@svgs = {}
|
36
35
|
|
37
|
-
|
36
|
+
found = find_files
|
37
|
+
@mtime = File.mtime(found.last)
|
38
|
+
|
39
|
+
found.each do |f|
|
38
40
|
svg = File.read(f)
|
39
41
|
@files[File.basename(f, ".*")] = SvgOptimizer.optimize(svg)
|
40
42
|
end
|
@@ -114,9 +116,9 @@ module Esvg
|
|
114
116
|
end
|
115
117
|
end
|
116
118
|
|
117
|
-
def svg_icon(
|
118
|
-
name = icon_name(
|
119
|
-
%Q{<svg class="#{config[:base_class]} #{name} #{options[:class] || ""}"><use xlink:href="##{name}"/>#{title(options)}#{desc(options)}</svg>}.html_safe
|
119
|
+
def svg_icon(file, options={})
|
120
|
+
name = icon_name(file)
|
121
|
+
%Q{<svg class="#{config[:base_class]} #{name} #{options[:class] || ""}" #{dimensions(@files[file])}><use xlink:href="##{name}"/>#{title(options)}#{desc(options)}</svg>}.html_safe
|
120
122
|
end
|
121
123
|
|
122
124
|
def title(options)
|
@@ -160,7 +162,7 @@ module Esvg
|
|
160
162
|
|
161
163
|
def dimensions(input)
|
162
164
|
dimensions = []
|
163
|
-
%w(viewBox).map do |dimension|
|
165
|
+
%w(viewBox height width).map do |dimension|
|
164
166
|
dimensions << input.scan(/<svg.+(#{dimension}=["'].+?["'])/).flatten.first
|
165
167
|
end
|
166
168
|
dimensions.compact.join(' ')
|
@@ -186,7 +188,7 @@ module Esvg
|
|
186
188
|
def find_files
|
187
189
|
path = File.join(config[:path], '*.svg')
|
188
190
|
|
189
|
-
Dir[path].uniq
|
191
|
+
Dir[path].uniq.sort_by{ |f| File.mtime(f) }
|
190
192
|
end
|
191
193
|
|
192
194
|
end
|
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: 1.1.
|
4
|
+
version: 1.1.2
|
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-06-
|
11
|
+
date: 2015-06-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: svg_optimizer
|