Sha256: 3a8aad372ba7159bae14c01c452a9093f8fca487f337ab63f90c543cb7e0ced2
Contents?: true
Size: 950 Bytes
Versions: 1
Compression:
Stored size: 950 Bytes
Contents
# frozen_string_literal: true module DevSuite module DirectoryTree module Builder class Base # # Recursive method to build the tree # def build(path) return build_permission_denied_node(path) unless path.readable? path.directory? ? construct_directory_node(path) : build_file_node(path) rescue Errno::EACCES build_permission_denied_node(path) end protected def construct_directory_node(path) directory = Node::Directory.new(path.basename.to_s) path.children.each do |child| directory.add_child(build(child)) end directory end def build_file_node(path) Node::File.new(path.basename.to_s) end def build_permission_denied_node(path) Node::PermissionDenied.new(path.basename.to_s, path.directory?) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dev_suite-0.2.1 | lib/dev_suite/directory_tree/builder/base.rb |