imgproxy 1.2.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +238 -113
  3. data/lib/imgproxy/builder.rb +47 -55
  4. data/lib/imgproxy/config.rb +96 -30
  5. data/lib/imgproxy/extensions/active_storage.rb +10 -0
  6. data/lib/imgproxy/extensions/shrine.rb +10 -0
  7. data/lib/imgproxy/options.rb +86 -120
  8. data/lib/imgproxy/options_aliases.rb +45 -0
  9. data/lib/imgproxy/options_casters/adjust.rb +22 -0
  10. data/lib/imgproxy/options_casters/array.rb +12 -0
  11. data/lib/imgproxy/options_casters/base64.rb +12 -0
  12. data/lib/imgproxy/options_casters/bool.rb +12 -0
  13. data/lib/imgproxy/options_casters/crop.rb +23 -0
  14. data/lib/imgproxy/options_casters/extend.rb +26 -0
  15. data/lib/imgproxy/options_casters/float.rb +16 -0
  16. data/lib/imgproxy/options_casters/gif_options.rb +21 -0
  17. data/lib/imgproxy/options_casters/gravity.rb +23 -0
  18. data/lib/imgproxy/options_casters/group.rb +21 -0
  19. data/lib/imgproxy/options_casters/integer.rb +10 -0
  20. data/lib/imgproxy/options_casters/jpeg_options.rb +26 -0
  21. data/lib/imgproxy/options_casters/png_options.rb +23 -0
  22. data/lib/imgproxy/options_casters/resize.rb +21 -0
  23. data/lib/imgproxy/options_casters/size.rb +24 -0
  24. data/lib/imgproxy/options_casters/string.rb +10 -0
  25. data/lib/imgproxy/options_casters/trim.rb +28 -0
  26. data/lib/imgproxy/options_casters/watermark.rb +30 -0
  27. data/lib/imgproxy/trim_array.rb +11 -0
  28. data/lib/imgproxy/url_adapters/active_storage.rb +35 -0
  29. data/lib/imgproxy/url_adapters/shrine.rb +16 -6
  30. data/lib/imgproxy/url_adapters.rb +0 -4
  31. data/lib/imgproxy/version.rb +1 -1
  32. data/lib/imgproxy.rb +72 -50
  33. metadata +69 -23
  34. data/lib/imgproxy/url_adapters/active_storage_gcs.rb +0 -31
  35. data/lib/imgproxy/url_adapters/active_storage_s3.rb +0 -23
  36. data/lib/imgproxy/url_adapters/shrine_s3.rb +0 -21
@@ -1,31 +0,0 @@
1
- require "imgproxy/url_adapters/active_storage"
2
-
3
- module Imgproxy
4
- class UrlAdapters
5
- # Adapter for ActiveStorage with S3 service
6
- #
7
- # Imgproxy.configure do |config|
8
- # config.url_adapters.add Imgproxy::UrlAdapters::ActiveStorageGCS.new("bucket_name")
9
- # end
10
- #
11
- # Imgproxy.url_for(user.avatar)
12
- class ActiveStorageGCS < Imgproxy::UrlAdapters::ActiveStorage
13
- # @param [String] bucket_name Google Cloud Storage bucket name
14
- def initialize(bucket_name)
15
- @bucket_name = bucket_name
16
- end
17
-
18
- # @return [String] Google Cloud Storage bucket name
19
- attr_reader :bucket_name
20
-
21
- def applicable?(image)
22
- super &&
23
- image.service.is_a?(::ActiveStorage::Service::GCSService)
24
- end
25
-
26
- def url(image)
27
- "gs://#{bucket_name}/#{image.key}"
28
- end
29
- end
30
- end
31
- end
@@ -1,23 +0,0 @@
1
- require "imgproxy/url_adapters/active_storage"
2
-
3
- module Imgproxy
4
- class UrlAdapters
5
- # Adapter for ActiveStorage with S3 service
6
- #
7
- # Imgproxy.configure do |config|
8
- # config.url_adapters.add Imgproxy::UrlAdapters::ActiveStorageS3.new
9
- # end
10
- #
11
- # Imgproxy.url_for(user.avatar)
12
- class ActiveStorageS3 < Imgproxy::UrlAdapters::ActiveStorage
13
- def applicable?(image)
14
- super &&
15
- image.service.is_a?(::ActiveStorage::Service::S3Service)
16
- end
17
-
18
- def url(image)
19
- "s3://#{image.service.bucket.name}/#{image.key}"
20
- end
21
- end
22
- end
23
- end
@@ -1,21 +0,0 @@
1
- module Imgproxy
2
- class UrlAdapters
3
- # Adapter for Shrine with S3 storage
4
- #
5
- # Imgproxy.configure do |config|
6
- # config.url_adapters.add Imgproxy::UrlAdapters::ShrineS3.new
7
- # end
8
- #
9
- # Imgproxy.url_for(user.avatar)
10
- class ShrineS3 < Imgproxy::UrlAdapters::Shrine
11
- def applicable?(image)
12
- super && image.storage.is_a?(::Shrine::Storage::S3)
13
- end
14
-
15
- def url(image)
16
- path = [*image.storage.prefix, image.id].join("/")
17
- "s3://#{image.storage.bucket.name}/#{path}"
18
- end
19
- end
20
- end
21
- end