Class: Organisir::Commands::MoveFiles
- Inherits:
-
Object
- Object
- Organisir::Commands::MoveFiles
- Defined in:
- lib/organisir/commands/move_files.rb
Instance Method Summary collapse
-
#initialize(source_dir, dest_dir, pwd, commit) ⇒ MoveFiles
constructor
A new instance of MoveFiles.
- #move ⇒ Object
Constructor Details
#initialize(source_dir, dest_dir, pwd, commit) ⇒ MoveFiles
Returns a new instance of MoveFiles.
6 7 8 9 10 11 12 13 |
# File 'lib/organisir/commands/move_files.rb', line 6 def initialize(source_dir, dest_dir, pwd, commit) @abs_source_dir = File.join(pwd, source_dir) @abs_dest_dir = File.join(pwd, dest_dir) Validator.validate_start(@abs_source_dir, @abs_dest_dir) @verbose = !commit @pwd = pwd end |
Instance Method Details
#move ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/organisir/commands/move_files.rb', line 15 def move sub_dirs = Util.get_sub_dirs(@abs_dest_dir) print("Scanned #{sub_dirs.length} directories in #{@abs_dest_dir}\n") src_files = get_src_files(@abs_source_dir) print("Scanned #{src_files.length} files in #{@abs_source_dir}\n") rule = Rule.new(sub_dirs) src_files.each do |f| match_dir = rule.match(f).try(:min) next if match_dir.nil? || match_dir.empty? process(f, match_dir) end end |