Method: IiifS3::Config#initialize

Defined in:
lib/iiif_s3/config.rb

#initialize(opts = {}) ⇒ Config

Initialize a new configuration option.

Parameters:

  • opts (Hash) (defaults to: {})

Options Hash (opts):

  • :upload_to_s3 (Boolean)

    if true, images and metadata will be uploaded to Amazon S3. Defaults to False.

  • :tile_width (Number)

    The width in pixels for generated tiles. Defaults to DEFAULT_TILE_WIDTH

  • :tile_scale_factors (Array<Number>)

    An array of ratios for generated tiles. Defaults to DEFAULT_TILE_SCALE_FACTORS

  • :image_directory_name (String)

    The name of the subdirectory for actual image data. Defaults to DEFAULT_IMAGE_DIRECTORY_NAME

  • :output_dir (String)

    The name of the directory for generated files. image data. Defaults to DEFAULT_OUTPUT_DIRECTORY

  • :base_url (String)

    The base URL for the generated URIs. Defaults to DEFAULT_URL if not auto-uploading to S3 and to the s3 bucket if upload_to_s3 is enabled.

  • :thumbnail_size (Number)

    the size in pixels for the largest side of the thumbnail images. Defaults to DEFAULT_THUMBNAIL_SIZE.

  • :use_extensions (Bool) — default: true

    should files have exensions appended?

  • :verbose (Bool) — default: false

    Should debug information be printed to the console?

  • :prefix (String) — default: ""

    a prefix (read: subdirectory) for the generated URIs.

  • :variants (Hash{String: String})


109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/iiif_s3/config.rb', line 109

def initialize(opts = {})
  @upload_to_s3   = opts[:upload_to_s3] || false
  @s3             = IiifS3::AmazonS3.new if @upload_to_s3
  @tile_width     = opts[:tile_width]                 || DEFAULT_TILE_WIDTH
  @tile_scale_factors = opts[:tile_scale_factors]     || DEFAULT_TILE_SCALE_FACTORS
  @image_directory_name = opts[:image_directory_name] || DEFAULT_IMAGE_DIRECTORY_NAME
  @base_url       = opts[:base_url]                   || ( @upload_to_s3 ? @s3.bucket.url : DEFAULT_URL)
  @use_extensions = opts.fetch(:use_extensions, true) ## true
  @output_dir     = opts[:output_dir]                 || DEFAULT_OUTPUT_DIRECTORY
  @variants       = opts[:variants]                   || {}
  @thumbnail_size = opts[:thumbnail_size]             || DEFAULT_THUMBNAIL_SIZE
  @verbose        = opts.fetch(:verbose, false)       ## false
  @prefix         = opts[:prefix]                     || ""
  if @prefix.length > 0 && @prefix[0] != "/"
    @prefix = "/#{@prefix}" 
  end
end