Module: MotherBrain::FileSystem

Defined in:
lib/mb/file_system.rb,
lib/mb/file_system/tempfile.rb

Defined Under Namespace

Classes: Tempfile

Class Method Summary collapse

Class Method Details

.initObject

Create the directory structure for motherbrain



9
10
11
12
13
14
15
# File 'lib/mb/file_system.rb', line 9

def init
  FileUtils.mkdir_p(logs)
  FileUtils.mkdir_p(manifests)
  FileUtils.mkdir_p(root)
  FileUtils.mkdir_p(templates)
  FileUtils.mkdir_p(tmp)
end

.logsPathname

Returns:

  • (Pathname)


18
19
20
# File 'lib/mb/file_system.rb', line 18

def logs
  root.join("logs")
end

.manifestsPathname

Returns:

  • (Pathname)


23
24
25
# File 'lib/mb/file_system.rb', line 23

def manifests
  root.join("manifests")
end

.rootPathname

Returns:

  • (Pathname)


28
29
30
# File 'lib/mb/file_system.rb', line 28

def root
  Pathname.new(default_root_path)
end

.templatesPathname

Returns:

  • (Pathname)


38
39
40
# File 'lib/mb/file_system.rb', line 38

def templates
  root.join("templates")
end

.tmpPathname

Returns:

  • (Pathname)


33
34
35
# File 'lib/mb/file_system.rb', line 33

def tmp
  root.join("tmp")
end

.tmpdir(prefix = nil) ⇒ String

Create a temporary directory in the tmp directory of the motherbrain file system

Parameters:

  • prefix (String) (defaults to: nil)

    (nil) a prefix suffix to attach to name of the generated directory

Returns:

  • (String)


49
50
51
# File 'lib/mb/file_system.rb', line 49

def tmpdir(prefix = nil)
  Dir.mktmpdir(prefix, tmp)
end