lib/servel/locals.rb in servel-0.4.0 vs lib/servel/locals.rb in servel-0.5.0
- old
+ new
@@ -1,23 +1,29 @@
class Servel::Locals
- def initialize(url_path:, fs_path:, root:)
+ def initialize(url_root:, url_path:, fs_path:)
+ @url_root = url_root
@url_path = url_path
@fs_path = fs_path
- @root = root
end
- def locals
+ def resolve
{
+ url_root: @url_root,
url_path: @url_path,
directories: directories,
files: files
}
end
def directories
list = @fs_path.children.select { |child| child.directory? }
list = sort_paths(list)
- list.unshift(@fs_path.decorate(true)) unless @fs_path == @root
+
+ unless @url_path == "/"
+ list.unshift(Servel::PathnameDecorator.new(pathname: "../", parent: true))
+ list.unshift(Servel::PathnameDecorator.new(pathname: @url_root, top: true))
+ end
+
list
end
def files
list = @fs_path.children.select { |child| child.file? }
\ No newline at end of file