Module: ScaleDown

Defined in:
lib/scale_down.rb,
lib/scale_down/version.rb,
lib/scale_down/configuration.rb

Defined Under Namespace

Classes: Controller, Dispatcher, FileSizeTooLarge, Image, Info, InvalidGeometry

Constant Summary collapse

VERSION =
"0.8.1"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.hmac_keyObject

The shared secret for generating the hmac



12
13
14
# File 'lib/scale_down/configuration.rb', line 12

def hmac_key
  @hmac_key
end

.hmac_lengthObject

How many characters of the HMAC are used for validation Default 8



16
17
18
# File 'lib/scale_down/configuration.rb', line 16

def hmac_length
  @hmac_length
end

.hmac_methodObject

Defines the method to use for generating an HMAC For example

ScaleDown.hmac_method = HMAC::SHA2

Default HMAC::SHA1



8
9
10
# File 'lib/scale_down/configuration.rb', line 8

def hmac_method
  @hmac_method
end

.labelsObject

Labels are predefined gemeotries



35
36
37
# File 'lib/scale_down/configuration.rb', line 35

def labels
  @labels
end

.max_dimensionsObject

An array of the max width and height an image can be scaled, in pixels.

800,600

would limit scaling operations to 800px wide by 600px tall

Default [1200,1200]



22
23
24
# File 'lib/scale_down/configuration.rb', line 22

def max_dimensions
  @max_dimensions
end

.max_file_sizeObject

The max file size allowed for the file to be scaled, in bytes Defaults 10 megabytes



27
28
29
# File 'lib/scale_down/configuration.rb', line 27

def max_file_size
  @max_file_size
end

.public_folderObject

The location of the public path for you application Must be set



32
33
34
# File 'lib/scale_down/configuration.rb', line 32

def public_folder
  @public_folder
end

Class Method Details

.hmac(string) ⇒ Object



27
28
29
# File 'lib/scale_down.rb', line 27

def self.hmac(string)
  hmac_method.new(hmac_key).update(string).to_s[0...hmac_length]
end

.loggerObject



47
48
49
# File 'lib/scale_down/configuration.rb', line 47

def logger
  @logger || Logger.new("/dev/null")
end

.logger=(logger) ⇒ Object



43
44
45
# File 'lib/scale_down/configuration.rb', line 43

def logger=(logger)
  @logger = logger
end

.valid_hmac?(params) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
25
# File 'lib/scale_down.rb', line 22

def self.valid_hmac?(params)
  str = ["/", params[:path], "/", params[:target], "/", params[:filename]].join
  hmac(str) == params[:hmac]
end