Class: CC::Analyzer::PathFilter

Inherits:
Object
  • Object
show all
Defined in:
lib/cc/analyzer/path_filter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(paths) ⇒ PathFilter

Returns a new instance of PathFilter.



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

def initialize(paths)
  @paths = paths
end

Instance Attribute Details

#pathsObject (readonly)

Returns the value of attribute paths.



4
5
6
# File 'lib/cc/analyzer/path_filter.rb', line 4

def paths
  @paths
end

Instance Method Details

#reject_globs(globs) ⇒ Object



30
31
32
33
34
# File 'lib/cc/analyzer/path_filter.rb', line 30

def reject_globs(globs)
  patterns = PathPatterns.new(globs)
  @paths = paths.reject { |path| patterns.match?(pathpatterns.match?(path)) }
  self
end

#reject_paths(ignore_paths) ⇒ Object



15
16
17
18
# File 'lib/cc/analyzer/path_filter.rb', line 15

def reject_paths(ignore_paths)
  @paths = paths - ignore_paths
  self
end


25
26
27
28
# File 'lib/cc/analyzer/path_filter.rb', line 25

def reject_symlinks
  @paths = paths.reject { |path| File.symlink?(path) }
  self
end

#reject_unreadable_pathsObject



10
11
12
13
# File 'lib/cc/analyzer/path_filter.rb', line 10

def reject_unreadable_paths
  @paths = paths - unreadable_path_entries
  self
end

#select_readable_filesObject



20
21
22
23
# File 'lib/cc/analyzer/path_filter.rb', line 20

def select_readable_files
  @paths = paths.select { |path| File.exist?(path) && FileUtils.readable_by_all?(path) }
  self
end