vectory 0.4.2 → 0.6.0

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.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/README.adoc +7 -1
  3. data/lib/vectory/capture.rb +115 -0
  4. data/lib/vectory/datauri.rb +1 -1
  5. data/lib/vectory/emf.rb +15 -0
  6. data/lib/vectory/eps.rb +9 -0
  7. data/lib/vectory/ps.rb +9 -0
  8. data/lib/vectory/svg.rb +11 -0
  9. data/lib/vectory/svg_mapping.rb +14 -7
  10. data/lib/vectory/system_call.rb +4 -3
  11. data/lib/vectory/utils.rb +80 -98
  12. data/lib/vectory/vector.rb +4 -0
  13. data/lib/vectory/version.rb +1 -1
  14. data/vectory.gemspec +5 -1
  15. metadata +17 -54
  16. data/bin/vectory +0 -9
  17. data/spec/examples/emf2eps/img.emf +0 -0
  18. data/spec/examples/emf2eps/img.emf.datauri +0 -1
  19. data/spec/examples/emf2eps/ref.eps +0 -88
  20. data/spec/examples/emf2ps/img.emf +0 -0
  21. data/spec/examples/emf2ps/ref.ps +0 -125
  22. data/spec/examples/emf2svg/img.emf +0 -0
  23. data/spec/examples/emf2svg/ref.svg +0 -9
  24. data/spec/examples/eps2emf/img.eps +0 -199
  25. data/spec/examples/eps2emf/img.eps.datauri +0 -1
  26. data/spec/examples/eps2emf/ref.emf +0 -0
  27. data/spec/examples/eps2ps/img.eps +0 -199
  28. data/spec/examples/eps2ps/ref.ps +0 -549
  29. data/spec/examples/eps2svg/img.eps +0 -199
  30. data/spec/examples/eps2svg/ref.svg +0 -173
  31. data/spec/examples/eps_but_svg_extension.svg +0 -199
  32. data/spec/examples/img.jpg +0 -0
  33. data/spec/examples/ps2emf/img.ps +0 -549
  34. data/spec/examples/ps2emf/img.ps.datauri +0 -1
  35. data/spec/examples/ps2emf/ref.emf +0 -0
  36. data/spec/examples/ps2eps/img.ps +0 -549
  37. data/spec/examples/ps2eps/ref.eps +0 -844
  38. data/spec/examples/ps2svg/img.ps +0 -549
  39. data/spec/examples/ps2svg/ref.svg +0 -476
  40. data/spec/examples/svg/action_schemaexpg1.svg +0 -124
  41. data/spec/examples/svg/action_schemaexpg2.svg +0 -124
  42. data/spec/examples/svg/doc-ref.xml +0 -109
  43. data/spec/examples/svg/doc.xml +0 -51
  44. data/spec/examples/svg/doc2-ref.xml +0 -59
  45. data/spec/examples/svg/doc2.xml +0 -28
  46. data/spec/examples/svg2emf/img.svg +0 -1
  47. data/spec/examples/svg2emf/img.svg.datauri +0 -1
  48. data/spec/examples/svg2emf/ref.emf +0 -0
  49. data/spec/examples/svg2eps/img.svg +0 -1
  50. data/spec/examples/svg2eps/ref.eps +0 -88
  51. data/spec/examples/svg2ps/img.svg +0 -1
  52. data/spec/examples/svg2ps/ref.ps +0 -125
  53. data/spec/spec_helper.rb +0 -22
  54. data/spec/support/matchers.rb +0 -51
  55. data/spec/support/text_matcher.rb +0 -63
  56. data/spec/support/vectory_helper.rb +0 -30
  57. data/spec/vectory/cli_spec.rb +0 -215
  58. data/spec/vectory/datauri_spec.rb +0 -181
  59. data/spec/vectory/emf_spec.rb +0 -62
  60. data/spec/vectory/eps_spec.rb +0 -67
  61. data/spec/vectory/file_magic_spec.rb +0 -24
  62. data/spec/vectory/inkscape_converter_spec.rb +0 -43
  63. data/spec/vectory/ps_spec.rb +0 -58
  64. data/spec/vectory/svg_mapping_spec.rb +0 -42
  65. data/spec/vectory/svg_spec.rb +0 -73
  66. data/spec/vectory/vector_spec.rb +0 -97
  67. data/spec/vectory_spec.rb +0 -7
