Class: Imgproxy::Config
- Inherits:
-
Anyway::Config
- Object
- Anyway::Config
- Imgproxy::Config
- Defined in:
- lib/imgproxy/config.rb
Overview
Imgproxy config
Instance Attribute Summary collapse
-
#always_escape_plain_urls ⇒ String
Always escape plain URLs.
-
#base64_encode_urls ⇒ String
Base64 encode the URL.
-
#gcs_bucket ⇒ String
Google Cloud Storage bucket name.
-
#shrine_host ⇒ String
Shrine host.
-
#use_gcs_urls ⇒ String
Use short Google Cloud Storage urls (gs://…) when possible.
-
#use_s3_urls ⇒ String
Use short S3 urls (s3://…) when possible.
-
#use_short_options ⇒ String
Use short processing option names (
rs
forresize
,g
forgravity
, etc).
Instance Method Summary collapse
- #always_encrypt_source_urls ⇒ Object
- #always_encrypt_source_urls=(value) ⇒ Object
- #endpoint ⇒ Object
- #endpoint=(value) ⇒ Object
-
#hex_key=(value) ⇒ Object
deprecated
Deprecated.
Please use #key instead
-
#hex_salt=(value) ⇒ Object
deprecated
Deprecated.
Please use #salt instead
- #key ⇒ Object
- #key=(value) ⇒ Object
- #raw_key ⇒ Object
- #raw_key=(value) ⇒ Object
- #raw_salt ⇒ Object
- #raw_salt=(value) ⇒ Object
- #raw_source_url_encryption_key ⇒ Object
- #raw_source_url_encryption_key=(value) ⇒ Object
- #salt ⇒ Object
- #salt=(value) ⇒ Object
- #service(name) {|| ... } ⇒ Object
- #services ⇒ Object
- #signature_size ⇒ Object
- #signature_size=(value) ⇒ Object
- #source_url_encryption_key ⇒ Object
- #source_url_encryption_key=(value) ⇒ Object
-
#url_adapters ⇒ Imgproxy::UrlAdapters
URL adapters config.
Instance Attribute Details
#always_escape_plain_urls ⇒ String
Always escape plain URLs. Defaults to false
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
# File 'lib/imgproxy/config.rb', line 36 class Config < Anyway::Config attr_config( use_short_options: true, base64_encode_urls: false, always_escape_plain_urls: false, use_s3_urls: false, use_gcs_urls: false, gcs_bucket: nil, shrine_host: nil, services: {}, ) coerce_types( use_short_options: :boolean, base64_encode_urls: :boolean, always_escape_plain_urls: :boolean, use_s3_urls: :boolean, use_gcs_urls: :boolean, gcs_bucket: :string, shrine_host: :string, ) def endpoint service(:default).endpoint end def endpoint=(value) service(:default).endpoint = value end def key service(:default).key end def key=(value) service(:default).key = value end def raw_key service(:default).raw_key end def raw_key=(value) service(:default).raw_key = value end def salt service(:default).salt end def salt=(value) service(:default).salt = value end def raw_salt service(:default).raw_salt end def raw_salt=(value) service(:default).raw_salt = value end def signature_size service(:default).signature_size end def signature_size=(value) service(:default).signature_size = value end def source_url_encryption_key service(:default).source_url_encryption_key end def source_url_encryption_key=(value) service(:default).source_url_encryption_key = value end def raw_source_url_encryption_key service(:default).raw_source_url_encryption_key end def raw_source_url_encryption_key=(value) service(:default).raw_source_url_encryption_key = value end def always_encrypt_source_urls service(:default).always_encrypt_source_urls end def always_encrypt_source_urls=(value) service(:default).always_encrypt_source_urls = value end def service(name) services[name.to_sym] ||= services[:default].dup yield services[name.to_sym] if block_given? services[name.to_sym] end def services @services ||= {}.tap do |s| s[:default] = ServiceConfig.new super.each do |name, data| config = s[name.to_sym] = s[:default].dup data.symbolize_keys.slice(*config.class.config_attributes).each do |key, value| value = config.class.type_caster.coerce(key, value) config.public_send("#{key}=", value) end end end end # @deprecated Please use {#key} instead def hex_key=(value) warn "[DEPRECATION] #hex_key is deprecated. Please use #key instead." self.key = value end # @deprecated Please use {#salt} instead def hex_salt=(value) warn "[DEPRECATION] #hex_salt is deprecated. Please use #salt instead." self.salt = value end # URL adapters config. Allows to use this gem with ActiveStorage, Shrine, etc. # # Imgproxy.configure do |config| # config.url_adapters.add Imgproxy::UrlAdapters::ActiveStorage.new # end # # Imgproxy.url_for(user.avatar) # # @return [Imgproxy::UrlAdapters] # @see Imgproxy::UrlAdapters def url_adapters @url_adapters ||= Imgproxy::UrlAdapters.new end end |
#base64_encode_urls ⇒ String
Base64 encode the URL. Defaults to false
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
# File 'lib/imgproxy/config.rb', line 36 class Config < Anyway::Config attr_config( use_short_options: true, base64_encode_urls: false, always_escape_plain_urls: false, use_s3_urls: false, use_gcs_urls: false, gcs_bucket: nil, shrine_host: nil, services: {}, ) coerce_types( use_short_options: :boolean, base64_encode_urls: :boolean, always_escape_plain_urls: :boolean, use_s3_urls: :boolean, use_gcs_urls: :boolean, gcs_bucket: :string, shrine_host: :string, ) def endpoint service(:default).endpoint end def endpoint=(value) service(:default).endpoint = value end def key service(:default).key end def key=(value) service(:default).key = value end def raw_key service(:default).raw_key end def raw_key=(value) service(:default).raw_key = value end def salt service(:default).salt end def salt=(value) service(:default).salt = value end def raw_salt service(:default).raw_salt end def raw_salt=(value) service(:default).raw_salt = value end def signature_size service(:default).signature_size end def signature_size=(value) service(:default).signature_size = value end def source_url_encryption_key service(:default).source_url_encryption_key end def source_url_encryption_key=(value) service(:default).source_url_encryption_key = value end def raw_source_url_encryption_key service(:default).raw_source_url_encryption_key end def raw_source_url_encryption_key=(value) service(:default).raw_source_url_encryption_key = value end def always_encrypt_source_urls service(:default).always_encrypt_source_urls end def always_encrypt_source_urls=(value) service(:default).always_encrypt_source_urls = value end def service(name) services[name.to_sym] ||= services[:default].dup yield services[name.to_sym] if block_given? services[name.to_sym] end def services @services ||= {}.tap do |s| s[:default] = ServiceConfig.new super.each do |name, data| config = s[name.to_sym] = s[:default].dup data.symbolize_keys.slice(*config.class.config_attributes).each do |key, value| value = config.class.type_caster.coerce(key, value) config.public_send("#{key}=", value) end end end end # @deprecated Please use {#key} instead def hex_key=(value) warn "[DEPRECATION] #hex_key is deprecated. Please use #key instead." self.key = value end # @deprecated Please use {#salt} instead def hex_salt=(value) warn "[DEPRECATION] #hex_salt is deprecated. Please use #salt instead." self.salt = value end # URL adapters config. Allows to use this gem with ActiveStorage, Shrine, etc. # # Imgproxy.configure do |config| # config.url_adapters.add Imgproxy::UrlAdapters::ActiveStorage.new # end # # Imgproxy.url_for(user.avatar) # # @return [Imgproxy::UrlAdapters] # @see Imgproxy::UrlAdapters def url_adapters @url_adapters ||= Imgproxy::UrlAdapters.new end end |
#gcs_bucket ⇒ String
Google Cloud Storage bucket name
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
# File 'lib/imgproxy/config.rb', line 36 class Config < Anyway::Config attr_config( use_short_options: true, base64_encode_urls: false, always_escape_plain_urls: false, use_s3_urls: false, use_gcs_urls: false, gcs_bucket: nil, shrine_host: nil, services: {}, ) coerce_types( use_short_options: :boolean, base64_encode_urls: :boolean, always_escape_plain_urls: :boolean, use_s3_urls: :boolean, use_gcs_urls: :boolean, gcs_bucket: :string, shrine_host: :string, ) def endpoint service(:default).endpoint end def endpoint=(value) service(:default).endpoint = value end def key service(:default).key end def key=(value) service(:default).key = value end def raw_key service(:default).raw_key end def raw_key=(value) service(:default).raw_key = value end def salt service(:default).salt end def salt=(value) service(:default).salt = value end def raw_salt service(:default).raw_salt end def raw_salt=(value) service(:default).raw_salt = value end def signature_size service(:default).signature_size end def signature_size=(value) service(:default).signature_size = value end def source_url_encryption_key service(:default).source_url_encryption_key end def source_url_encryption_key=(value) service(:default).source_url_encryption_key = value end def raw_source_url_encryption_key service(:default).raw_source_url_encryption_key end def raw_source_url_encryption_key=(value) service(:default).raw_source_url_encryption_key = value end def always_encrypt_source_urls service(:default).always_encrypt_source_urls end def always_encrypt_source_urls=(value) service(:default).always_encrypt_source_urls = value end def service(name) services[name.to_sym] ||= services[:default].dup yield services[name.to_sym] if block_given? services[name.to_sym] end def services @services ||= {}.tap do |s| s[:default] = ServiceConfig.new super.each do |name, data| config = s[name.to_sym] = s[:default].dup data.symbolize_keys.slice(*config.class.config_attributes).each do |key, value| value = config.class.type_caster.coerce(key, value) config.public_send("#{key}=", value) end end end end # @deprecated Please use {#key} instead def hex_key=(value) warn "[DEPRECATION] #hex_key is deprecated. Please use #key instead." self.key = value end # @deprecated Please use {#salt} instead def hex_salt=(value) warn "[DEPRECATION] #hex_salt is deprecated. Please use #salt instead." self.salt = value end # URL adapters config. Allows to use this gem with ActiveStorage, Shrine, etc. # # Imgproxy.configure do |config| # config.url_adapters.add Imgproxy::UrlAdapters::ActiveStorage.new # end # # Imgproxy.url_for(user.avatar) # # @return [Imgproxy::UrlAdapters] # @see Imgproxy::UrlAdapters def url_adapters @url_adapters ||= Imgproxy::UrlAdapters.new end end |
#shrine_host ⇒ String
Shrine host
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
# File 'lib/imgproxy/config.rb', line 36 class Config < Anyway::Config attr_config( use_short_options: true, base64_encode_urls: false, always_escape_plain_urls: false, use_s3_urls: false, use_gcs_urls: false, gcs_bucket: nil, shrine_host: nil, services: {}, ) coerce_types( use_short_options: :boolean, base64_encode_urls: :boolean, always_escape_plain_urls: :boolean, use_s3_urls: :boolean, use_gcs_urls: :boolean, gcs_bucket: :string, shrine_host: :string, ) def endpoint service(:default).endpoint end def endpoint=(value) service(:default).endpoint = value end def key service(:default).key end def key=(value) service(:default).key = value end def raw_key service(:default).raw_key end def raw_key=(value) service(:default).raw_key = value end def salt service(:default).salt end def salt=(value) service(:default).salt = value end def raw_salt service(:default).raw_salt end def raw_salt=(value) service(:default).raw_salt = value end def signature_size service(:default).signature_size end def signature_size=(value) service(:default).signature_size = value end def source_url_encryption_key service(:default).source_url_encryption_key end def source_url_encryption_key=(value) service(:default).source_url_encryption_key = value end def raw_source_url_encryption_key service(:default).raw_source_url_encryption_key end def raw_source_url_encryption_key=(value) service(:default).raw_source_url_encryption_key = value end def always_encrypt_source_urls service(:default).always_encrypt_source_urls end def always_encrypt_source_urls=(value) service(:default).always_encrypt_source_urls = value end def service(name) services[name.to_sym] ||= services[:default].dup yield services[name.to_sym] if block_given? services[name.to_sym] end def services @services ||= {}.tap do |s| s[:default] = ServiceConfig.new super.each do |name, data| config = s[name.to_sym] = s[:default].dup data.symbolize_keys.slice(*config.class.config_attributes).each do |key, value| value = config.class.type_caster.coerce(key, value) config.public_send("#{key}=", value) end end end end # @deprecated Please use {#key} instead def hex_key=(value) warn "[DEPRECATION] #hex_key is deprecated. Please use #key instead." self.key = value end # @deprecated Please use {#salt} instead def hex_salt=(value) warn "[DEPRECATION] #hex_salt is deprecated. Please use #salt instead." self.salt = value end # URL adapters config. Allows to use this gem with ActiveStorage, Shrine, etc. # # Imgproxy.configure do |config| # config.url_adapters.add Imgproxy::UrlAdapters::ActiveStorage.new # end # # Imgproxy.url_for(user.avatar) # # @return [Imgproxy::UrlAdapters] # @see Imgproxy::UrlAdapters def url_adapters @url_adapters ||= Imgproxy::UrlAdapters.new end end |
#use_gcs_urls ⇒ String
Use short Google Cloud Storage urls (gs://…) when possible. Defaults to false
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
# File 'lib/imgproxy/config.rb', line 36 class Config < Anyway::Config attr_config( use_short_options: true, base64_encode_urls: false, always_escape_plain_urls: false, use_s3_urls: false, use_gcs_urls: false, gcs_bucket: nil, shrine_host: nil, services: {}, ) coerce_types( use_short_options: :boolean, base64_encode_urls: :boolean, always_escape_plain_urls: :boolean, use_s3_urls: :boolean, use_gcs_urls: :boolean, gcs_bucket: :string, shrine_host: :string, ) def endpoint service(:default).endpoint end def endpoint=(value) service(:default).endpoint = value end def key service(:default).key end def key=(value) service(:default).key = value end def raw_key service(:default).raw_key end def raw_key=(value) service(:default).raw_key = value end def salt service(:default).salt end def salt=(value) service(:default).salt = value end def raw_salt service(:default).raw_salt end def raw_salt=(value) service(:default).raw_salt = value end def signature_size service(:default).signature_size end def signature_size=(value) service(:default).signature_size = value end def source_url_encryption_key service(:default).source_url_encryption_key end def source_url_encryption_key=(value) service(:default).source_url_encryption_key = value end def raw_source_url_encryption_key service(:default).raw_source_url_encryption_key end def raw_source_url_encryption_key=(value) service(:default).raw_source_url_encryption_key = value end def always_encrypt_source_urls service(:default).always_encrypt_source_urls end def always_encrypt_source_urls=(value) service(:default).always_encrypt_source_urls = value end def service(name) services[name.to_sym] ||= services[:default].dup yield services[name.to_sym] if block_given? services[name.to_sym] end def services @services ||= {}.tap do |s| s[:default] = ServiceConfig.new super.each do |name, data| config = s[name.to_sym] = s[:default].dup data.symbolize_keys.slice(*config.class.config_attributes).each do |key, value| value = config.class.type_caster.coerce(key, value) config.public_send("#{key}=", value) end end end end # @deprecated Please use {#key} instead def hex_key=(value) warn "[DEPRECATION] #hex_key is deprecated. Please use #key instead." self.key = value end # @deprecated Please use {#salt} instead def hex_salt=(value) warn "[DEPRECATION] #hex_salt is deprecated. Please use #salt instead." self.salt = value end # URL adapters config. Allows to use this gem with ActiveStorage, Shrine, etc. # # Imgproxy.configure do |config| # config.url_adapters.add Imgproxy::UrlAdapters::ActiveStorage.new # end # # Imgproxy.url_for(user.avatar) # # @return [Imgproxy::UrlAdapters] # @see Imgproxy::UrlAdapters def url_adapters @url_adapters ||= Imgproxy::UrlAdapters.new end end |
#use_s3_urls ⇒ String
Use short S3 urls (s3://…) when possible. Defaults to false
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
# File 'lib/imgproxy/config.rb', line 36 class Config < Anyway::Config attr_config( use_short_options: true, base64_encode_urls: false, always_escape_plain_urls: false, use_s3_urls: false, use_gcs_urls: false, gcs_bucket: nil, shrine_host: nil, services: {}, ) coerce_types( use_short_options: :boolean, base64_encode_urls: :boolean, always_escape_plain_urls: :boolean, use_s3_urls: :boolean, use_gcs_urls: :boolean, gcs_bucket: :string, shrine_host: :string, ) def endpoint service(:default).endpoint end def endpoint=(value) service(:default).endpoint = value end def key service(:default).key end def key=(value) service(:default).key = value end def raw_key service(:default).raw_key end def raw_key=(value) service(:default).raw_key = value end def salt service(:default).salt end def salt=(value) service(:default).salt = value end def raw_salt service(:default).raw_salt end def raw_salt=(value) service(:default).raw_salt = value end def signature_size service(:default).signature_size end def signature_size=(value) service(:default).signature_size = value end def source_url_encryption_key service(:default).source_url_encryption_key end def source_url_encryption_key=(value) service(:default).source_url_encryption_key = value end def raw_source_url_encryption_key service(:default).raw_source_url_encryption_key end def raw_source_url_encryption_key=(value) service(:default).raw_source_url_encryption_key = value end def always_encrypt_source_urls service(:default).always_encrypt_source_urls end def always_encrypt_source_urls=(value) service(:default).always_encrypt_source_urls = value end def service(name) services[name.to_sym] ||= services[:default].dup yield services[name.to_sym] if block_given? services[name.to_sym] end def services @services ||= {}.tap do |s| s[:default] = ServiceConfig.new super.each do |name, data| config = s[name.to_sym] = s[:default].dup data.symbolize_keys.slice(*config.class.config_attributes).each do |key, value| value = config.class.type_caster.coerce(key, value) config.public_send("#{key}=", value) end end end end # @deprecated Please use {#key} instead def hex_key=(value) warn "[DEPRECATION] #hex_key is deprecated. Please use #key instead." self.key = value end # @deprecated Please use {#salt} instead def hex_salt=(value) warn "[DEPRECATION] #hex_salt is deprecated. Please use #salt instead." self.salt = value end # URL adapters config. Allows to use this gem with ActiveStorage, Shrine, etc. # # Imgproxy.configure do |config| # config.url_adapters.add Imgproxy::UrlAdapters::ActiveStorage.new # end # # Imgproxy.url_for(user.avatar) # # @return [Imgproxy::UrlAdapters] # @see Imgproxy::UrlAdapters def url_adapters @url_adapters ||= Imgproxy::UrlAdapters.new end end |
#use_short_options ⇒ String
Use short processing option names (rs
for resize
, g
for gravity
, etc). Defaults to true
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
# File 'lib/imgproxy/config.rb', line 36 class Config < Anyway::Config attr_config( use_short_options: true, base64_encode_urls: false, always_escape_plain_urls: false, use_s3_urls: false, use_gcs_urls: false, gcs_bucket: nil, shrine_host: nil, services: {}, ) coerce_types( use_short_options: :boolean, base64_encode_urls: :boolean, always_escape_plain_urls: :boolean, use_s3_urls: :boolean, use_gcs_urls: :boolean, gcs_bucket: :string, shrine_host: :string, ) def endpoint service(:default).endpoint end def endpoint=(value) service(:default).endpoint = value end def key service(:default).key end def key=(value) service(:default).key = value end def raw_key service(:default).raw_key end def raw_key=(value) service(:default).raw_key = value end def salt service(:default).salt end def salt=(value) service(:default).salt = value end def raw_salt service(:default).raw_salt end def raw_salt=(value) service(:default).raw_salt = value end def signature_size service(:default).signature_size end def signature_size=(value) service(:default).signature_size = value end def source_url_encryption_key service(:default).source_url_encryption_key end def source_url_encryption_key=(value) service(:default).source_url_encryption_key = value end def raw_source_url_encryption_key service(:default).raw_source_url_encryption_key end def raw_source_url_encryption_key=(value) service(:default).raw_source_url_encryption_key = value end def always_encrypt_source_urls service(:default).always_encrypt_source_urls end def always_encrypt_source_urls=(value) service(:default).always_encrypt_source_urls = value end def service(name) services[name.to_sym] ||= services[:default].dup yield services[name.to_sym] if block_given? services[name.to_sym] end def services @services ||= {}.tap do |s| s[:default] = ServiceConfig.new super.each do |name, data| config = s[name.to_sym] = s[:default].dup data.symbolize_keys.slice(*config.class.config_attributes).each do |key, value| value = config.class.type_caster.coerce(key, value) config.public_send("#{key}=", value) end end end end # @deprecated Please use {#key} instead def hex_key=(value) warn "[DEPRECATION] #hex_key is deprecated. Please use #key instead." self.key = value end # @deprecated Please use {#salt} instead def hex_salt=(value) warn "[DEPRECATION] #hex_salt is deprecated. Please use #salt instead." self.salt = value end # URL adapters config. Allows to use this gem with ActiveStorage, Shrine, etc. # # Imgproxy.configure do |config| # config.url_adapters.add Imgproxy::UrlAdapters::ActiveStorage.new # end # # Imgproxy.url_for(user.avatar) # # @return [Imgproxy::UrlAdapters] # @see Imgproxy::UrlAdapters def url_adapters @url_adapters ||= Imgproxy::UrlAdapters.new end end |
Instance Method Details
#always_encrypt_source_urls ⇒ Object
122 123 124 |
# File 'lib/imgproxy/config.rb', line 122 def always_encrypt_source_urls service(:default).always_encrypt_source_urls end |
#always_encrypt_source_urls=(value) ⇒ Object
126 127 128 |
# File 'lib/imgproxy/config.rb', line 126 def always_encrypt_source_urls=(value) service(:default).always_encrypt_source_urls = value end |
#endpoint ⇒ Object
58 59 60 |
# File 'lib/imgproxy/config.rb', line 58 def endpoint service(:default).endpoint end |
#endpoint=(value) ⇒ Object
62 63 64 |
# File 'lib/imgproxy/config.rb', line 62 def endpoint=(value) service(:default).endpoint = value end |
#hex_key=(value) ⇒ Object
Please use #key instead
154 155 156 157 |
# File 'lib/imgproxy/config.rb', line 154 def hex_key=(value) warn "[DEPRECATION] #hex_key is deprecated. Please use #key instead." self.key = value end |
#hex_salt=(value) ⇒ Object
Please use #salt instead
160 161 162 163 |
# File 'lib/imgproxy/config.rb', line 160 def hex_salt=(value) warn "[DEPRECATION] #hex_salt is deprecated. Please use #salt instead." self.salt = value end |
#key ⇒ Object
66 67 68 |
# File 'lib/imgproxy/config.rb', line 66 def key service(:default).key end |
#key=(value) ⇒ Object
70 71 72 |
# File 'lib/imgproxy/config.rb', line 70 def key=(value) service(:default).key = value end |
#raw_key ⇒ Object
74 75 76 |
# File 'lib/imgproxy/config.rb', line 74 def raw_key service(:default).raw_key end |
#raw_key=(value) ⇒ Object
78 79 80 |
# File 'lib/imgproxy/config.rb', line 78 def raw_key=(value) service(:default).raw_key = value end |
#raw_salt ⇒ Object
90 91 92 |
# File 'lib/imgproxy/config.rb', line 90 def raw_salt service(:default).raw_salt end |
#raw_salt=(value) ⇒ Object
94 95 96 |
# File 'lib/imgproxy/config.rb', line 94 def raw_salt=(value) service(:default).raw_salt = value end |
#raw_source_url_encryption_key ⇒ Object
114 115 116 |
# File 'lib/imgproxy/config.rb', line 114 def raw_source_url_encryption_key service(:default).raw_source_url_encryption_key end |
#raw_source_url_encryption_key=(value) ⇒ Object
118 119 120 |
# File 'lib/imgproxy/config.rb', line 118 def raw_source_url_encryption_key=(value) service(:default).raw_source_url_encryption_key = value end |
#salt ⇒ Object
82 83 84 |
# File 'lib/imgproxy/config.rb', line 82 def salt service(:default).salt end |
#salt=(value) ⇒ Object
86 87 88 |
# File 'lib/imgproxy/config.rb', line 86 def salt=(value) service(:default).salt = value end |
#service(name) {|| ... } ⇒ Object
130 131 132 133 134 135 136 |
# File 'lib/imgproxy/config.rb', line 130 def service(name) services[name.to_sym] ||= services[:default].dup yield services[name.to_sym] if block_given? services[name.to_sym] end |
#services ⇒ Object
138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/imgproxy/config.rb', line 138 def services @services ||= {}.tap do |s| s[:default] = ServiceConfig.new super.each do |name, data| config = s[name.to_sym] = s[:default].dup data.symbolize_keys.slice(*config.class.config_attributes).each do |key, value| value = config.class.type_caster.coerce(key, value) config.public_send("#{key}=", value) end end end end |
#signature_size ⇒ Object
98 99 100 |
# File 'lib/imgproxy/config.rb', line 98 def signature_size service(:default).signature_size end |
#signature_size=(value) ⇒ Object
102 103 104 |
# File 'lib/imgproxy/config.rb', line 102 def signature_size=(value) service(:default).signature_size = value end |
#source_url_encryption_key ⇒ Object
106 107 108 |
# File 'lib/imgproxy/config.rb', line 106 def source_url_encryption_key service(:default).source_url_encryption_key end |
#source_url_encryption_key=(value) ⇒ Object
110 111 112 |
# File 'lib/imgproxy/config.rb', line 110 def source_url_encryption_key=(value) service(:default).source_url_encryption_key = value end |
#url_adapters ⇒ Imgproxy::UrlAdapters
URL adapters config. Allows to use this gem with ActiveStorage, Shrine, etc.
Imgproxy.configure do |config|
config.url_adapters.add Imgproxy::UrlAdapters::ActiveStorage.new
end
Imgproxy.url_for(user.avatar)
175 176 177 |
# File 'lib/imgproxy/config.rb', line 175 def url_adapters @url_adapters ||= Imgproxy::UrlAdapters.new end |