Module: Simple::Httpd::Mount

Extended by:
Mount
Included in:
Mount
Defined in:
lib/simple/httpd/mount.rb

Defined Under Namespace

Classes: PathMount

Instance Method Summary collapse

Instance Method Details

#build(arg, at:) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/simple/httpd/mount.rb', line 7

def build(arg, at:)
  if at
    entity, mount_point = arg, at
  else
    # The regexp below uses negative lookbehind and negative lookahead to
    # only match single colons, but not double (or more) colons. See
    # `ri Regexp` for details.
    entity, mount_point = *arg.split(/(?<!:):(?!:)/, 2)
  end

  mount_point = normalize_and_verify_mount_point(mount_point)

  PathMount.build(mount_point, path: entity) ||
    raise(ArgumentError, "#{mount_point}: don't know how to mount #{entity.inspect}")
end