svgeez 0.2.1 → 0.2.2
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 +4 -4
- data/lib/svgeez/sprite_builder.rb +10 -12
- data/lib/svgeez/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 585e1ea2905e2d635f3db935400a604dc5dcc1b3
|
4
|
+
data.tar.gz: c4d2db623624544191db0439a2355ddec476288a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
-
|
41
|
-
|
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
|
-
|
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
|
data/lib/svgeez/version.rb
CHANGED