mini_magick 4.2.10 → 4.3.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of mini_magick might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/lib/mini_magick/configuration.rb +3 -13
- data/lib/mini_magick/image.rb +3 -7
- data/lib/mini_magick/image/info.rb +1 -0
- data/lib/mini_magick/tool.rb +29 -83
- data/lib/mini_magick/version.rb +2 -2
- 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: ea018518f84a24383054e66dfd339b36d004f3f0
|
4
|
+
data.tar.gz: 90b0ab0e59ce32941f9d804915ce29ddbbaa247f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12c91ebcb9b87f12a9ee2b55e3857d8b75ef840a5c941ea36cb284c949f026f819b2aeabdcf4172f22a9f656a7db9536ac5223bb7caaa0ce120d100bf0120c0d
|
7
|
+
data.tar.gz: 537dd43b9e236ad805faa32a12d6d30a94c36f761719002c73a145fcf5ca35f8b5028c3e42182e396a6bab8ada521439297a34327cf07e8b2063355926fcd7d0
|
@@ -114,8 +114,6 @@ module MiniMagick
|
|
114
114
|
"processor has to be set to either \"mogrify\" or \"gm\"" \
|
115
115
|
", was set to #{@processor.inspect}"
|
116
116
|
end
|
117
|
-
|
118
|
-
reload_tools
|
119
117
|
end
|
120
118
|
|
121
119
|
def cli
|
@@ -131,20 +129,11 @@ module MiniMagick
|
|
131
129
|
def cli=(value)
|
132
130
|
@cli = value
|
133
131
|
|
134
|
-
|
135
|
-
when :imagemagick
|
136
|
-
Utilities.which("mogrify") or
|
137
|
-
raise MiniMagick::Error, "ImageMagick is not installed or CLI is not found"
|
138
|
-
when :graphicsmagick
|
139
|
-
Utilities.which("gm") or
|
140
|
-
raise MiniMagick::Error, "GraphicsMagick is not installed or CLI is not found"
|
141
|
-
else
|
132
|
+
if not [:imagemagick, :graphicsmagick].include?(@cli)
|
142
133
|
raise ArgumentError,
|
143
134
|
"CLI has to be set to either :imagemagick or :graphicsmagick" \
|
144
135
|
", was set to #{@cli.inspect}"
|
145
136
|
end
|
146
|
-
|
147
|
-
reload_tools
|
148
137
|
end
|
149
138
|
|
150
139
|
def cli_path
|
@@ -155,8 +144,9 @@ module MiniMagick
|
|
155
144
|
@logger || MiniMagick::Logger.new($stdout)
|
156
145
|
end
|
157
146
|
|
147
|
+
# Backwards compatibility
|
158
148
|
def reload_tools
|
159
|
-
MiniMagick
|
149
|
+
warn "[MiniMagick] MiniMagick.reload_tools is deprecated because it is no longer necessary"
|
160
150
|
end
|
161
151
|
|
162
152
|
end
|
data/lib/mini_magick/image.rb
CHANGED
@@ -121,7 +121,7 @@ module MiniMagick
|
|
121
121
|
#
|
122
122
|
def self.attribute(name, key = name.to_s)
|
123
123
|
define_method(name) do |*args|
|
124
|
-
if args.any? &&
|
124
|
+
if args.any? && name != :resolution
|
125
125
|
mogrify { |b| b.send(name, *args) }
|
126
126
|
else
|
127
127
|
@info[key, *args]
|
@@ -387,16 +387,12 @@ module MiniMagick
|
|
387
387
|
#
|
388
388
|
def method_missing(name, *args)
|
389
389
|
mogrify do |builder|
|
390
|
-
|
391
|
-
builder.send(name, *args)
|
392
|
-
else
|
393
|
-
super
|
394
|
-
end
|
390
|
+
builder.send(name, *args)
|
395
391
|
end
|
396
392
|
end
|
397
393
|
|
398
394
|
def respond_to_missing?(method_name, include_private = false)
|
399
|
-
|
395
|
+
true
|
400
396
|
end
|
401
397
|
|
402
398
|
##
|
@@ -103,6 +103,7 @@ module MiniMagick
|
|
103
103
|
details_string = identify(&:verbose)
|
104
104
|
key_stack = []
|
105
105
|
details_string.lines.to_a[1..-1].each_with_object({}) do |line, details_hash|
|
106
|
+
next if line.strip.length.zero?
|
106
107
|
level = line[/^\s*/].length / 2 - 1
|
107
108
|
key_stack.pop until key_stack.size <= level
|
108
109
|
|
data/lib/mini_magick/tool.rb
CHANGED
@@ -15,11 +15,10 @@ module MiniMagick
|
|
15
15
|
#
|
16
16
|
class Tool
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
end
|
18
|
+
CREATION_OPERATORS = %w[
|
19
|
+
xc canvas logo rose gradient radial-gradient plasma tile pattern label
|
20
|
+
caption text
|
21
|
+
]
|
23
22
|
|
24
23
|
##
|
25
24
|
# Aside from classic instantiation, it also accepts a block, and then
|
@@ -173,89 +172,36 @@ module MiniMagick
|
|
173
172
|
end
|
174
173
|
|
175
174
|
##
|
176
|
-
#
|
177
|
-
# for each command-line tool. It uses the `-help` page of a command-line
|
178
|
-
# tool and generates methods from it. It then includes the generated
|
179
|
-
# module into the tool class.
|
175
|
+
# Define creator operator methods
|
180
176
|
#
|
181
|
-
#
|
177
|
+
# mogrify = MiniMagick::Tool.new("mogrify")
|
178
|
+
# mogrify.canvas("khaki")
|
179
|
+
# mogrify.command.join(" ") #=> "mogrify canvas:khaki"
|
182
180
|
#
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
end
|
188
|
-
|
189
|
-
def initialize(tool_name)
|
190
|
-
@tool_name = tool_name
|
191
|
-
reload_methods
|
192
|
-
self.class.instances << self
|
193
|
-
end
|
194
|
-
|
195
|
-
def to_s
|
196
|
-
"OptionMethods(#{@tool_name})"
|
197
|
-
end
|
198
|
-
|
199
|
-
##
|
200
|
-
# Dynamically generates operator methods from the "-help" page.
|
201
|
-
#
|
202
|
-
def reload_methods
|
203
|
-
instance_methods(false).each { |method| undef_method(method) }
|
204
|
-
creation_operator *creation_operators
|
205
|
-
option *cli_options
|
206
|
-
end
|
207
|
-
|
208
|
-
##
|
209
|
-
# Creates method based on command-line option's name.
|
210
|
-
#
|
211
|
-
# mogrify = MiniMagick::Tool.new("mogrify")
|
212
|
-
# mogrify.antialias
|
213
|
-
# mogrify.depth(8)
|
214
|
-
# mogrify.resize("500x500")
|
215
|
-
# mogrify.command.join(" ")
|
216
|
-
# #=> "mogrify -antialias -depth 8 -resize 500x500"
|
217
|
-
#
|
218
|
-
def option(*options)
|
219
|
-
options.each do |option|
|
220
|
-
define_method(option[1..-1].tr('-', '_')) do |*values|
|
221
|
-
self << option
|
222
|
-
self.merge!(values)
|
223
|
-
self
|
224
|
-
end
|
225
|
-
end
|
181
|
+
CREATION_OPERATORS.each do |operator|
|
182
|
+
define_method(operator.gsub('-', '_')) do |value = nil|
|
183
|
+
self << "#{operator}:#{value}"
|
184
|
+
self
|
226
185
|
end
|
186
|
+
end
|
227
187
|
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
end
|
243
|
-
|
244
|
-
def creation_operators
|
245
|
-
%w[xc canvas logo rose gradient radial-gradient
|
246
|
-
plasma tile pattern label caption text]
|
247
|
-
end
|
248
|
-
|
249
|
-
def cli_options
|
250
|
-
tool = MiniMagick::Tool.new(@tool_name)
|
251
|
-
tool << "-help"
|
252
|
-
help_page = tool.call(false, stderr: false)
|
253
|
-
|
254
|
-
cli_options = help_page.scan(/^\s+-[a-z\-]+/).map(&:strip)
|
255
|
-
cli_options << "-gravity" if @tool_name == "mogrify" && MiniMagick.graphicsmagick?
|
256
|
-
cli_options
|
257
|
-
end
|
188
|
+
##
|
189
|
+
# Any undefined method will be transformed into a CLI option
|
190
|
+
#
|
191
|
+
# mogrify = MiniMagick::Tool.new("mogrify")
|
192
|
+
# mogrify.adaptive_blur("...")
|
193
|
+
# mogrify.foo_bar
|
194
|
+
# mogrify.command.join(" ") "mogrify -adaptive-blur ... -foo-bar"
|
195
|
+
#
|
196
|
+
def method_missing(name, *args)
|
197
|
+
option = "-#{name.to_s.tr('_', '-')}"
|
198
|
+
self << option
|
199
|
+
self.merge!(args)
|
200
|
+
self
|
201
|
+
end
|
258
202
|
|
203
|
+
def respond_to_missing?(method_name, include_private = false)
|
204
|
+
true
|
259
205
|
end
|
260
206
|
|
261
207
|
end
|
data/lib/mini_magick/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mini_magick
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Corey Johnson
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date: 2015-
|
16
|
+
date: 2015-09-03 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: rake
|