Class: BackupOrganizer::Setup

Inherits:
Object
  • Object
show all
Defined in:
lib/backup_organizer/setup.rb

Class Method Summary collapse

Class Method Details

.create_structure(configuration) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/backup_organizer/setup.rb', line 5

def self.create_structure(configuration)
  @configuration = configuration
  raise Error::InvalidPathError unless File.exist?(@configuration.path) && File.directory?(@configuration.path)

  @configuration.directories.each do |necessary_directory|
    next if File.directory?(necessary_directory)
    raise Error::SetupError.new('`#{necessary_directory}` should be a directory but is a file.') if File.exist?(necessary_directory)
    BackupOrganizer::FileUtils.mkdir(necessary_directory)
  end
end