class CC::Workspace::PathTree
Attributes
root_node[R]
Public Class Methods
for_path(path)
click to toggle source
# File lib/cc/workspace/path_tree.rb, line 18 def self.for_path(path) new(node_for_pathname(Pathname.new(path))) end
new(root_node)
click to toggle source
# File lib/cc/workspace/path_tree.rb, line 22 def initialize(root_node) @root_node = root_node end
node_for_pathname(pathname)
click to toggle source
# File lib/cc/workspace/path_tree.rb, line 10 def self.node_for_pathname(pathname) if pathname.directory? DirNode.new(pathname.to_s) else FileNode.new(pathname.to_s) end end
Public Instance Methods
clone()
click to toggle source
# File lib/cc/workspace/path_tree.rb, line 26 def clone self.class.new(root_node.clone) end
exclude_paths(paths)
click to toggle source
# File lib/cc/workspace/path_tree.rb, line 30 def exclude_paths(paths) paths.each { |path| root_node.remove(*normalized_path_pieces(path)) } end
include_paths(paths)
click to toggle source
# File lib/cc/workspace/path_tree.rb, line 34 def include_paths(paths) paths.each { |path| root_node.add(*normalized_path_pieces(path)) } end
Private Instance Methods
normalized_path_pieces(path)
click to toggle source
# File lib/cc/workspace/path_tree.rb, line 44 def normalized_path_pieces(path) Pathname.new(path).cleanpath.to_s.split(File::SEPARATOR).reject(&:blank?) end