Sha256: 60bf8780f16adad30928a03134d9e84258a0170eeaf509867f7e8d03292ce141
Contents?: true
Size: 665 Bytes
Versions: 2
Compression:
Stored size: 665 Bytes
Contents
class Servel::Locals def initialize(url_path:, fs_path:, root:) @url_path = url_path @fs_path = fs_path @root = root end def locals { 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 list end def files list = @fs_path.children.select { |child| child.file? } sort_paths(list) end def sort_paths(paths) Naturalsorter::Sorter.sort(paths.map(&:to_s), true).map { |path| Pathname.new(path) } end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
servel-0.4.0 | lib/servel/locals.rb |
servel-0.3.0 | lib/servel/locals.rb |