Sha256: 1f5d27913d223d7443e3945ca95deab3766c0279699151fe3e49c57cfd3cde33
Contents?: true
Size: 871 Bytes
Versions: 5
Compression:
Stored size: 871 Bytes
Contents
module Riiif class FileSystemFileResolver < AbstractFileSystemResolver attr_writer :input_types # @return a string suitable for a globbing match # e.g. /base/path/67352ccc-d1b0-11e1-89ae-279075081939.{jp2,tiff,png} # or nil when the id is not valid def pattern(id) return unless validate_identifier(id: id) ::File.join(base_path, "#{id}.{#{input_types.join(',')}}") end private # @return [Boolean] true if the id matches the regex def validate_identifier(id:, regex: identifier_regex) return true if id =~ regex Rails.logger.warn "Invalid characters in id `#{id}`" false end # Matches on word characters dashes and colons def identifier_regex /^[\w\-:]+$/ end def input_types @input_types ||= %w(png jpg tif tiff jp2) end end end
Version data entries
5 entries across 5 versions & 1 rubygems