imgproxy 1.0.1 → 1.0.2

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: 90e13f160840d97192d6499cc36cc2bf9c5e96d58348706339f2215333c44f17
4
- data.tar.gz: 3631ee4b306561b4f7ab00d8930e80a510013fd37dba059b825e21aa115d6977
3
+ metadata.gz: da7381a4edd77972d08b45c68b7a923b924d67b63953e009d90188fc24a56f78
4
+ data.tar.gz: 7d9832c91d0688b462644238766766df4720f8f7f4d8e5b68d6e94d7b5f6587e
5
5
  SHA512:
6
- metadata.gz: b519665418fabeda9bbc356454952e4490163cfeea490fa620aae7a475df95d8c58c1fe051e567b650733d9bd388b26c3f5344c638a238a22c4bb6fd2b889018
7
- data.tar.gz: 37c777751a3f6d0384cafd4f08e84b02c4f26221b61550605e95c9c6ffec05e5be5cbe2c8030a84efca6c39ab5c41c8997e3a87bb3b58b268cf0c907a5215a49
6
+ metadata.gz: 4f195a449ff6c690aefcc92d776378c7fec811112943e54781f2fd1f1cbf2484f042bf555ca2b62bf6fbe070998fb5df6e83767f571fc52d6533966cea1d0678
7
+ data.tar.gz: 3affbd94edbb6be46ee1fb3729c3a3ff6002b06344d84fd4c434bc27f47b7a6d2aa374d6023694af866c41691fad8b5286e1ec525c9121fd0503addb707fc1d4
data/README.md CHANGED
@@ -110,14 +110,12 @@ user.avatar.imgproxy_url(width: 250, height: 250)
110
110
 
111
111
  will give you an URL to your user's avatar, resized to 250x250px on the fly.
112
112
 
113
- **Note:** If you use `Shrine::Storage::FileSystem` as storage, uploaded file URLs won't include the hostname, so imgproxy server won't be able to access them. To fix this, initialize `Shrine::Storage::FileSystem` with the `host` option:
113
+ **Note:** If you use `Shrine::Storage::FileSystem` as storage, uploaded file URLs won't include the hostname, so imgproxy server won't be able to access them. To fix this, use `host` option of `Imgproxy.extend_shrine!`:
114
114
 
115
115
  ```ruby
116
- # Your Shrine initializer
116
+ # config/initializers/imgproxy.rb
117
117
 
118
- Shrine.storages = {
119
- store: Shrine::Storage::FileSystem.new("public", host: "http://your-host.test")
120
- }
118
+ Imgproxy.extend_shrine!(host: "http://your-host.test")
121
119
  ```
122
120
 
123
121
  Alternatively, you can launch your imgproxy server with the `IMGPROXY_BASE_URL` setting:
data/lib/imgproxy.rb CHANGED
@@ -97,13 +97,13 @@ module Imgproxy
97
97
  #
98
98
  # @return [void]
99
99
  # @param use_s3 [Boolean] enable Amazon S3 source URLs
100
- def extend_shrine!(use_s3: false)
100
+ def extend_shrine!(host: nil, use_s3: false)
101
101
  ::Shrine::UploadedFile.include Imgproxy::Extensions::Shrine
102
102
 
103
103
  url_adapters = Imgproxy.config.url_adapters
104
104
 
105
105
  url_adapters.add(Imgproxy::UrlAdapters::ShrineS3.new) if use_s3
106
- url_adapters.add(Imgproxy::UrlAdapters::Shrine.new)
106
+ url_adapters.add(Imgproxy::UrlAdapters::Shrine.new(host: host))
107
107
  end
108
108
  end
109
109
  end
@@ -1,5 +1,6 @@
1
1
  require "openssl"
2
2
  require "base64"
3
+ require "uri"
3
4
 
4
5
  require "imgproxy/options"
5
6
 
@@ -37,7 +38,7 @@ module Imgproxy
37
38
 
38
39
  signature = sign_path(path)
39
40
 
40
- "#{Imgproxy.config.endpoint}/#{signature}/#{path}"
41
+ URI.join(Imgproxy.config.endpoint.to_s, "#{signature}/#{path}").to_s
41
42
  end
42
43
 
43
44
  private
@@ -5,7 +5,7 @@ module Imgproxy
5
5
  # @see Imgproxy.configure
6
6
  class Config
7
7
  # @return [String] imgproxy endpoint
8
- attr_reader :endpoint
8
+ attr_accessor :endpoint
9
9
  # @return [String] imgproxy signature key
10
10
  attr_accessor :key
11
11
  # @return [String] imgproxy signature salt
@@ -36,11 +36,6 @@ module Imgproxy
36
36
  self.salt = value.nil? ? nil : [value].pack("H*")
37
37
  end
38
38
 
39
- def endpoint=(value)
40
- value = value.to_s
41
- @endpoint = value.end_with?("/") ? value[0..-2] : value
42
- end
43
-
44
39
  # URL adapters config. Allows to use this gem with ActiveStorage, Shrine, etc.
45
40
  #
46
41
  # Imgproxy.configure do |config|
@@ -20,7 +20,7 @@ module Imgproxy
20
20
 
21
21
  def applicable?(image)
22
22
  super &&
23
- ::ActiveStorage::Blob.service.is_a?(::ActiveStorage::Service::GCSService)
23
+ image.service.is_a?(::ActiveStorage::Service::GCSService)
24
24
  end
25
25
 
26
26
  def url(image)
@@ -12,7 +12,7 @@ module Imgproxy
12
12
  class ActiveStorageS3 < Imgproxy::UrlAdapters::ActiveStorage
13
13
  def applicable?(image)
14
14
  super &&
15
- ::ActiveStorage::Blob.service.is_a?(::ActiveStorage::Service::S3Service)
15
+ image.service.is_a?(::ActiveStorage::Service::S3Service)
16
16
  end
17
17
 
18
18
  def url(image)
@@ -8,12 +8,16 @@ module Imgproxy
8
8
  #
9
9
  # Imgproxy.url_for(user.avatar)
10
10
  class Shrine
11
+ def initialize(host: nil)
12
+ @host = host
13
+ end
14
+
11
15
  def applicable?(image)
12
16
  image.is_a?(::Shrine::UploadedFile)
13
17
  end
14
18
 
15
19
  def url(image)
16
- image.url
20
+ image.url(host: @host)
17
21
  end
18
22
  end
19
23
  end
@@ -1,3 +1,3 @@
1
1
  module Imgproxy
2
- VERSION = "1.0.1".freeze
2
+ VERSION = "1.0.2".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imgproxy
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergey Alexandrovich
@@ -14,16 +14,16 @@ dependencies:
14
14
  name: pry-byebug
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 3.6.0
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: 3.6.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -42,16 +42,16 @@ dependencies:
42
42
  name: rspec_junit_formatter
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: 0.4.1
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: 0.4.1
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rubocop
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -183,7 +183,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
183
183
  requirements:
184
184
  - - ">="
185
185
  - !ruby/object:Gem::Version
186
- version: '0'
186
+ version: '2.0'
187
187
  required_rubygems_version: !ruby/object:Gem::Requirement
188
188
  requirements:
189
189
  - - ">="