Class: CC::Workspace

Inherits:
Object
  • Object
show all
Defined in:
lib/cc/workspace.rb,
lib/cc/workspace/exclusion.rb,
lib/cc/workspace/path_tree.rb,
lib/cc/workspace/path_tree/dir_node.rb,
lib/cc/workspace/path_tree/file_node.rb

Defined Under Namespace

Classes: Exclusion, PathTree

Instance Method Summary collapse

Constructor Details

#initialize(path_tree = PathTree.for_path(".")) ⇒ Workspace

Returns a new instance of Workspace.



6
7
8
# File 'lib/cc/workspace.rb', line 6

def initialize(path_tree = PathTree.for_path("."))
  @path_tree = path_tree
end

Instance Method Details

#add(paths) ⇒ Object



18
19
20
21
22
# File 'lib/cc/workspace.rb', line 18

def add(paths)
  if paths.present?
    path_tree.include_paths(paths)
  end
end

#cloneObject



10
11
12
# File 'lib/cc/workspace.rb', line 10

def clone
  self.class.new(path_tree.clone)
end

#pathsObject



14
15
16
# File 'lib/cc/workspace.rb', line 14

def paths
  path_tree.all_paths
end

#remove(patterns) ⇒ Object



24
25
26
27
28
29
30
31
32
33
# File 'lib/cc/workspace.rb', line 24

def remove(patterns)
  Array(patterns).each do |pattern|
    exclusion = Exclusion.new(pattern)
    if exclusion.negated?
      path_tree.include_paths(exclusion.expand)
    else
      path_tree.exclude_paths(exclusion.expand)
    end
  end
end