Class: MagicShelf::DirStructureFlattener

Inherits:
Object
  • Object
show all
Defined in:
lib/magicshelf/dirstructureflattener.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#workdirObject

Returns the value of attribute workdir.



7
8
9
# File 'lib/magicshelf/dirstructureflattener.rb', line 7

def workdir
  @workdir
end

Instance Method Details

#enterObject



8
9
10
# File 'lib/magicshelf/dirstructureflattener.rb', line 8

def enter()
  yield
end

#processObject



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/magicshelf/dirstructureflattener.rb', line 12

def process()
  @workdir ||= Dir.pwd
  Dir.glob(File.join(@workdir,'**/*')).select{|f|File.file?(f)}.each do |f|
    begin
      FileUtils.mv f, @workdir
    rescue => e
      MagicShelf.logger.warn(e.message)
    end

  end
end