imgproxy 2.0.1 → 2.1.0

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: cfcf61128475771936852251e3b3525cfd88b4dd37587a624fde29bc23a3f1cd
4
- data.tar.gz: 965ad9ac3c19c898481356e12232f1c78998b64dda684ff7928da076d50965cb
3
+ metadata.gz: f30666a2a3a8a1097534749a93ca6d53492982f59f43e0fa91553f19957535d8
4
+ data.tar.gz: c0ac3bddc82a2e515b728107ad1bc58fedac3eb8edca76532a3f23d8b8def706
5
5
  SHA512:
6
- metadata.gz: bd23c1f227b35ad0401955ca29ab3c36ddb9fc2070097983731416cdf409d2292b9c3d9157fe4e3e913d0da525f66397922f4997e4974f665d22ec752b338c8f
7
- data.tar.gz: 8338e73961d8e6c00e37deb55223c1aa3760d1ded5094afabfb7461a0cad7b44cf2f1a1d98dd9d9a59ee5bbe2c98067ae183e7b9f0765b60110d165068278bca
6
+ metadata.gz: 3c242a4e67d4e726ebae337e9264454ad223e2fbd31e8f5655cd8a47288e6ab8ee035bebbd0d99dbe17aa9de75ed3fc098cedae1acc7501ac5ea6e3dc43feea7
7
+ data.tar.gz: ccd34093cb91dbe50d1a59139db8c94da96fe0f6dba780ae1c1538ccb91646de982055aad509adceb6a3eb6af63f9a2f9af74450ce00aaa6bb0f00439b92acae
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  <img align="right" width="200" height="200" title="imgproxy logo"
4
4
  src="https://cdn.rawgit.com/DarthSim/imgproxy/master/logo.svg">
5
5
 
