Class: Build::Files::List
- Inherits:
-
Object
- Object
- Build::Files::List
- Includes:
- Enumerable
- Defined in:
- lib/build/files/list.rb,
lib/build/files/system.rb
Overview
A list of paths, where #each yields instances of Path.
Direct Known Subclasses
Constant Summary collapse
Class Method Summary collapse
Instance Method Summary collapse
-
#+(list) ⇒ Object
Create a composite list out of two other lists:.
- #-(list) ⇒ Object
-
#==(other) ⇒ Object
This isn’t very efficient, but it IS generic.
-
#create ⇒ Object
Recursively create paths for all listed paths.
-
#delete ⇒ Object
Recursively delete all paths and all contents within those paths.
-
#exist? ⇒ Boolean
Check that all files listed exist.
-
#intersects?(other) ⇒ Boolean
Does this list of files include the path of any other?.
- #map ⇒ Object
- #rebase(root) ⇒ Object
- #roots ⇒ Object
- #to_paths ⇒ Object
- #to_s ⇒ Object
-
#touch ⇒ Object
Touch all listed files.
- #with(**options) ⇒ Object
Class Method Details
Instance Method Details
#+(list) ⇒ Object
Create a composite list out of two other lists:
34 35 36 |
# File 'lib/build/files/list.rb', line 34 def +(list) Composite.new([self, list]) end |
#-(list) ⇒ Object
38 39 40 |
# File 'lib/build/files/list.rb', line 38 def -(list) Difference.new(self, list) end |
#==(other) ⇒ Object
This isn’t very efficient, but it IS generic.
43 44 45 46 47 48 49 50 51 |
# File 'lib/build/files/list.rb', line 43 def ==(other) if self.class == other.class self.eql?(other) elsif other.kind_of? self.class self.to_a.sort == other.to_a.sort else super end end |
#create ⇒ Object
Recursively create paths for all listed paths.
111 112 113 |
# File 'lib/build/files/system.rb', line 111 def create each(&:create) end |
#delete ⇒ Object
Recursively delete all paths and all contents within those paths.
116 117 118 |
# File 'lib/build/files/system.rb', line 116 def delete each(&:delete) end |
#exist? ⇒ Boolean
Check that all files listed exist.
106 107 108 |
# File 'lib/build/files/system.rb', line 106 def exist? all?(&:exist?) end |
#intersects?(other) ⇒ Boolean
Does this list of files include the path of any other?
54 55 56 |
# File 'lib/build/files/list.rb', line 54 def intersects? other other.any?{|path| include?(path)} end |
#rebase(root) ⇒ Object
74 75 76 |
# File 'lib/build/files/list.rb', line 74 def rebase(root) Paths.new(self.collect{|path| path.rebase(root)}, [root]) end |
#roots ⇒ Object
29 30 31 |
# File 'lib/build/files/list.rb', line 29 def roots collect{|path| path.root}.sort.uniq end |
#to_paths ⇒ Object
78 79 80 |
# File 'lib/build/files/list.rb', line 78 def to_paths Paths.new(each.to_a) end |
#to_s ⇒ Object
94 95 96 |
# File 'lib/build/files/list.rb', line 94 def to_s inspect end |
#touch ⇒ Object
Touch all listed files.
101 102 103 |
# File 'lib/build/files/system.rb', line 101 def touch each(&:touch) end |
#with(**options) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/build/files/list.rb', line 58 def with(**) return to_enum(:with, **) unless block_given? paths = [] self.each do |path| updated_path = path.with(**) yield path, updated_path paths << updated_path end return Paths.new(paths) end |