Class: Teapot::Build::FileList
- Inherits:
-
Object
- Object
- Teapot::Build::FileList
- Includes:
- Enumerable
- Defined in:
- lib/teapot/build/file_list.rb
Instance Attribute Summary collapse
-
#pattern ⇒ Object
readonly
Returns the value of attribute pattern.
-
#prefix ⇒ Object
readonly
Returns the value of attribute prefix.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Class Method Summary collapse
Instance Method Summary collapse
- #copy(destination) ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(root, pattern, prefix = nil) ⇒ FileList
constructor
A new instance of FileList.
Constructor Details
Instance Attribute Details
#pattern ⇒ Object (readonly)
Returns the value of attribute pattern.
40 41 42 |
# File 'lib/teapot/build/file_list.rb', line 40 def pattern @pattern end |
#prefix ⇒ Object (readonly)
Returns the value of attribute prefix.
41 42 43 |
# File 'lib/teapot/build/file_list.rb', line 41 def prefix @prefix end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
39 40 41 |
# File 'lib/teapot/build/file_list.rb', line 39 def root @root end |
Class Method Details
Instance Method Details
#copy(destination) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/teapot/build/file_list.rb', line 47 def copy(destination) self.each do |path| # Compute the destination path, which is formed using the relative path: relative_path = path.relative_path_from(@root) destination_path = destination + @prefix + relative_path if path.directory? # Make a directory at the destination: destination_path.mkpath else # Make the path if it doesn't already exist: destination_path.dirname.mkpath # Copy the file to the destination: FileUtils.cp(path, destination_path, :preserve => true) end end end |
#each(&block) ⇒ Object
43 44 45 |
# File 'lib/teapot/build/file_list.rb', line 43 def each(&block) Pathname.glob(@root + @pattern).each &block end |