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.
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.
- #copy(destination) ⇒ Object
-
#create ⇒ Object
Recursively create paths for all listed paths.
-
#delete ⇒ Object
Recursively delete all paths and all contents within those paths.
- #empty? ⇒ Boolean
-
#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:
19 20 21 |
# File 'lib/build/files/list.rb', line 19 def +(list) Composite.new([self, list]) end |
#-(list) ⇒ Object
23 24 25 |
# File 'lib/build/files/list.rb', line 23 def -(list) Difference.new(self, list) end |
#==(other) ⇒ Object
This isn’t very efficient, but it IS generic.
28 29 30 31 32 33 34 35 36 |
# File 'lib/build/files/list.rb', line 28 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 |
#copy(destination) ⇒ Object
113 114 115 116 117 |
# File 'lib/build/files/system.rb', line 113 def copy(destination) each do |path| path.copy(destination / path.relative_path) end end |
#create ⇒ Object
Recursively create paths for all listed paths.
104 105 106 |
# File 'lib/build/files/system.rb', line 104 def create each(&:create) end |
#delete ⇒ Object
Recursively delete all paths and all contents within those paths.
109 110 111 |
# File 'lib/build/files/system.rb', line 109 def delete each(&:delete) end |
#empty? ⇒ Boolean
43 44 45 46 47 48 49 |
# File 'lib/build/files/list.rb', line 43 def empty? each do return false end return true end |
#exist? ⇒ Boolean
Check that all files listed exist.
99 100 101 |
# File 'lib/build/files/system.rb', line 99 def exist? all?(&:exist?) end |
#intersects?(other) ⇒ Boolean
Does this list of files include the path of any other?
39 40 41 |
# File 'lib/build/files/list.rb', line 39 def intersects? other other.any?{|path| include?(path)} end |
#rebase(root) ⇒ Object
67 68 69 |
# File 'lib/build/files/list.rb', line 67 def rebase(root) Paths.new(self.collect{|path| path.rebase(root)}, [root]) end |
#roots ⇒ Object
14 15 16 |
# File 'lib/build/files/list.rb', line 14 def roots collect{|path| path.root}.sort.uniq end |
#to_paths ⇒ Object
71 72 73 |
# File 'lib/build/files/list.rb', line 71 def to_paths Paths.new(each.to_a) end |
#to_s ⇒ Object
87 88 89 |
# File 'lib/build/files/list.rb', line 87 def to_s inspect end |
#touch ⇒ Object
Touch all listed files.
94 95 96 |
# File 'lib/build/files/system.rb', line 94 def touch each(&:touch) end |
#with(**options) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/build/files/list.rb', line 51 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 |