Class: Imgproxy::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/imgproxy/config.rb

Overview

Imgproxy config

See Also:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



20
21
22
23
# File 'lib/imgproxy/config.rb', line 20

def initialize
  self.signature_size = 32
  self.use_short_options = true
end

Instance Attribute Details

#endpointString

Returns imgproxy endpoint.

Returns:

  • (String)

    imgproxy endpoint



8
9
10
# File 'lib/imgproxy/config.rb', line 8

def endpoint
  @endpoint
end

#keyString

Returns imgproxy signature key.

Returns:

  • (String)

    imgproxy signature key



10
11
12
# File 'lib/imgproxy/config.rb', line 10

def key
  @key
end

#saltString

Returns imgproxy signature salt.

Returns:

  • (String)

    imgproxy signature salt



12
13
14
# File 'lib/imgproxy/config.rb', line 12

def salt
  @salt
end

#signature_sizeInteger

Returns imgproxy signature size. Defaults to 32.

Returns:

  • (Integer)

    imgproxy signature size. Defaults to 32



14
15
16
# File 'lib/imgproxy/config.rb', line 14

def signature_size
  @signature_size
end

#use_short_optionsBoolean

Returns use short processing option names (rs for resize, g for gravity, etc). Defaults to true.

Returns:

  • (Boolean)

    use short processing option names (rs for resize, g for gravity, etc). Defaults to true



18
19
20
# File 'lib/imgproxy/config.rb', line 18

def use_short_options
  @use_short_options
end

Instance Method Details

#hex_key=(value) ⇒ Object

Decodes hex-encoded key and sets it to #key

Parameters:

  • value (String)

    hex-encoded signature key



28
29
30
# File 'lib/imgproxy/config.rb', line 28

def hex_key=(value)
  self.key = value.nil? ? nil : [value].pack("H*")
end

#hex_salt=(value) ⇒ Object

Decodes hex-encoded salt and sets it to #salt

Parameters:

  • value (String)

    hex-encoded signature salt



35
36
37
# File 'lib/imgproxy/config.rb', line 35

def hex_salt=(value)
  self.salt = value.nil? ? nil : [value].pack("H*")
end

#url_adaptersImgproxy::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)

Returns:

See Also:



49
50
51
# File 'lib/imgproxy/config.rb', line 49

def url_adapters
  @url_adapters ||= Imgproxy::UrlAdapters.new
end