Class: Simple::Httpd::MountSpec
- Inherits:
-
Object
- Object
- Simple::Httpd::MountSpec
- Defined in:
- lib/simple/httpd/mount_spec.rb
Direct Known Subclasses
Defined Under Namespace
Classes: PathMountSpec, ServiceMountSpec
Instance Attribute Summary collapse
-
#mount_point ⇒ Object
readonly
Returns the value of attribute mount_point.
Class Method Summary collapse
Instance Attribute Details
#mount_point ⇒ Object (readonly)
Returns the value of attribute mount_point.
34 35 36 |
# File 'lib/simple/httpd/mount_spec.rb', line 34 def mount_point @mount_point end |
Class Method Details
.build(arg, at:) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/simple/httpd/mount_spec.rb', line 7 def self.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) ServiceMountSpec.build(mount_point, service: entity) || PathMountSpec.build(mount_point, path: entity) || raise(ArgumentError, "#{mount_point}: don't know how to mount #{entity.inspect}") end |
.normalize_and_verify_mount_point(mount_point) ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/simple/httpd/mount_spec.rb', line 24 def self.normalize_and_verify_mount_point(mount_point) mount_point ||= "/" # fall back to "/" mount_point = File.join("/", mount_point) # make sure we start at "/" canary_url = "http://0.0.0.0#{mount_point}" # verify mount_point: can it be used to build a URL? URI.parse canary_url mount_point end |