Class: Planter::FileList
- Inherits:
-
Object
- Object
- Planter::FileList
- Defined in:
- lib/planter/filelist.rb
Overview
File listing class
Instance Attribute Summary collapse
-
#files ⇒ Object
readonly
Returns the value of attribute files.
Instance Method Summary collapse
-
#copy ⇒ Boolean
Public method for copying @files to target based on their operator.
-
#initialize(path = Planter.base_dir) ⇒ FileList
constructor
Initialize a new FileList object.
Constructor Details
#initialize(path = Planter.base_dir) ⇒ FileList
Initialize a new FileList object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/planter/filelist.rb', line 13 def initialize(path = Planter.base_dir) @basedir = File.realdirpath(path) search_path = File.join(@basedir, '**/*') files = Dir.glob(search_path, File::FNM_DOTMATCH).reject do |file| file =~ %r{/(_scripts|\.git|_config\.yml$|\.{1,2}$)} end files.sort_by!(&:length) @files = files.map do |file| new_file = "#{Planter.target}#{file.sub(/^#{@basedir}/, '').apply_variables.apply_regexes}" operation = Planter.overwrite ? :overwrite : :copy FileEntry.new(file, new_file, operation) end prepare_copy end |
Instance Attribute Details
#files ⇒ Object (readonly)
Returns the value of attribute files.
6 7 8 |
# File 'lib/planter/filelist.rb', line 6 def files @files end |
Instance Method Details
#copy ⇒ Boolean
Public method for copying @files to target based on their operator
37 38 39 40 41 42 43 44 |
# File 'lib/planter/filelist.rb', line 37 def copy @files.each do |file| handle_operator(file) end rescue StandardError => e Planter.notify("#{e}\n#{e.backtrace}", :debug, above_spinner: true) Planter.notify('Error copying files/directories', :error, exit_code: 128) end |