dynamic_image 2.1.0 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fd1d723cd97a91199630354e541d2a740aa41bae8ccb07554c1e723096a1b6dc
4
- data.tar.gz: b4f5a8bf26b69da95543cb8885f5add2b72504ea88f83c4097bc1c25a13c622f
3
+ metadata.gz: 814628e7438a06292a2a283be0c88b724a1449327276c2f7ca89656947c690d7
4
+ data.tar.gz: 8ff9d551e13362514d102cae1c04e61d3374689282715911448019c425c12487
5
5
  SHA512:
6
- metadata.gz: e2ba7e0be3c929f9da2b1c7311ae7a246341f081cc8057e8293417a8a73634ec5844d0ce7a691c3d5c771d99924b311c59a2a9b9bf2e2baae84675a3967a8614
7
- data.tar.gz: '08cfc8124f2d6e2bd9d505315b1af7ed87e42ae4ff497a88fafd240e9594943721a6f72e7f196d5dffb1a43a1c8489e9b1b427e4042e149aedcf21a22f0506ba'
6
+ metadata.gz: c52354d7f7100b367b402ea9be16a522872d423e8f1a21f49482bc86eb6223ac9d0c1194979e1d6b49fcfac2352922460aa44395e37adef1ca8cac0c6009e2b6
7
+ data.tar.gz: 94c370ea4a7ab9fe575ae324f8d50844c6600c5a677efcfe03471703130b4eea7613c5e3ac48d894481a1520484efdae2843ef90e36486f114009aa168681d1e
@@ -51,6 +51,24 @@ module DynamicImage
51
51
  @record = model.find(params[:id])
52
52
  end
53
53
 
54
+ def process_and_send(image, options)
55
+ processed_image = DynamicImage::ProcessedImage.new(image, options)
56
+ if process_later?(processed_image, requested_size)
57
+ process_later(image, options, requested_size)
58
+ head 503, retry_after: 10
59
+ else
60
+ send_image(processed_image, requested_size)
61
+ end
62
+ rescue MiniMagick::Error
63
+ process_later(image, options, requested_size)
64
+ raise
65
+ end
66
+
67
+ def process_later(image, options, requested_size)
68
+ DynamicImage::Jobs::CreateVariant
69
+ .perform_later(image, options, requested_size.to_s)
70
+ end
71
+
54
72
  def process_later?(processed_image, size)
55
73
  return false unless DynamicImage.process_later_limit
56
74
 
@@ -68,7 +86,7 @@ module DynamicImage
68
86
  layout: false, locals: { options: options })
69
87
  end
70
88
  format.any(:gif, :jpeg, :jpg, :png, :tiff, :webp) do
71
- send_image(@record, options)
89
+ process_and_send(@record, options)
72
90
  end
73
91
  end
74
92
  end
@@ -90,17 +108,10 @@ module DynamicImage
90
108
  params[:format]
91
109
  end
92
110
 
93
- def send_image(image, options)
94
- processed_image = DynamicImage::ProcessedImage.new(image, options)
95
- if process_later?(processed_image, requested_size)
96
- DynamicImage::Jobs::CreateVariant
97
- .perform_later(image, options, requested_size.to_s)
98
- head 503, retry_after: 10
99
- else
100
- send_data(processed_image.cropped_and_resized(requested_size),
101
- content_type: processed_image.content_type,
102
- disposition: "inline")
103
- end
111
+ def send_image(processed_image, requested_size)
112
+ send_data(processed_image.cropped_and_resized(requested_size),
113
+ content_type: processed_image.content_type,
114
+ disposition: "inline")
104
115
  end
105
116
 
106
117
  def verify_signed_params
@@ -3,11 +3,17 @@
3
3
  module DynamicImage
4
4
  module Errors
5
5
  class Error < StandardError; end
6
+
6
7
  class InvalidImage < DynamicImage::Errors::Error; end
8
+
7
9
  class InvalidHeader < DynamicImage::Errors::Error; end
10
+
8
11
  class InvalidSignature < DynamicImage::Errors::Error; end
12
+
9
13
  class InvalidSizeOptions < DynamicImage::Errors::Error; end
14
+
10
15
  class InvalidTransformation < DynamicImage::Errors::Error; end
16
+
11
17
  class ParameterMissing < DynamicImage::Errors::Error; end
12
18
  end
13
19
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DynamicImage
4
- VERSION = "2.1.0"
4
+ VERSION = "2.1.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynamic_image
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Inge Jørgensen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-13 00:00:00.000000000 Z
11
+ date: 2021-01-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dis
@@ -202,7 +202,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
202
202
  - !ruby/object:Gem::Version
203
203
  version: '0'
204
204
  requirements: []
205
- rubygems_version: 3.1.2
205
+ rubygems_version: 3.1.4
206
206
  signing_key:
207
207
  specification_version: 4
208
208
  summary: Rails plugin that simplifies image uploading and processing