Sha256: 164b71fdf1fb14054ffa70a5aad6f1506b55380102fa33157e4485dce12f85ad

Contents?: true

Size: 667 Bytes

Versions: 1

Compression:

Stored size: 667 Bytes

Contents

class EngineAssets::PublicLocator
  class << self
    attr_reader :paths

    # TODO: expose this as EngineAssets.register(...)
    def register(full_path)
      raise ArgumentError unless File.exist?(full_path)

      @paths ||= []
      public_path = File.join(full_path, 'public')

      if File.exist?(public_path)
        paths << public_path
      end
    end

    def locate(file_path)
      full_paths = (paths || []).map { |base_path| File.join(base_path, file_path) }

      full_paths.each do |full_path|
        return full_path if File.exist?(full_path)
      end

      nil
    end

    private

      def clear
        @paths = nil
      end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
engine-assets-0.6.0.pre1 lib/engine_assets/public_locator.rb