Module: ROM::Files::Dataset::Filtering
- Included in:
- ROM::Files::Dataset
- Defined in:
- lib/rom/files/dataset/filtering.rb
Reading collapse
-
#exclude_patterns ⇒ Array<String>
readonly
Array of filename patterns to be rejected.
-
#include_patterns ⇒ Array<String>
readonly
Array of glob patterns to be selected inside #inside_paths.
-
#inside_paths ⇒ Array<String>
readonly
Array of glob patterns to select files inside.
-
#search_recursive ⇒ Boolean
readonly
Whether to search for files only in specific directory/ies or recursively.
Reading collapse
- #inside(*paths) ⇒ Dataset
- #inside_append(*paths) ⇒ Dataset
- #not_recursive ⇒ Dataset
- #recursive ⇒ Dataset
- #recursive? ⇒ Boolean
- #reject(*patterns) ⇒ Dataset
- #reject_append(*patterns) ⇒ Dataset
- #search_patterns ⇒ Array<Pathname>
- #select(*patterns) ⇒ Dataset
- #select_append(*patterns) ⇒ Dataset
Class Method Summary collapse
Instance Attribute Details
#exclude_patterns ⇒ Array<String> (readonly)
Array of filename patterns to be rejected
|
# File 'lib/rom/files/dataset/filtering.rb', line 29
|
#include_patterns ⇒ Array<String> (readonly)
Array of glob patterns to be selected inside #inside_paths
|
# File 'lib/rom/files/dataset/filtering.rb', line 25
|
#inside_paths ⇒ Array<String> (readonly)
Array of glob patterns to select files inside
|
# File 'lib/rom/files/dataset/filtering.rb', line 21
|
#search_recursive ⇒ Boolean (readonly)
Whether to search for files only in specific directory/ies or recursively
|
# File 'lib/rom/files/dataset/filtering.rb', line 33
|
Class Method Details
.included(other) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# 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 |
Instance Method Details
#inside(*paths) ⇒ Dataset
48 49 50 |
# File 'lib/rom/files/dataset/filtering.rb', line 48 def inside(*paths) with(inside_paths: paths) end |
#inside_append(*paths) ⇒ Dataset
53 54 55 |
# File 'lib/rom/files/dataset/filtering.rb', line 53 def inside_append(*paths) with(inside_paths: (inside_paths + paths).uniq) end |
#not_recursive ⇒ Dataset
63 64 65 |
# File 'lib/rom/files/dataset/filtering.rb', line 63 def not_recursive with(search_recursive: false) end |
#recursive ⇒ Dataset
58 59 60 |
# File 'lib/rom/files/dataset/filtering.rb', line 58 def recursive with(search_recursive: true) end |
#recursive? ⇒ Boolean
78 79 80 81 82 |
# 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) ⇒ Dataset
85 86 87 |
# File 'lib/rom/files/dataset/filtering.rb', line 85 def reject(*patterns) with(exclude_patterns: patterns.uniq) end |
#reject_append(*patterns) ⇒ Dataset
90 91 92 |
# File 'lib/rom/files/dataset/filtering.rb', line 90 def reject_append(*patterns) with(exclude_patterns: (exclude_patterns + patterns).uniq) end |
#search_patterns ⇒ Array<Pathname>
68 69 70 71 72 73 74 75 |
# 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) ⇒ Dataset
38 39 40 |
# File 'lib/rom/files/dataset/filtering.rb', line 38 def select(*patterns) with(include_patterns: patterns.uniq) end |
#select_append(*patterns) ⇒ Dataset
43 44 45 |
# File 'lib/rom/files/dataset/filtering.rb', line 43 def select_append(*patterns) with(include_patterns: (include_patterns + patterns).uniq) end |