Module: Webgen::Common

Defined in:
lib/webgen/common.rb,
lib/webgen/common/sitemap.rb

Overview

Namespace for classes and methods that provide common functionality.

Defined Under Namespace

Classes: Sitemap

Class Method Summary collapse

Class Method Details

.absolute_path(path, base) ⇒ Object

Make the given path absolute by prepending the absolute path base if necessary. Also resolves all ‘..’ and ‘.’ references in path.

Raises:

  • (ArgumentError)


14
15
16
17
# File 'lib/webgen/common.rb', line 14

def self.absolute_path(path, base)
  raise(ArgumentError, 'base has to be an absolute path') unless base =~ /\//
  Pathname.new(path =~ /^\// ? path : File.join(base, path)).cleanpath.to_s
end