mojo_magick 0.5.4 → 0.6.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 +5 -5
- data/.circleci/config.yml +24 -0
- data/.github/dependabot.yml +8 -0
- data/.rubocop-common.yml +99 -0
- data/.rubocop-performance.yml +2 -0
- data/.rubocop-rspec.yml +33 -0
- data/.rubocop.yml +10 -0
- data/.ruby-version +1 -1
- data/Gemfile +6 -1
- data/Gemfile.lock +58 -10
- data/README.md +54 -2
- data/Rakefile +15 -12
- data/examples/animated_gif.rb +11 -14
- data/examples/composite.rb +11 -14
- data/init.rb +1 -3
- data/lib/image_magick/fonts.rb +6 -6
- data/lib/initializers/hash.rb +5 -1
- data/lib/mojo_magick.rb +191 -188
- data/lib/mojo_magick/command_status.rb +11 -0
- data/lib/mojo_magick/errors.rb +5 -0
- data/lib/mojo_magick/font.rb +4 -6
- data/lib/mojo_magick/opt_builder.rb +25 -34
- data/lib/mojo_magick/util/parser.rb +7 -48
- data/lib/mojo_magick/version.rb +1 -1
- data/mojo_magick.gemspec +20 -15
- data/test/fixtures/roll with it.jpg +0 -0
- data/test/font_test.rb +22 -28
- data/test/fonts_test.rb +4 -5
- data/test/mojo_magick_test.rb +282 -283
- data/test/opt_builder_test.rb +56 -49
- data/test/parser_test.rb +17 -18
- data/test/test_helper.rb +7 -5
- metadata +86 -23
- data/lib/image_magick/resource_limits.rb +0 -94
- data/test/resource_limits_test.rb +0 -51
data/test/opt_builder_test.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
class MojoMagickOptBuilderTest < MiniTest::Unit::TestCase
|
1
|
+
require_relative "test_helper"
|
4
2
|
|
3
|
+
class MojoMagickOptBuilderTest < MiniTest::Test
|
5
4
|
# These tests make the assumption that if we call #raw_command with the
|
6
5
|
# correct strings, ImageMagick itself will operate correctly. We're only
|
7
6
|
# verifying that the option builder produces the correct strings
|
@@ -11,36 +10,46 @@ class MojoMagickOptBuilderTest < MiniTest::Unit::TestCase
|
|
11
10
|
end
|
12
11
|
|
13
12
|
def test_annotate
|
14
|
-
@builder.annotate
|
15
|
-
assert_equal
|
13
|
+
@builder.annotate "blah"
|
14
|
+
assert_equal %w[-annotate 0 blah], @builder.to_a
|
16
15
|
end
|
17
16
|
|
18
17
|
def test_annotate_with_escapeable_string
|
19
|
-
@builder.annotate
|
20
|
-
assert_equal
|
18
|
+
@builder.annotate "it's"
|
19
|
+
assert_equal %w[-annotate 0 it's], @builder.to_a
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_annotate_with_full_args
|
23
|
+
@builder.annotate "5 it's"
|
24
|
+
assert_equal %w[-annotate 5 it's], @builder.to_a
|
21
25
|
end
|
22
26
|
|
23
27
|
def test_annotate_with_full_args
|
24
|
-
@builder.annotate
|
25
|
-
assert_equal
|
28
|
+
@builder.annotate "this thing", geometry: 3
|
29
|
+
assert_equal ["-annotate", "3", "this thing"], @builder.to_a
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_annotate_with_full_array_args
|
33
|
+
@builder.annotate "this", "thing", geometry: 3
|
34
|
+
assert_equal ["-annotate", "3", "thisthing"], @builder.to_a
|
26
35
|
end
|
27
36
|
|
28
37
|
def test_option_builder_with_blocks
|
29
38
|
# Passing in basic commands produces a string
|
30
39
|
b = MojoMagick::OptBuilder.new
|
31
40
|
b.image_block do
|
32
|
-
b.background
|
41
|
+
b.background "red"
|
33
42
|
end
|
34
43
|
b.image_block do
|
35
|
-
b.background
|
44
|
+
b.background "blue"
|
36
45
|
end
|
37
|
-
assert_equal '\( -background red \) \( -background blue \)', b.
|
46
|
+
assert_equal ['\(', "-background", "red", '\)', '\(', "-background", "blue", '\)'], b.to_a
|
38
47
|
end
|
39
48
|
|
40
|
-
def test_option_builder_with_hex_colors
|
49
|
+
def test_option_builder_with_hex_colors
|
41
50
|
b = MojoMagick::OptBuilder.new
|
42
|
-
b.background
|
43
|
-
assert_equal
|
51
|
+
b.background "#000000"
|
52
|
+
assert_equal %w[-background #000000], b.to_a
|
44
53
|
end
|
45
54
|
|
46
55
|
def test_option_builder
|
@@ -48,85 +57,83 @@ class MojoMagickOptBuilderTest < MiniTest::Unit::TestCase
|
|
48
57
|
b = MojoMagick::OptBuilder.new
|
49
58
|
b.strip
|
50
59
|
b.repage
|
51
|
-
assert_equal
|
60
|
+
assert_equal "-strip -repage", b.to_s
|
52
61
|
|
53
62
|
# Chaining commands works
|
54
63
|
b = MojoMagick::OptBuilder.new.strip.repage
|
55
|
-
assert_equal
|
64
|
+
assert_equal "-strip -repage", b.to_s
|
56
65
|
|
57
66
|
# Bang (!) indicates the plus version of commands
|
58
67
|
b = MojoMagick::OptBuilder.new
|
59
68
|
b.repage
|
60
69
|
b.repage!
|
61
|
-
assert_equal
|
70
|
+
assert_equal "-repage +repage", b.to_s
|
62
71
|
|
63
72
|
# Accepts raw data as-is
|
64
73
|
b = MojoMagick::OptBuilder.new
|
65
74
|
b.opt1
|
66
|
-
b <<
|
75
|
+
b << "a ! b !"
|
67
76
|
b.opt2
|
68
|
-
assert_equal
|
77
|
+
assert_equal "-opt1 a ! b ! -opt2", b.to_s
|
69
78
|
|
70
79
|
# Treats an array of raw data as different arguments
|
71
80
|
b = MojoMagick::OptBuilder.new
|
72
|
-
b << [
|
73
|
-
assert_equal
|
81
|
+
b << ["leave this data", "alone"]
|
82
|
+
assert_equal "leave this data alone", b.to_s
|
74
83
|
|
75
84
|
# String includes command arguments
|
76
85
|
b = MojoMagick::OptBuilder.new
|
77
|
-
b.extent
|
78
|
-
b.crop
|
79
|
-
assert_equal
|
86
|
+
b.extent "256x256+0+0"
|
87
|
+
b.crop "64x64"
|
88
|
+
assert_equal %w[-extent 256x256+0+0 -crop 64x64], b.to_a
|
80
89
|
|
81
90
|
# Arguments are quoted (doublequote) if appropriate
|
82
91
|
b = MojoMagick::OptBuilder.new
|
83
|
-
b.comment
|
84
|
-
b.comment
|
85
|
-
b.crop
|
86
|
-
assert_equal
|
92
|
+
b.comment "white space"
|
93
|
+
b.comment "w&b"
|
94
|
+
b.crop "6x6^"
|
95
|
+
assert_equal ["-comment", "white space", "-comment", "w&b", "-crop", "6x6^"], b.to_a
|
87
96
|
|
88
97
|
# Existing doublequotes are escaped
|
89
98
|
b = MojoMagick::OptBuilder.new
|
90
99
|
b.comment 'Fred "Woot" Rook'
|
91
|
-
assert_equal
|
100
|
+
assert_equal ["-comment", "Fred \"Woot\" Rook"], b.to_a
|
92
101
|
|
93
102
|
# Multi-argument commands should not be quoted together
|
94
103
|
b = MojoMagick::OptBuilder.new
|
95
|
-
b.set
|
96
|
-
assert_equal
|
104
|
+
b.set "comment", 'the "best" comment'
|
105
|
+
assert_equal ["-set", "comment", "the \"best\" comment"], b.to_a
|
97
106
|
|
98
107
|
# File and files are helper methods
|
99
108
|
b = MojoMagick::OptBuilder.new
|
100
|
-
b.files
|
109
|
+
b.files "source.jpg", "source2.jpg"
|
101
110
|
b.append
|
102
|
-
b.crop
|
103
|
-
b.file
|
104
|
-
assert_equal
|
111
|
+
b.crop "64x64"
|
112
|
+
b.file "dest%d.jpg"
|
113
|
+
assert_equal %w[source.jpg source2.jpg -append -crop 64x64 dest%d.jpg], b.to_a
|
105
114
|
|
106
115
|
# Files are quoted (doublequote) if appropriate
|
107
116
|
b = MojoMagick::OptBuilder.new
|
108
|
-
b.file
|
109
|
-
assert_equal
|
117
|
+
b.file "probably on windows.jpg"
|
118
|
+
assert_equal ["probably on windows.jpg"], b.to_a
|
110
119
|
|
111
120
|
# Blob is a shortcut for the #tempfile helper method
|
112
121
|
b = MojoMagick::OptBuilder.new
|
113
|
-
b.blob
|
122
|
+
b.blob "binary data"
|
114
123
|
filename = b.to_s
|
115
|
-
File.open(filename,
|
116
|
-
assert_equal
|
124
|
+
File.open(filename, "rb") do |f|
|
125
|
+
assert_equal "binary data", f.read
|
117
126
|
end
|
118
127
|
|
119
|
-
#label for text should use 'label:"the string"' if specified
|
120
|
-
[[
|
121
|
-
[
|
122
|
-
[
|
123
|
-
[
|
124
|
-
[
|
125
|
-
|
128
|
+
# label for text should use 'label:"the string"' if specified
|
129
|
+
[%w[mylabel mylabel],
|
130
|
+
['my " label', '"my \" label"'],
|
131
|
+
["Rock it, cuz i said so!", '"Rock it, cuz i said so!"'],
|
132
|
+
["it's like this", '"it\'s like this"'],
|
133
|
+
["\#$%^&*", '"#$%^&*"']].each do |labels|
|
126
134
|
b = MojoMagick::OptBuilder.new
|
127
135
|
b.label labels[0]
|
128
136
|
assert_equal "label:#{labels[1]}", b.to_s
|
129
137
|
end
|
130
|
-
|
131
138
|
end
|
132
139
|
end
|
data/test/parser_test.rb
CHANGED
@@ -1,30 +1,29 @@
|
|
1
|
-
|
1
|
+
require_relative "test_helper"
|
2
2
|
|
3
|
-
IDENTIFY_FONT_RESPONSE
|
3
|
+
IDENTIFY_FONT_RESPONSE = <<~EOFONT
|
4
4
|
|
5
|
-
Font: Zapf-Dingbats
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
5
|
+
Font: Zapf-Dingbats
|
6
|
+
family: Zapf Dingbats
|
7
|
+
style: Normal
|
8
|
+
stretch: Normal
|
9
|
+
weight: 400
|
10
|
+
glyphs: /System/Library/Fonts/ZapfDingbats.ttf
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
12
|
+
Font: Zapfino
|
13
|
+
family: Zapfino
|
14
|
+
style: Italic
|
15
|
+
stretch: Normal
|
16
|
+
weight: 400
|
17
|
+
glyphs: /Library/Fonts/Zapfino.ttf
|
18
18
|
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
class ParserTest < MiniTest::Unit::TestCase
|
20
|
+
EOFONT
|
23
21
|
|
22
|
+
class ParserTest < MiniTest::Test
|
24
23
|
def test_parse_fonts
|
25
24
|
parser = MojoMagick::Util::Parser.new
|
26
25
|
parsed_fonts = parser.parse_fonts(IDENTIFY_FONT_RESPONSE)
|
27
26
|
assert_equal parsed_fonts.length, 2
|
28
|
-
assert_equal parsed_fonts[1].style,
|
27
|
+
assert_equal parsed_fonts[1].style, "Italic"
|
29
28
|
end
|
30
29
|
end
|
data/test/test_helper.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
-
require
|
2
|
-
|
3
|
-
require 'fileutils'
|
4
|
-
require 'tempfile'
|
5
|
-
require 'rspec/expectations'
|
1
|
+
require "simplecov"
|
2
|
+
SimpleCov.start
|
6
3
|
|
4
|
+
require "minitest/autorun"
|
5
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "..", "init"))
|
6
|
+
require "fileutils"
|
7
|
+
require "tempfile"
|
8
|
+
require "rspec/expectations"
|
metadata
CHANGED
@@ -1,57 +1,113 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mojo_magick
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steve Midgley
|
8
8
|
- Elliot Nelson
|
9
9
|
- Jon Rogers
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2021-01-23 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
|
-
name:
|
16
|
+
name: bundler
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - ">="
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: '0'
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: bundle-audit
|
17
31
|
requirement: !ruby/object:Gem::Requirement
|
18
32
|
requirements:
|
19
|
-
- -
|
33
|
+
- - ">="
|
20
34
|
- !ruby/object:Gem::Version
|
21
35
|
version: '0'
|
22
36
|
type: :development
|
23
37
|
prerelease: false
|
24
38
|
version_requirements: !ruby/object:Gem::Requirement
|
25
39
|
requirements:
|
26
|
-
- -
|
40
|
+
- - ">="
|
27
41
|
- !ruby/object:Gem::Version
|
28
42
|
version: '0'
|
29
43
|
- !ruby/object:Gem::Dependency
|
30
|
-
name:
|
44
|
+
name: minitest
|
45
|
+
requirement: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
type: :development
|
51
|
+
prerelease: false
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
57
|
+
- !ruby/object:Gem::Dependency
|
58
|
+
name: rake
|
31
59
|
requirement: !ruby/object:Gem::Requirement
|
32
60
|
requirements:
|
33
|
-
- -
|
61
|
+
- - ">="
|
34
62
|
- !ruby/object:Gem::Version
|
35
63
|
version: '0'
|
36
64
|
type: :development
|
37
65
|
prerelease: false
|
38
66
|
version_requirements: !ruby/object:Gem::Requirement
|
39
67
|
requirements:
|
40
|
-
- -
|
68
|
+
- - ">="
|
41
69
|
- !ruby/object:Gem::Version
|
42
70
|
version: '0'
|
43
71
|
- !ruby/object:Gem::Dependency
|
44
72
|
name: rspec-expectations
|
45
73
|
requirement: !ruby/object:Gem::Requirement
|
46
74
|
requirements:
|
47
|
-
- -
|
75
|
+
- - ">="
|
48
76
|
- !ruby/object:Gem::Version
|
49
77
|
version: '0'
|
50
78
|
type: :development
|
51
79
|
prerelease: false
|
52
80
|
version_requirements: !ruby/object:Gem::Requirement
|
53
81
|
requirements:
|
54
|
-
- -
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
- !ruby/object:Gem::Dependency
|
86
|
+
name: rubocop
|
87
|
+
requirement: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
type: :development
|
93
|
+
prerelease: false
|
94
|
+
version_requirements: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
- !ruby/object:Gem::Dependency
|
100
|
+
name: rubocop-performance
|
101
|
+
requirement: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
type: :development
|
107
|
+
prerelease: false
|
108
|
+
version_requirements: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - ">="
|
55
111
|
- !ruby/object:Gem::Version
|
56
112
|
version: '0'
|
57
113
|
description: Simple Ruby stateless module interface to imagemagick.
|
@@ -62,8 +118,14 @@ executables: []
|
|
62
118
|
extensions: []
|
63
119
|
extra_rdoc_files: []
|
64
120
|
files:
|
65
|
-
- .
|
66
|
-
- .
|
121
|
+
- ".circleci/config.yml"
|
122
|
+
- ".github/dependabot.yml"
|
123
|
+
- ".gitignore"
|
124
|
+
- ".rubocop-common.yml"
|
125
|
+
- ".rubocop-performance.yml"
|
126
|
+
- ".rubocop-rspec.yml"
|
127
|
+
- ".rubocop.yml"
|
128
|
+
- ".ruby-version"
|
67
129
|
- Gemfile
|
68
130
|
- Gemfile.lock
|
69
131
|
- LICENSE.txt
|
@@ -73,9 +135,10 @@ files:
|
|
73
135
|
- examples/composite.rb
|
74
136
|
- init.rb
|
75
137
|
- lib/image_magick/fonts.rb
|
76
|
-
- lib/image_magick/resource_limits.rb
|
77
138
|
- lib/initializers/hash.rb
|
78
139
|
- lib/mojo_magick.rb
|
140
|
+
- lib/mojo_magick/command_status.rb
|
141
|
+
- lib/mojo_magick/errors.rb
|
79
142
|
- lib/mojo_magick/font.rb
|
80
143
|
- lib/mojo_magick/opt_builder.rb
|
81
144
|
- lib/mojo_magick/util/parser.rb
|
@@ -83,13 +146,13 @@ files:
|
|
83
146
|
- mojo_magick.gemspec
|
84
147
|
- test/fixtures/5742.jpg
|
85
148
|
- test/fixtures/not_an_image.jpg
|
149
|
+
- test/fixtures/roll with it.jpg
|
86
150
|
- test/fixtures/zero_byte_image.jpg
|
87
151
|
- test/font_test.rb
|
88
152
|
- test/fonts_test.rb
|
89
153
|
- test/mojo_magick_test.rb
|
90
154
|
- test/opt_builder_test.rb
|
91
155
|
- test/parser_test.rb
|
92
|
-
- test/resource_limits_test.rb
|
93
156
|
- test/test_helper.rb
|
94
157
|
homepage: http://github.com/rcode5/mojo_magick
|
95
158
|
licenses:
|
@@ -109,28 +172,28 @@ require_paths:
|
|
109
172
|
- lib
|
110
173
|
required_ruby_version: !ruby/object:Gem::Requirement
|
111
174
|
requirements:
|
112
|
-
- -
|
175
|
+
- - ">="
|
113
176
|
- !ruby/object:Gem::Version
|
114
|
-
version:
|
177
|
+
version: 2.6.0
|
115
178
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
179
|
requirements:
|
117
|
-
- -
|
180
|
+
- - ">="
|
118
181
|
- !ruby/object:Gem::Version
|
119
182
|
version: '0'
|
120
183
|
requirements: []
|
121
|
-
|
122
|
-
|
123
|
-
signing_key:
|
184
|
+
rubygems_version: 3.0.3
|
185
|
+
signing_key:
|
124
186
|
specification_version: 4
|
125
|
-
summary: mojo_magick-0.
|
187
|
+
summary: mojo_magick-0.6.2
|
126
188
|
test_files:
|
127
189
|
- test/fixtures/5742.jpg
|
128
190
|
- test/fixtures/not_an_image.jpg
|
191
|
+
- test/fixtures/roll with it.jpg
|
129
192
|
- test/fixtures/zero_byte_image.jpg
|
130
193
|
- test/font_test.rb
|
131
194
|
- test/fonts_test.rb
|
132
195
|
- test/mojo_magick_test.rb
|
133
196
|
- test/opt_builder_test.rb
|
134
197
|
- test/parser_test.rb
|
135
|
-
- test/resource_limits_test.rb
|
136
198
|
- test/test_helper.rb
|
199
|
+
...
|