Class: CleanupVendor::Path

Inherits:
Pathname
  • Object
show all
Defined in:
lib/cleanup_vendor/path.rb

Instance Method Summary collapse

Instance Method Details

#gem_level?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/cleanup_vendor/path.rb', line 23

def gem_level?
  @gem_level ||= parent.glob('*.gemspec').any?
end

#include?(enum) ⇒ Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/cleanup_vendor/path.rb', line 27

def include?(enum)
  descend.any? { |p| enum.include?(p) }
end

#match?(patterns) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
18
19
20
21
# File 'lib/cleanup_vendor/path.rb', line 15

def match?(patterns)
  patterns.any? do |p|
    p.eql?(self) ||
      p.start_with?('**') && fnmatch?(p, File::FNM_EXTGLOB) ||
      basename.fnmatch?(p, File::FNM_EXTGLOB) && gem_level?
  end
end

#recursive_entriesObject



7
8
9
10
11
12
13
# File 'lib/cleanup_vendor/path.rb', line 7

def recursive_entries
  return to_enum(:recursive_entries) unless block_given?

  glob('**/*', File::FNM_DOTMATCH) do |path|
    yield(Path.new(path)) unless path == self
  end
end

#summaryObject



31
32
33
34
# File 'lib/cleanup_vendor/path.rb', line 31

def summary
  entries = [self] + recursive_entries.to_a
  entries.map(&:stat)
end