Sha256: e753aefbea2e28c24e8ed750e7c3ce4bfda1dbb0b21b64f4e0b08ef677431073

Contents?: true

Size: 622 Bytes

Versions: 14

Compression:

Stored size: 622 Bytes

Contents

module Riiif
  class AbstractFileSystemResolver
    attr_accessor :root, :base_path

    def initialize
      @root = ::File.expand_path(::File.join(::File.dirname(__FILE__), '../..'))
      @base_path = ::File.join(root, 'spec/samples')
    end

    def find(id)
      Riiif::File.new(path(id))
    end

    # @param [String] id the id to resolve
    # @return the path of the file
    def path(id)
      search = pattern(id)
      Dir.glob(search).first || raise(ImageNotFoundError, search)
    end

    def pattern(_id)
      raise NotImplementedError, "Implement `pattern(id)' in the concrete class"
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
riiif-1.5.1 lib/riiif/abstract_file_system_resolver.rb
riiif-1.5.0 lib/riiif/abstract_file_system_resolver.rb
riiif-1.4.4 lib/riiif/abstract_file_system_resolver.rb
riiif-1.4.3 lib/riiif/abstract_file_system_resolver.rb
riiif-1.4.2 lib/riiif/abstract_file_system_resolver.rb
riiif-1.4.1 lib/riiif/abstract_file_system_resolver.rb
riiif-1.4.0 lib/riiif/abstract_file_system_resolver.rb
riiif-1.3.0 lib/riiif/abstract_file_system_resolver.rb
riiif-1.2.0 lib/riiif/abstract_file_system_resolver.rb
riiif-1.1.3 lib/riiif/abstract_file_system_resolver.rb
riiif-1.1.2 lib/riiif/abstract_file_system_resolver.rb
riiif-1.1.1 lib/riiif/abstract_file_system_resolver.rb
riiif-1.1.0 lib/riiif/abstract_file_system_resolver.rb
riiif-1.0.0 lib/riiif/abstract_file_system_resolver.rb