Class: LittleGhost::Workspace

Inherits:
Object
  • Object
show all
Defined in:
lib/little_ghost/workspace.rb

Overview

A Workspace gives an agent a concrete home for files. Pair it with a Sandbox to decide how those files may be read, changed, or used by commands.

workspace = LittleGhost::Workspace.new(root: "./tmp/support-run")
workspace.root # => an absolute path ending in "/tmp/support-run"

Workspaces participate in the run resource lifecycle. A custom workspace can provision storage in #open and release it in #close.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root:) ⇒ Workspace

Expands root to an absolute path.



14
15
16
# File 'lib/little_ghost/workspace.rb', line 14

def initialize(root:)
  @root = File.expand_path(root)
end

Instance Attribute Details

#rootObject (readonly)

Absolute filesystem root assigned to this workspace.



19
20
21
# File 'lib/little_ghost/workspace.rb', line 19

def root
  @root
end

Instance Method Details

#closeObject

Releases workspace resources. The default workspace has nothing to close.



27
28
29
# File 'lib/little_ghost/workspace.rb', line 27

def close
  nil
end

#open(run: nil) ⇒ Object

Opens any run-scoped resources and yields this workspace to the run.



22
23
24
# File 'lib/little_ghost/workspace.rb', line 22

def open(run: nil)
  self
end