svgeez 0.2.1 → 0.2.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: a3c37bab4033eb6499bc4d2bdfbdfd11c882de9d
4
- data.tar.gz: a527d2cdf19b23775367fd9395941dd80d3ca1c4
3
+ metadata.gz: 585e1ea2905e2d635f3db935400a604dc5dcc1b3
4
+ data.tar.gz: c4d2db623624544191db0439a2355ddec476288a
5
5
  SHA512:
6
- metadata.gz: 7b7c8277a22af454dda0b22827b370e1abbf6cb5324a4ddee1e1544b3338237a3eb00c01b7fb0bba6b350109548089c6f92431404a5e5204b3bc8e66676a8439
7
- data.tar.gz: b21f4895462d5662266b7f22df1e8a673db0641f031fe6dd50cfce77b458497d6b4bd8cb398c06cd67d4fcaacaec70a1e62b580fc7120777201bd01d1b776f03
6
+ metadata.gz: 80f1c95ee4ae39bb8a528f019db7fb77a1b81b771fe34cfe548c160440083b21bf5fd94551bc55082c6ef9310430b1fd555407a6ba9bb0fede677589aeed064c
7
+ data.tar.gz: 4db1a89309a2f4636e3c7a5c1e3d8791e4613086e902aadc56e82de2dbe7f67867a90b0f1ab56f73350363d31e8e8822ff4ced83a7f64ac3bb984c5cdf51e247
@@ -34,23 +34,21 @@ module Svgeez
34
34
  end
35
35
 
36
36
  def build_destination_file_contents
37
- %{<svg id="#{destination_file_id}" style="display: none;" version="1.1">}.tap do |destination_file_contents|
38
- # Loop over all source files, grabbing their content, and appending to `destination_file_contents`
37
+ destination_file_contents = '<svg>'.tap do |file_contents|
39
38
  source_file_paths.each do |file_path|
40
- file_contents = IO.read(file_path)
41
- pattern = /^<svg.*?(?<viewbox>viewBox=".*?").*?>(?<content>.*?)<\/svg>/m
42
-
43
- if use_svgo?
44
- file_contents = `cat <<EOF | svgo -i - -o -\n#{file_contents}\nEOF`
45
- end
46
-
47
- file_contents.match(pattern) do |matches|
48
- destination_file_contents << %{<symbol id="#{destination_file_id}-#{File.basename(file_path, '.svg').gsub(/['"\s]/, '-').downcase}" #{matches[:viewbox]}>#{matches[:content]}</symbol>}
39
+ IO.read(file_path).match(/^<svg.*?(?<viewbox>viewBox=".*?").*?>(?<content>.*?)<\/svg>/m) do |matches|
40
+ file_contents << %{<symbol id="#{destination_file_id}-#{File.basename(file_path, '.svg').gsub(/['"\s]/, '-')}" #{matches[:viewbox]}>#{matches[:content]}</symbol>}
49
41
  end
50
42
  end
51
43
 
52
- destination_file_contents << '</svg>'
44
+ file_contents << '</svg>'
53
45
  end
46
+
47
+ if use_svgo?
48
+ destination_file_contents = `cat <<EOF | svgo --disable=removeUselessDefs -i - -o -\n#{destination_file_contents}\nEOF`
49
+ end
50
+
51
+ destination_file_contents.insert(4, %{ id="#{destination_file_id}" style="display: none;" version="1.1"})
54
52
  end
55
53
 
56
54
  def destination_file_id
@@ -1,3 +1,3 @@
1
1
  module Svgeez
2
- VERSION = '0.2.1'
2
+ VERSION = '0.2.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: svgeez
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Garber