6
- [![CircleCI branch](https://img.shields.io/circleci/project/github/imgproxy/imgproxy.rb/master.svg?style=for-the-badge)](https://circleci.com/gh/imgproxy/imgproxy.rb) [![Gem](https://img.shields.io/gem/v/imgproxy.svg?style=for-the-badge)](https://rubygems.org/gems/imgproxy) [![rubydoc.org](https://img.shields.io/badge/rubydoc-reference-blue.svg?style=for-the-badge)](https://www.rubydoc.info/gems/imgproxy)
6
+ [![GH Test](https://img.shields.io/github/workflow/status/imgproxy/imgproxy.rb/Test?label=Test&logo=github&style=for-the-badge)](https://github.com/imgproxy/imgproxy.rb/actions) [![GH Lint](https://img.shields.io/github/workflow/status/imgproxy/imgproxy.rb/Lint?label=Lint&logo=github&style=for-the-badge)](https://github.com/imgproxy/imgproxy.rb/actions) [![Gem](https://img.shields.io/gem/v/imgproxy.svg?style=for-the-badge)](https://rubygems.org/gems/imgproxy) [![rubydoc.org](https://img.shields.io/badge/rubydoc-reference-blue.svg?style=for-the-badge)](https://www.rubydoc.info/gems/imgproxy)
7
7
 
8
8
  **[imgproxy](https://github.com/imgproxy/imgproxy)** is a fast and secure standalone server for resizing and converting remote images. The main principles of imgproxy are simplicity, speed, and security. It is a Go application, ready to be installed and used in any Unix environment—also ready to be containerized using Docker.
9
9
 
@@ -235,6 +235,8 @@ builder.url_for("http://images.example.com/images/image2.jpg")
235
235
  - [auto_rotate](https://docs.imgproxy.net/#/generating_the_url_advanced?id=auto-rotate)
236
236
  - [filename](https://docs.imgproxy.net/#/generating_the_url_advanced?id=filename)
237
237
  - [format](https://docs.imgproxy.net/#/generating_the_url_advanced?id=format)
238
+ - [return_attachment](https://docs.imgproxy.net/#/generating_the_url_advanced?id=return-attachment)
239
+ - [expires](https://docs.imgproxy.net/#/generating_the_url?id=expires)
238
240
 
239
241
  _See [imgproxy URL format guide](https://docs.imgproxy.net/#/generating_the_url_advanced?id=processing-options) for more info._
240
242
 
@@ -64,12 +64,16 @@ module Imgproxy
64
64
  auto_rotate: Imgproxy::OptionsCasters::Bool,
65
65
  filename: Imgproxy::OptionsCasters::String,
66
66
  format: Imgproxy::OptionsCasters::String,
67
+ return_attachment: Imgproxy::OptionsCasters::Bool,
68
+ expires: Imgproxy::OptionsCasters::Integer,
67
69
  }.freeze
68
70
 
69
71
  META = %i[size resize adjust].freeze
70
72
 
71
73
  # @param options [Hash] raw processing options
72
74
  def initialize(options)
75
+ super()
76
+
73
77
  # Options order hack: initialize known and meta options with nil value to preserve order
74
78
  CASTERS.each_key { |n| self[n] = nil if options.key?(n) || META.include?(n) }
75
79
 
@@ -39,5 +39,7 @@ module Imgproxy
39
39
  strip_color_profile: :scp,
40
40
  auto_rotate: :ar,
41
41
  filename: :fn,
42
+ return_attachment: :att,
43
+ expires: :exp,
42
44
  }.freeze
43
45
  end
@@ -5,7 +5,7 @@ module Imgproxy
5
5
  ZERO_RE = /\.0+/.freeze
6
6
 
7
7
  def self.cast(raw)
8
- raw&.to_f&.yield_self do |f|
8
+ raw&.to_f&.then do |f|
9
9
  # Convert integral value to Integer so to_s won't give us trailing zero
10
10
  i = f.to_i
11
11
  i == f ? i : f
@@ -24,11 +24,11 @@ module Imgproxy
24
24
  private
25
25
 
26
26
  def s3_url(image)
27
- "s3://#{image.service.bucket.name}/#{image.key}"
27
+ "s3://#{service(image).bucket.name}/#{image.key}"
28
28
  end
29
29
 
30
30
  def use_s3_url(image)
31
- config.use_s3_urls && image.service.is_a?(::ActiveStorage::Service::S3Service)
31
+ config.use_s3_urls && service(image).is_a?(::ActiveStorage::Service::S3Service)
32
32
  end
33
33
 
34
34
  def gcs_url(image)
@@ -36,7 +36,17 @@ module Imgproxy
36
36
  end
37
37
 
38
38
  def use_gcs_url(image)
39
- config.use_gcs_urls && image.service.is_a?(::ActiveStorage::Service::GCSService)
39
+ config.use_gcs_urls && service(image).is_a?(::ActiveStorage::Service::GCSService)
40
+ end
41
+
42
+ def service(image)
43
+ unwrap_service(image.service)
44
+ end
45
+
46
+ def unwrap_service(service)
47
+ return service unless defined?(::ActiveStorage::Service::MirrorService)
48
+ return service unless service.is_a?(::ActiveStorage::Service::MirrorService)
49
+ unwrap_service(service.primary)
40
50
  end
41
51
 
42
52
  def config
@@ -17,7 +17,7 @@ module Imgproxy
17
17
 
18
18
  opts = {}
19
19
  opts[:host] = Imgproxy.config.shrine_host if Imgproxy.config.shrine_host
20
- image.url(opts)
20
+ image.url(**opts)
21
21
  end
22
22
 
23
23
  private
@@ -1,3 +1,3 @@
1
1
  module Imgproxy
2
- VERSION = "2.0.1".freeze
2
+ VERSION = "2.1.0".freeze
3
3
  end
data/lib/imgproxy.rb CHANGED
@@ -100,6 +100,8 @@ module Imgproxy
100
100
  # @option options [Boolean] :auto_rotate
101
101
  # @option options [String] :filename
102
102
  # @option options [String] :format
103
+ # @option options [Boolean] :return_attachment
104
+ # @option options [Integer] :expires
103
105
  # @option options [Boolean] :use_short_options
104
106
  # @option options [Boolean] :base64_encode_urls
105
107
  # @option options [Boolean] :escape_plain_url
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imgproxy
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergey Alexandrovich
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-23 00:00:00.000000000 Z
11
+ date: 2022-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: anyway_config
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.1.2
33
+ version: 0.2.0
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.1.2
40
+ version: 0.2.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: pry-byebug
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -58,70 +58,70 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 3.9.0
61
+ version: 3.11.0
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 3.9.0
68
+ version: 3.11.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec_junit_formatter
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 0.4.1
75
+ version: 0.5.1
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 0.4.1
82
+ version: 0.5.1
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rubocop
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 0.83.0
89
+ version: 1.30.1
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 0.83.0
96
+ version: 1.30.1
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rubocop-rspec
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 1.38.1
103
+ version: 2.11.1
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 1.38.1
110
+ version: 2.11.1
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: aws-sdk-s3
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: 1.64.0
117
+ version: '1.64'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: 1.64.0
124
+ version: '1.64'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: google-cloud-storage
127
127
  requirement: !ruby/object:Gem::Requirement
@@ -142,14 +142,14 @@ dependencies:
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: '5.2'
145
+ version: 7.0.3
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: '5.2'
152
+ version: 7.0.3
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: shrine
155
155
  requirement: !ruby/object:Gem::Requirement
@@ -219,7 +219,8 @@ files:
219
219
  homepage: https://github.com/imgproxy/imgproxy.rb
220
220
  licenses:
221
221
  - MIT
222
- metadata: {}
222
+ metadata:
223
+ rubygems_mfa_required: 'true'
223
224
  post_install_message:
224
225
  rdoc_options: []
225
226
  require_paths:
@@ -235,7 +236,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
235
236
  - !ruby/object:Gem::Version
236
237
  version: '0'
237
238
  requirements: []
238
- rubygems_version: 3.0.3
239
+ rubygems_version: 3.3.7
239
240
  signing_key:
240
241
  specification_version: 4
241
242
  summary: imgproxy URL generator