Module: Roda::RodaPlugins::StripPathPrefix

Defined in:
lib/roda/plugins/strip_path_prefix.rb

Overview

The strip_path_prefix plugin makes Roda strip a given prefix off internal absolute paths, turning them to relative paths. Roda by default stores internal paths as absolute paths. The main reason to use this plugin is when the internal absolute path could change at runtime, either due to a symlink change or chroot call, or you really want to use relative paths instead of absolute paths.

Examples:

plugin :strip_path_prefix # Defaults to Dir.pwd
plugin :strip_path_prefix, File.dirname(Dir.pwd)

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Class Method Details

.configure(app, prefix = Dir.pwd) ⇒ Object

Set the regexp to use when stripping prefixes from internal paths.



18
19
20
21
# File 'lib/roda/plugins/strip_path_prefix.rb', line 18

def self.configure(app, prefix=Dir.pwd)
  prefix += '/' unless prefix=~ /\/\z/
  app.opts[:strip_path_prefix] = /\A#{Regexp.escape(prefix)}/
end