Class: Fylorg::Fileman
- Inherits:
-
Object
- Object
- Fylorg::Fileman
- Defined in:
- lib/fylorg/fileman.rb
Instance Method Summary collapse
Instance Method Details
#load_files_for_processing(opts) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/fylorg/fileman.rb', line 8 def load_files_for_processing(opts) files = String(opts[:types]).split(",").reduce([]) do |acc, filetype| acc + Dir[File.join(root_dir(opts), "**", "*.#{filetype}")] end [files, opts] end |
#relocate!(categorized_files, opts) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/fylorg/fileman.rb', line 16 def relocate!(categorized_files, opts) categorized_files.map do |category, files| category_path = File.join(opts[:out], category.to_s) FileUtils.mkdir(category_path) unless File.exists?(category_path) files.map do |categorized_file| unless File.realdirpath(File.dirname(categorized_file)) == File.realdirpath(category_path) FileUtils.mv(categorized_file, category_path) end end end end |