module ROM::Files::Dataset::Filtering

Public Class Methods

included(other) click to toggle source
Calls superclass method
# File lib/rom/files/dataset/filtering.rb, line 9
def self.included(other)
  super(other)
  other.module_eval do
    option :inside_paths, Types::Strict::Array.of(Types::Coercible::Pathname), default: proc { HERE }
    option :include_patterns, Types::Strict::Array.of(Types::Coercible::String), default: proc { ALL }
    option :exclude_patterns, Types::Strict::Array.of(Types::Coercible::String), default: proc { EMPTY_ARRAY }
    option :search_recursive, Types::Bool, default: proc { true }
  end
end

Public Instance Methods

inside(*paths) click to toggle source

@return [Dataset]

# File lib/rom/files/dataset/filtering.rb, line 48
def inside(*paths)
  with(inside_paths: paths)
end
inside_append(*paths) click to toggle source

@return [Dataset]

# File lib/rom/files/dataset/filtering.rb, line 53
def inside_append(*paths)
  with(inside_paths: (inside_paths + paths).uniq)
end
not_recursive() click to toggle source

@return [Dataset]

# File lib/rom/files/dataset/filtering.rb, line 63
def not_recursive
  with(search_recursive: false)
end
recursive() click to toggle source

@return [Dataset]

# File lib/rom/files/dataset/filtering.rb, line 58
def recursive
  with(search_recursive: true)
end
recursive?() click to toggle source

@return [Boolean]

# File lib/rom/files/dataset/filtering.rb, line 78
def recursive?
  search_recursive ||
    inside_paths.all? { |path| path.to_s =~ RECURSIVE_EXPRESSION } ||
    include_patterns.all? { |pattern| pattern =~ RECURSIVE_EXPRESSION }
end
reject(*patterns) click to toggle source

@return [Dataset]

# File lib/rom/files/dataset/filtering.rb, line 85
def reject(*patterns)
  with(exclude_patterns: patterns.uniq)
end
reject_append(*patterns) click to toggle source

@return [Dataset]

# File lib/rom/files/dataset/filtering.rb, line 90
def reject_append(*patterns)
  with(exclude_patterns: (exclude_patterns + patterns).uniq)
end
search_patterns() click to toggle source

@return [Array<Pathname>]

# File lib/rom/files/dataset/filtering.rb, line 68
def search_patterns
  inside_paths.inject([]) do |result, path|
    path = path.join('**') if search_recursive
    result + include_patterns.map do |pattern|
      path.join(pattern)
    end
  end
end
select(*patterns) click to toggle source

@return [Dataset]

# File lib/rom/files/dataset/filtering.rb, line 38
def select(*patterns)
  with(include_patterns: patterns.uniq)
end
select_append(*patterns) click to toggle source

@return [Dataset]

# File lib/rom/files/dataset/filtering.rb, line 43
def select_append(*patterns)
  with(include_patterns: (include_patterns + patterns).uniq)
end