Sha256: c563fe98c022b8d75c18c440b09fd8b816155a787781ac3dca0bfdf79dc73749
Contents?: true
Size: 759 Bytes
Versions: 3
Compression:
Stored size: 759 Bytes
Contents
# frozen_string_literal: true class Shoes module Common module ImageHandling def absolute_file_path(path) if Pathname(path).absolute? search_for(File.basename(path), File.dirname(path)) else search_for(path, *default_search_paths) end end def search_for(path, *locations) found = locations.map { |dir| File.join(dir, path) } .find { |candidate| File.exist?(candidate) } unless found raise FileNotFoundError, "#{path} not found. Searched #{locations.join(',')}" end found end def default_search_paths [Dir.pwd, Shoes.configuration.app_dir, File.join(Shoes::DIR, "static")] end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
shoes-core-4.0.0.pre12 | lib/shoes/common/image_handling.rb |
shoes-core-4.0.0.pre11 | lib/shoes/common/image_handling.rb |
shoes-core-4.0.0.pre10 | lib/shoes/common/image_handling.rb |