Class: Imap::Backup::Serializer::Directory

Inherits:
Object
  • Object
show all
Defined in:
lib/imap/backup/serializer/directory.rb

Constant Summary collapse

DIRECTORY_PERMISSIONS =
0o700

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, relative) ⇒ Directory

Returns a new instance of Directory.


12
13
14
15
# File 'lib/imap/backup/serializer/directory.rb', line 12

def initialize(path, relative)
  @path = path
  @relative = relative
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.


10
11
12
# File 'lib/imap/backup/serializer/directory.rb', line 10

def path
  @path
end

#relativeObject (readonly)

Returns the value of attribute relative.


9
10
11
# File 'lib/imap/backup/serializer/directory.rb', line 9

def relative
  @relative
end

Instance Method Details

#ensure_existsObject


17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/imap/backup/serializer/directory.rb', line 17

def ensure_exists
  if !File.directory?(full_path)
    Utils.make_folder(
      path, relative, DIRECTORY_PERMISSIONS
    )
  end

  return if OS.windows?
  return if Utils.mode(full_path) == DIRECTORY_PERMISSIONS

  FileUtils.chmod DIRECTORY_PERMISSIONS, full_path
end