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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bc49e968dc9968f8fe72bae00d4efcbb8e1e4e52
4
- data.tar.gz: 428208a9c3c9426a199361c225e7e6625234ac40
3
+ metadata.gz: 22b09f33bb221a8e3e0ca935a7e1ee2b958d4503
4
+ data.tar.gz: d0415a87014d73b3363fc29f5879bbb06e81bf55
5
5
  SHA512:
6
- metadata.gz: 9f59e82c496aeed8819c3e2a8e953d17b682d5f99ae578a9dd576fbc3c875ab76d0db3a0f7988c9a9112759a282f1c8912c3745769285332328a7fa7802e61e2
7
- data.tar.gz: 26ba8e38c78eb82e7861a847bc31a5f0601dcf231ea7fb99cee4befc99062887e8d65167b5365eb1776b5fef45a43c10dfefc113cbe11f220c3ad07ddd45696b
6
+ metadata.gz: bc4b112d6b50c3189dfdad7c16493b4c79fddb4dd3671b2b8422d8bc208abd431141736d70ade7a50613de0df1c96d4da6e0a4c5c757228867191027774c01e6
7
+ data.tar.gz: f3a7e00e22411e3dd4ab823be0077fd0509aae1ce9df3eefae7a2014a74828bb33d30f49c5e6d3d26465bbe365218080047e214d5a21d2f7f54925d34ea62442
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ### 1.1.2 (2015-06-30)
4
+
5
+ - Fix: Measuring modified time works better now.
6
+ - Fix: SVGs keep their dimensions when embedded.
7
+
3
8
  ### 1.1.1 (2015-06-29)
4
9
 
5
10
  - Fix: Moved methods from Esvg module to SVG class. Oops.
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
- @mtime != File.mtime(config[:path])
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
- find_files.each do |f|
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(name, options={})
118
- name = icon_name(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
@@ -1,3 +1,3 @@
1
1
  module Esvg
2
- VERSION = "1.1.1"
2
+ VERSION = "1.1.2"
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: 1.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-29 00:00:00.000000000 Z
11
+ date: 2015-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: svg_optimizer