svgo_wrapper 0.0.3 → 0.0.4
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/.ruby-version +1 -1
- data/lib/svgo_wrapper.rb +8 -1
- data/lib/svgo_wrapper/version.rb +1 -1
- data/spec/lib/svgo_wrapper_spec.rb +27 -14
- 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: 3a40cd66303349f126ac7403993e9e49c4d70c03
|
4
|
+
data.tar.gz: c7fd377d1a46ec6441dff7866efa36bb8c81d8eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e6a39d65c1646e5164aa09d54854a23e8173a60219030f145102aca2d4bc44b0d6aa9cda03f39edbbb553ecbe833753753899ea4eef5c8699434a8968512ca3
|
7
|
+
data.tar.gz: f43d1cfafc2ef8ed34f8002b81262ea27dd36011f1403e513c0e5bffe598af38e59580157bad744f1036efba44c2c570b7e6282369e90563c924dd56e3ebd4ef
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.2.0
|
data/lib/svgo_wrapper.rb
CHANGED
@@ -28,7 +28,7 @@ class SvgoWrapper
|
|
28
28
|
raise Error, "Unexpected error (#{e.exitstatus})\n"
|
29
29
|
end
|
30
30
|
|
31
|
-
|
31
|
+
verify_output(output)
|
32
32
|
output
|
33
33
|
end
|
34
34
|
|
@@ -60,4 +60,11 @@ class SvgoWrapper
|
|
60
60
|
(disabled.map {|v| "--disable=#{v}".freeze } +
|
61
61
|
enabled.map {|v| "--enable=#{v}".freeze }).freeze
|
62
62
|
end
|
63
|
+
|
64
|
+
def verify_output(output)
|
65
|
+
return if output =~ /<svg/
|
66
|
+
|
67
|
+
output = "There was a problem optimizing the SVG image with the selected plugins\n" if output.strip.empty?
|
68
|
+
raise ParserError, output
|
69
|
+
end
|
63
70
|
end
|
data/lib/svgo_wrapper/version.rb
CHANGED
@@ -152,25 +152,38 @@ describe SvgoWrapper do
|
|
152
152
|
end
|
153
153
|
end
|
154
154
|
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
155
|
+
describe "`svgo` tool" do
|
156
|
+
context "returns an empty string" do
|
157
|
+
let(:svg_image) { " <svg/>" }
|
158
|
+
|
159
|
+
subject { described_class.new(enable: :transformsWithOnePath).optimize_images_data svg_image }
|
160
|
+
|
161
|
+
it "raises a descriptive exception" do
|
162
|
+
expect { subject }.to raise_error(described_class::ParserError, "There was a problem optimizing the SVG " \
|
163
|
+
"image with the selected plugins\n")
|
163
164
|
end
|
164
165
|
end
|
165
166
|
|
166
|
-
|
167
|
+
context "unexpectedly fails" do
|
168
|
+
let(:mocked_status) do
|
169
|
+
# A mock of Process::Status
|
170
|
+
Object.new.tap do |o|
|
171
|
+
o.instance_eval do
|
172
|
+
define_singleton_method :signaled?, proc { false }
|
173
|
+
define_singleton_method :exitstatus, proc { 123 }
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
167
177
|
|
168
|
-
|
169
|
-
allow(Open4).to receive(:spawn).and_raise(Open4::SpawnError.new("command example", mocked_status))
|
170
|
-
end
|
178
|
+
subject { described_class.new.optimize_images_data svg_image }
|
171
179
|
|
172
|
-
|
173
|
-
|
180
|
+
before(:each) do
|
181
|
+
allow(Open4).to receive(:spawn).and_raise(Open4::SpawnError.new("command example", mocked_status))
|
182
|
+
end
|
183
|
+
|
184
|
+
it "raises a general error" do
|
185
|
+
expect { subject }.to raise_error(described_class::Error, "Unexpected error (123)\n")
|
186
|
+
end
|
174
187
|
end
|
175
188
|
end
|
176
189
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: svgo_wrapper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gabriel de Oliveira
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: open4
|