mini_magick 5.3.1 → 5.3.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: edcf3d52dfa447f650be4854b37f3352979bb33c52726fe0b48174b9f66d8259
4
- data.tar.gz: 979b3307e4fc554f29d2f0293e1267d968fff48a9f6948c750efae4d5dfd813e
3
+ metadata.gz: ce89fb8c4944594e97e5fa8bb017b17ad827f6dd06df2effd4155b83bf8a4215
4
+ data.tar.gz: 4a130f7c8963143f29bad7432be8d90a68892716dffd479e56edffc45655e0a4
5
5
  SHA512:
6
- metadata.gz: 3d53b6c00fafe8db9142358a3d56daa971e305a3a8a2161a19b8f7893fbaffd6c37bc06de1f2e5f9bd026ae8dd936102af274c118ea70f7107b0645b4fac9e27
7
- data.tar.gz: 4a94a35509be48ae56ba3113778a49ca592569bc0ee711856c50d89f3b4cf277ccf207ff616b20b3e56c305fabb88a2534542ff79937fdf8e2e77e3caf541f01
6
+ metadata.gz: ed544ea77778b627fd58ff4a80665d9560ee67d2fe4d88fc391450bf53f01647f6d515c730d97ffa301619a46334134616dbb5fc1e4f0e40ff09e81355154fbe
7
+ data.tar.gz: 6aaf746cdb19db2f15bbbf3d55fdb839c0df1c9504f1ba8afc8a7b822329fe61c5eac7d6f07337f2735df0c00da089cf46f3e2f387789a46b1c0e41661041469
@@ -31,7 +31,38 @@ module MiniMagick
31
31
  env["MAGICK_TIME_LIMIT"] = timeout.to_s if timeout
32
32
 
33
33
  stdout, stderr, status = log(command.join(" ")) do
34
- Open3.capture3(env, *command, stdin_data: stdin, unsetenv_others: MiniMagick.restricted_env)
34
+ # We would ideally use Open3.capture3, but it doesn't allow us to
35
+ # terminate the command after timing out. We can't rely solely on
36
+ # ImageMagick's own $MAGICK_TIME_LIMIT for this, because it's only
37
+ # checked periodically inside ImageMagick's processing loops, so it
38
+ # can fire too late (or not at all) depending on the operation.
39
+ Open3.popen3(env, *command, unsetenv_others: MiniMagick.restricted_env) do |stdin_io, stdout_io, stderr_io, wait_thread|
40
+ stdin_io.binmode
41
+ stdout_io.binmode
42
+ stderr_io.binmode
43
+
44
+ stdout_reader = Thread.new { stdout_io.read }
45
+ stderr_reader = Thread.new { stderr_io.read }
46
+
47
+ begin
48
+ # Matches how Open3.capture3 detects IO objects.
49
+ if stdin.respond_to?(:readpartial)
50
+ IO.copy_stream(stdin, stdin_io)
51
+ else
52
+ stdin_io.write(stdin)
53
+ end
54
+ rescue Errno::EPIPE
55
+ end
56
+ stdin_io.close
57
+
58
+ if timeout && !wait_thread.join(timeout)
59
+ Process.kill("TERM", wait_thread.pid) rescue nil
60
+ wait_thread.join
61
+ fail MiniMagick::TimeoutError, "`#{command.join(" ")}` has timed out"
62
+ end
63
+
64
+ [stdout_reader.value, stderr_reader.value, wait_thread.value]
65
+ end
35
66
  end
36
67
 
37
68
  [stdout, stderr, status&.exitstatus]
@@ -27,7 +27,7 @@ module MiniMagick
27
27
  # instance of the tool, if block is given, returns the output of the
28
28
  # command.
29
29
  #
30
- def self.new(name, **options)
30
+ def self.new(*args, **options)
31
31
  instance = super
32
32
 
33
33
  if block_given?
@@ -46,7 +46,8 @@ module MiniMagick
46
46
  # @option options [Boolean] :errors Whether to raise errors on non-zero
47
47
  # exit codes.
48
48
  # @option options [Boolean] :warnings Whether to print warnings to stderrr.
49
- # @option options [String] :stdin Content to send to standard input stream.
49
+ # @option options [String, IO] :stdin Content to send to standard input
50
+ # stream, either a string or a readable IO object.
50
51
  # @example
51
52
  # MiniMagick.identify(errors: false) do |identify|
52
53
  # identify.help # returns exit status 1, which would otherwise throw an error
@@ -9,7 +9,7 @@ module MiniMagick
9
9
  module VERSION
10
10
  MAJOR = 5
11
11
  MINOR = 3
12
- TINY = 1
12
+ TINY = 3
13
13
  PRE = nil
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
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: 5.3.1
4
+ version: 5.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Corey Johnson
@@ -99,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
99
99
  version: '0'
100
100
  requirements:
101
101
  - You must have ImageMagick installed
102
- rubygems_version: 3.6.7
102
+ rubygems_version: 4.0.13
103
103
  specification_version: 4
104
104
  summary: Manipulate images with minimal use of memory via ImageMagick
105
105
  test_files: []