data/spec/spec_helper.rb DELETED
@@ -1,22 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "vectory"
4
- require "tmpdir"
5
- require "rspec/matchers"
6
- require "equivalent-xml"
7
-
8
- Dir["./spec/support/**/*.rb"].sort.each { |file| require file }
9
-
10
- RSpec.configure do |config|
11
- # Enable flags like --only-failures and --next-failure
12
- config.example_status_persistence_file_path = ".rspec_status"
13
-
14
- config.include Vectory::Helper
15
-
16
- # Disable RSpec exposing methods globally on `Module` and `main`
17
- config.disable_monkey_patching!
18
-
19
- config.expect_with :rspec do |c|
20
- c.syntax = :expect
21
- end
22
- end
@@ -1,51 +0,0 @@
1
- RSpec::Matchers.define :be_eps do
2
- match do |actual|
3
- actual.start_with?("%!PS-Adobe-3.0")
4
- end
5
- end
6
-
7
- RSpec::Matchers.define :be_svg do
8
- match do |actual|
9
- actual.include?("<svg")
10
- end
11
- end
12
-
13
- RSpec::Matchers.define :be_equivalent_eps_to do |expected|
14
- match do |actual|
15
- e = sub_time_and_version(expected)
16
- a = sub_time_and_version(actual)
17
-
18
- windows_pattern = /mswin|msys|mingw|cygwin|bccwin|wince|emc/
19
- if RbConfig::CONFIG["host_os"].match?(windows_pattern)
20
- Vectory.ui.debug("Using `TextMatcher`.")
21
-
22
- Vectory::TextMatcher.new(allowed_changed_lines: 60,
23
- allowed_changed_words_in_line: 5).match?(e, a)
24
- else
25
- Vectory.ui.debug("Using a default matcher.")
26
-
27
- values_match?(e, a)
28
- end
29
- end
30
-
31
- def sub_time_and_version(str)
32
- str.sub(/%%CreationDate:(.+)$/, "%%CreationDate:")
33
- .sub(/%%Creator: cairo(.+)$/, "%%Creator: cairo")
34
- end
35
-
36
- diffable
37
- end
38
-
39
- RSpec::Matchers.define :be_equivalent_svg_to do |expected|
40
- match do |actual|
41
- e = sub_unimportant(expected)
42
- a = sub_unimportant(actual)
43
- values_match?(e, a)
44
- end
45
-
46
- def sub_unimportant(str)
47
- str.sub(/sodipodi:docname=(.+)$/, "sodipodi:docname=")
48
- end
49
-
50
- diffable
51
- end
@@ -1,63 +0,0 @@
1
- module Vectory
2
- class TextMatcher
3
- def initialize(allowed_changed_lines: 0,
4
- allowed_changed_words_in_line: 0)
5
- @allowed_changed_lines = allowed_changed_lines
6
- @allowed_changed_words_in_line = allowed_changed_words_in_line
7
- end
8
-
9
- def match?(expected, actual)
10
- expected_lines = expected.split("\n")
11
- actual_lines = actual.split("\n")
12
-
13
- if expected_lines.count < actual_lines.count
14
- Vectory.ui.debug("Lines count differ.")
15
- return false
16
- end
17
-
18
- lines_the_same?(expected_lines, actual_lines)
19
- end
20
-
21
- private
22
-
23
- def lines_the_same?(expected_lines, actual_lines)
24
- results = []
25
- expected_lines
26
- .zip(actual_lines)
27
- .each_with_index do |(expected_line, actual_line), current_line|
28
- results[current_line] = analyze_line(expected_line, actual_line)
29
- end
30
-
31
- print_results(results)
32
-
33
- evaluate_results(results)
34
- end
35
-
36
- def analyze_line(expected, actual)
37
- expected_words = expected.split
38
- actual_words = actual.split
39
-
40
- padded_expected_words = pad_ary(expected_words, actual_words.count)
41
- padded_expected_words.zip(actual_words).count do |e, a|
42
- e != a
43
- end
44
- end
45
-
46
- def pad_ary(ary, target_length)
47
- ary.fill(nil, ary.length...target_length)
48
- end
49
-
50
- def print_results(results)
51
- results.each_with_index do |result, index|
52
- unless result.zero?
53
- Vectory.ui.debug("#{index}: #{result} different word(s).")
54
- end
55
- end
56
- end
57
-
58
- def evaluate_results(results)
59
- results.none? { |changed| changed >= @allowed_changed_words_in_line } &&
60
- results.count { |changed| changed > 0 } < @allowed_changed_lines
61
- end
62
- end
63
- end
@@ -1,30 +0,0 @@
1
- require "nokogiri"
2
- require "tmpdir"
3
-
4
- module Vectory
5
- module Helper
6
- def with_tmp_dir(&block)
7
- Dir.mktmpdir(nil, Vectory.root_path.join("tmp/"), &block)
8
- end
9
-
10
- def in_tmp_dir(&block)
11
- Dir.mktmpdir(nil, Vectory.root_path.join("tmp/")) do |dir|
12
- Dir.chdir(dir, &block)
13
- end
14
- end
15
-
16
- def xmlpp(xml)
17
- xsl = <<~XSL
18
- <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
19
- <xsl:output method="xml" encoding="UTF-8" indent="yes"/>
20
- <xsl:strip-space elements="*"/>
21
- <xsl:template match="/">
22
- <xsl:copy-of select="."/>
23
- </xsl:template>
24
- </xsl:stylesheet>
25
- XSL
26
- Nokogiri::XSLT(xsl).transform(Nokogiri::XML(xml, &:noblanks))
27
- .to_xml(indent: 2, encoding: "UTF-8")
28
- end
29
- end
30
- end
@@ -1,215 +0,0 @@
1
- require "spec_helper"
2
- require "vectory/cli"
3
-
4
- RSpec.describe Vectory::CLI do
5
- before do
6
- # Vectory.ui.level = :debug
7
- Vectory.ui.level = ENV["VECTORY_LOG"] || :fatal
8
- end
9
-
10
- describe "#convert" do
11
- shared_examples "converter" do |format|
12
- it "creates file of a chosen format" do
13
- matcher = case format
14
- when "eps", "ps" then "be_eps"
15
- when "svg" then "be_svg"
16
- else "be_equivalent_to"
17
- end
18
-
19
- with_tmp_dir do |dir|
20
- output = File.join(dir, "output.#{format}")
21
- status = described_class.start(["-f", format, "-o", output, input])
22
- expect(status).to be Vectory::CLI::STATUS_SUCCESS
23
- expect(File.read(output))
24
- .to public_send(matcher, File.read(reference))
25
- end
26
- end
27
- end
28
-
29
- context "eps to ps" do
30
- let(:input) { "spec/examples/eps2ps/img.eps" }
31
- let(:reference) { "spec/examples/eps2ps/ref.ps" }
32
-
33
- it_behaves_like "converter", "ps"
34
- end
35
-
36
- context "eps to svg" do
37
- let(:input) { "spec/examples/eps2svg/img.eps" }
38
- let(:reference) { "spec/examples/eps2svg/ref.svg" }
39
-
40
- it_behaves_like "converter", "svg"
41
- end
42
-
43
- context "eps to emf" do
44
- let(:input) { "spec/examples/eps2emf/img.eps" }
45
- let(:reference) { "spec/examples/eps2emf/ref.emf" }
46
-
47
- it_behaves_like "converter", "emf"
48
- end
49
-
50
- context "ps to eps" do
51
- let(:input) { "spec/examples/ps2eps/img.ps" }
52
- let(:reference) { "spec/examples/ps2eps/ref.eps" }
53
-
54
- it_behaves_like "converter", "eps"
55
- end
56
-
57
- context "ps to emf" do
58
- let(:input) { "spec/examples/ps2emf/img.ps" }
59
- let(:reference) { "spec/examples/ps2emf/ref.emf" }
60
-
61
- it_behaves_like "converter", "emf"
62
- end
63
-
64
- context "ps to svg" do
65
- let(:input) { "spec/examples/ps2svg/img.ps" }
66
- let(:reference) { "spec/examples/ps2svg/ref.svg" }
67
-
68
- it_behaves_like "converter", "svg"
69
- end
70
-
71
- context "svg to emf" do
72
- let(:input) { "spec/examples/svg2emf/img.svg" }
73
- let(:reference) { "spec/examples/svg2emf/ref.emf" }
74
-
75
- it_behaves_like "converter", "emf"
76
- end
77
-
78
- context "svg to eps" do
79
- let(:input) { "spec/examples/svg2eps/img.svg" }
80
- let(:reference) { "spec/examples/svg2eps/ref.eps" }
81
-
82
- it_behaves_like "converter", "eps"
83
- end
84
-
85
- context "svg to ps" do
86
- let(:input) { "spec/examples/svg2ps/img.svg" }
87
- let(:reference) { "spec/examples/svg2ps/ref.ps" }
88
-
89
- it_behaves_like "converter", "ps"
90
- end
91
-
92
- context "emf to svg" do
93
- let(:input) { "spec/examples/emf2svg/img.emf" }
94
- let(:reference) { "spec/examples/emf2svg/ref.svg" }
95
-
96
- it_behaves_like "converter", "svg"
97
- end
98
-
99
- context "emf to eps" do
100
- let(:input) { "spec/examples/emf2eps/img.emf" }
101
- let(:reference) { "spec/examples/emf2eps/ref.eps" }
102
-
103
- it_behaves_like "converter", "eps"
104
- end
105
-
106
- context "emf to ps" do
107
- let(:input) { "spec/examples/emf2ps/img.emf" }
108
- let(:reference) { "spec/examples/emf2ps/ref.ps" }
109
-
110
- it_behaves_like "converter", "ps"
111
- end
112
-
113
- context "jpg to svg" do
114
- let(:input) { "spec/examples/img.jpg" }
115
- let(:format) { "svg" }
116
-
117
- it "returns unsupported-input-format error" do
118
- with_tmp_dir do |dir|
119
- expect(Vectory.ui).to receive(:error)
120
- .with(start_with("Could not detect input format. " \
121
- "Please provide file of the following formats:"))
122
-
123
- output = File.join(dir, "output.#{format}")
124
- status = described_class.start(["-f", format, "-o", output, input])
125
-
126
- expect(status)
127
- .to be Vectory::CLI::STATUS_UNSUPPORTED_INPUT_FORMAT_ERROR
128
- end
129
- end
130
- end
131
-
132
- context "svg to jpg" do
133
- let(:input) { "spec/examples/svg2emf/img.svg" }
134
- let(:format) { "jpg" }
135
-
136
- it "returns unsupported-output-format error" do
137
- with_tmp_dir do |dir|
138
- expect(Vectory.ui).to receive(:error)
139
- .with(start_with("Unsupported output format '#{format}'. " \
140
- "Please choose one of:"))
141
-
142
- output = File.join(dir, "output.#{format}")
143
- status = described_class.start(["-f", format, "-o", output, input])
144
-
145
- expect(status)
146
- .to be Vectory::CLI::STATUS_UNSUPPORTED_OUTPUT_FORMAT_ERROR
147
- end
148
- end
149
- end
150
-
151
- context "inkscape throws ConversionError" do
152
- let(:input) { "spec/examples/eps2emf/img.eps" }
153
- let(:format) { "emf" }
154
-
155
- it "returns conversion error" do
156
- with_tmp_dir do |dir|
157
- expect(Vectory::InkscapeConverter.instance).to receive(:convert)
158
- .and_raise(Vectory::ConversionError)
159
-
160
- output = File.join(dir, "output.#{format}")
161
- status = described_class.start(["-f", format, "-o", output, input])
162
-
163
- expect(status).to be Vectory::CLI::STATUS_CONVERSION_ERROR
164
- end
165
- end
166
- end
167
-
168
- context "got SystemCallError" do
169
- let(:input) { "spec/examples/eps2emf/img.eps" }
170
- let(:format) { "emf" }
171
-
172
- it "returns system-call error" do
173
- with_tmp_dir do |dir|
174
- expect_any_instance_of(Vectory::SystemCall).to receive(:call)
175
- .and_raise(Vectory::SystemCallError)
176
-
177
- output = File.join(dir, "output.#{format}")
178
- status = described_class.start(["-f", format, "-o", output, input])
179
-
180
- expect(status).to be Vectory::CLI::STATUS_SYSTEM_CALL_ERROR
181
- end
182
- end
183
- end
184
-
185
- context "got InkscapeNotFoundError" do
186
- let(:input) { Vectory.root_path.join("spec/examples/eps2emf/img.eps") }
187
- let(:format) { "emf" }
188
-
189
- it "returns inkscape-not-found error" do
190
- in_tmp_dir do
191
- expect(Vectory::InkscapeConverter.instance)
192
- .to receive(:convert).and_raise(Vectory::InkscapeNotFoundError)
193
-
194
- status = described_class.start(["-f", format, input])
195
-
196
- expect(status).to be Vectory::CLI::STATUS_INKSCAPE_NOT_FOUND_ERROR
197
- end
198
- end
199
- end
200
-
201
- context "no output option (it's not required)" do
202
- let(:input) { Vectory.root_path.join("spec/examples/eps2emf/img.eps") }
203
- let(:format) { "emf" }
204
-
205
- it "uses input filename with a new extension and writes to current dir" do
206
- in_tmp_dir do |dir|
207
- status = described_class.start(["-f", format, input])
208
-
209
- expect(Pathname.new(File.join(dir, "img.emf"))).to exist
210
- expect(status).to be Vectory::CLI::STATUS_SUCCESS
211
- end
212
- end
213
- end
214
- end
215
- end
@@ -1,181 +0,0 @@
1
- require "spec_helper"
2
-
3
- RSpec.describe Vectory::Datauri do
4
- describe "::from_vector" do
5
- context "eps" do
6
- let(:input) { "spec/examples/eps2emf/img.eps" }
7
- let(:vector) { Vectory::Eps.from_path(input) }
8
-
9
- it "returns datauri content" do
10
- expect(Vectory::Datauri.from_vector(vector).content)
11
- .to eq File.read("#{input}.datauri")
12
- end
13
- end
14
-
15
- context "ps" do
16
- let(:input) { "spec/examples/ps2emf/img.ps" }
17
- let(:vector) { Vectory::Ps.from_path(input) }
18
-
19
- it "returns datauri content" do
20
- expect(Vectory::Datauri.from_vector(vector).content)
21
- .to eq File.read("#{input}.datauri")
22
- end
23
- end
24
-
25
- context "emf" do
26
- let(:input) { "spec/examples/emf2eps/img.emf" }
27
- let(:vector) { Vectory::Emf.from_path(input) }
28
-
29
- it "returns datauri content" do
30
- expect(Vectory::Datauri.from_vector(vector).content)
31
- .to eq File.read("#{input}.datauri")
32
- end
33
- end
34
-
35
- describe "svg" do
36
- let(:input) { "spec/examples/svg2emf/img.svg" }
37
- let(:vector) { Vectory::Svg.from_path(input) }
38
-
39
- it "returns datauri content" do
40
- expect(Vectory::Datauri.from_vector(vector).content)
41
- .to eq File.read("#{input}.datauri")
42
- end
43
- end
44
- end
45
-
46
- describe "#to_vector" do
47
- context "incorrect data" do
48
- let(:not_a_datauri) { "123abc" }
49
-
50
- it "raises conversion error" do
51
- expect { Vectory::Datauri.new(not_a_datauri).to_vector }
52
- .to raise_error(Vectory::ConversionError)
53
- end
54
- end
55
-
56
- context "eps" do
57
- let(:input) { "spec/examples/eps2emf/img.eps.datauri" }
58
- let(:reference) { "spec/examples/eps2emf/img.eps" }
59
-
60
- it "returns eps content" do
61
- expect(Vectory::Datauri.from_path(input).to_vector.content)
62
- .to eq File.read(reference)
63
- end
64
-
65
- it "returns Eps class" do
66
- expect(Vectory::Datauri.from_path(input).to_vector)
67
- .to be_kind_of(Vectory::Eps)
68
- end
69
- end
70
-
71
- context "emf" do
72
- let(:input) { "spec/examples/emf2eps/img.emf.datauri" }
73
- let(:reference) { "spec/examples/emf2eps/img.emf" }
74
-
75
- it "returns emf content" do
76
- expect(Vectory::Datauri.from_path(input).to_vector.content)
77
- .to eq File.binread(reference)
78
- end
79
-
80
- it "returns Emf class" do
81
- expect(Vectory::Datauri.from_path(input).to_vector)
82
- .to be_kind_of(Vectory::Emf)
83
- end
84
- end
85
-
86
- context "svg" do
87
- let(:input) { "spec/examples/svg2emf/img.svg.datauri" }
88
- let(:reference) { "spec/examples/svg2emf/img.svg" }
89
-
90
- it "returns svg content" do
91
- expect(Vectory::Datauri.from_path(input).to_vector.content)
92
- .to be_equivalent_to File.read(reference)
93
- end
94
-
95
- it "returns Svg class" do
96
- expect(Vectory::Datauri.from_path(input).to_vector)
97
- .to be_kind_of(Vectory::Svg)
98
- end
99
- end
100
- end
101
-
102
- describe "#mime" do
103
- context "incorrect data" do
104
- let(:not_a_datauri) { "123abc" }
105
-
106
- it "raises conversion error" do
107
- expect { described_class.new(not_a_datauri).mime }
108
- .to raise_error(Vectory::ConversionError)
109
- end
110
- end
111
-
112
- context "eps" do
113
- let(:input) { "spec/examples/eps2emf/img.eps.datauri" }
114
-
115
- it "returns eps" do
116
- expect(described_class.from_path(input).mime)
117
- .to eq "application/postscript"
118
- end
119
- end
120
-
121
- context "emf" do
122
- let(:input) { "spec/examples/emf2eps/img.emf.datauri" }
123
-
124
- it "returns emf" do
125
- expect(described_class.from_path(input).mime).to eq "image/emf"
126
- end
127
- end
128
-
129
- context "svg" do
130
- let(:input) { "spec/examples/svg2emf/img.svg.datauri" }
131
-
132
- it "returns svg" do
133
- expect(described_class.from_path(input).mime).to eq "image/svg+xml"
134
- end
135
- end
136
- end
137
-
138
- describe "dimensions (#height / #width)" do
139
- context "incorrect data" do
140
- let(:not_a_datauri) { "123abc" }
141
-
142
- it "raises conversion error" do
143
- expect { described_class.new(not_a_datauri).height }
144
- .to raise_error(Vectory::ConversionError)
145
-
146
- expect { described_class.new(not_a_datauri).width }
147
- .to raise_error(Vectory::ConversionError)
148
- end
149
- end
150
-
151
- context "eps" do
152
- let(:input) { "spec/examples/eps2emf/img.eps.datauri" }
153
-
154
- it "returns height and width" do
155
- expect(described_class.from_path(input).height)
156
- .to eq 707
157
-
158
- expect(described_class.from_path(input).width)
159
- .to eq 649
160
- end
161
- end
162
-
163
- context "emf" do
164
- let(:input) { "spec/examples/emf2eps/img.emf.datauri" }
165
-
166
- it "returns height and width" do
167
- expect(described_class.from_path(input).height).to eq 90
168
- expect(described_class.from_path(input).width).to eq 90
169
- end
170
- end
171
-
172
- context "svg" do
173
- let(:input) { "spec/examples/svg2emf/img.svg.datauri" }
174
-
175
- it "returns height and width" do
176
- expect(described_class.from_path(input).height).to eq 90
177
- expect(described_class.from_path(input).width).to eq 90
178
- end
179
- end
180
- end
181
- end
@@ -1,62 +0,0 @@
1
- require "spec_helper"
2
-
3
- RSpec.describe Vectory::Emf do
4
- describe "#to_svg" do
5
- let(:input) { "spec/examples/emf2svg/img.emf" }
6
- let(:reference) { "spec/examples/emf2svg/ref.svg" }
7
-
8
- it "returns svg content" do
9
- expect(Vectory::Emf.from_path(input).to_svg.content)
10
- .to be_equivalent_to File.read(reference)
11
- end
12
-
13
- it "strips the starting xml tag" do
14
- expect(Vectory::Emf.from_path(input).to_svg.content)
15
- .not_to start_with "<?xml"
16
- end
17
- end
18
-
19
- describe "#to_eps" do
20
- let(:input) { "spec/examples/emf2eps/img.emf" }
21
- let(:reference) { "spec/examples/emf2eps/ref.eps" }
22
-
23
- it "returns eps content" do
24
- expect(Vectory::Emf.from_path(input).to_eps.content)
25
- .to be_equivalent_eps_to File.read(reference)
26
- end
27
- end
28
-
29
- describe "#to_ps" do
30
- let(:input) { "spec/examples/emf2ps/img.emf" }
31
- let(:reference) { "spec/examples/emf2ps/ref.ps" }
32
-
33
- it "returns ps content" do
34
- expect(Vectory::Emf.from_path(input).to_ps.content)
35
- .to be_equivalent_eps_to File.read(reference)
36
- end
37
- end
38
-
39
- describe "#mime" do
40
- let(:input) { "spec/examples/emf2eps/img.emf" }
41
-
42
- it "returns emf" do
43
- expect(described_class.from_path(input).mime).to eq "image/emf"
44
- end
45
- end
46
-
47
- describe "#height" do
48
- let(:input) { "spec/examples/emf2eps/img.emf" }
49
-
50
- it "returns height" do
51
- expect(described_class.from_path(input).height).to eq 90
52
- end
53
- end
54
-
55
- describe "#width" do
56
- let(:input) { "spec/examples/emf2eps/img.emf" }
57
-
58
- it "returns width" do
59
- expect(described_class.from_path(input).width).to eq 90
60
- end
61
- end
62
- end
@@ -1,67 +0,0 @@
1
- require "spec_helper"
2
-
3
- RSpec.describe Vectory::Eps do
4
- shared_examples "converter" do |format|
5
- it "returns content of a chosen format" do
6
- to_format_method = "to_#{format}"
7
- content = described_class.from_path(input)
8
- .public_send(to_format_method)
9
- .content
10
-
11
- matcher = case format
12
- when "eps", "ps" then "be_eps"
13
- when "svg" then "be_svg"
14
- else "be_equivalent_to"
15
- end
16
-
17
- expect(content)
18
- .to public_send(matcher, File.read(reference))
19
- end
20
- end
21
-
22
- describe "#to_ps" do
23
- let(:input) { "spec/examples/eps2ps/img.eps" }
24
- let(:reference) { "spec/examples/eps2ps/ref.ps" }
25
-
26
- it_behaves_like "converter", "ps"
27
- end
28
-
29
- describe "#to_svg" do
30
- let(:input) { "spec/examples/eps2svg/img.eps" }
31
- let(:reference) { "spec/examples/eps2svg/ref.svg" }
32
-
33
- it_behaves_like "converter", "svg"
34
- end
35
-
36
- describe "#to_emf" do
37
- let(:input) { "spec/examples/eps2emf/img.eps" }
38
- let(:reference) { "spec/examples/eps2emf/ref.emf" }
39
-
40
- it_behaves_like "converter", "emf"
41
- end
42
-
43
- describe "#mime" do
44
- let(:input) { "spec/examples/eps2emf/img.eps" }
45
-
46
- it "returns postscript" do
47
- expect(described_class.from_path(input).mime)
48
- .to eq "application/postscript"
49
- end
50
- end
51
-
52
- describe "#height" do
53
- let(:input) { "spec/examples/eps2emf/img.eps" }
54
-
55
- it "returns height" do
56
- expect(described_class.from_path(input).height).to eq 707
57
- end
58
- end
59
-
60
- describe "#width" do
61
- let(:input) { "spec/examples/eps2emf/img.eps" }
62
-
63
- it "returns width" do
64
- expect(described_class.from_path(input).width).to eq 649
65
- end
66
- end
67
- end