Class: Yoda::Server::RootlessWorkspace

Inherits:
Object
  • Object
show all
Defined in:
lib/yoda/server/rootless_workspace.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:) ⇒ RootlessWorkspace

Returns a new instance of RootlessWorkspace.

Parameters:

  • name (String)


10
11
12
# File 'lib/yoda/server/rootless_workspace.rb', line 10

def initialize(name:)
  @name = name
end

Instance Attribute Details

#nameString (readonly)

Returns:

  • (String)


7
8
9
# File 'lib/yoda/server/rootless_workspace.rb', line 7

def name
  @name
end

Instance Method Details

#file_treeStore::FileTree

Returns:



57
58
59
# File 'lib/yoda/server/rootless_workspace.rb', line 57

def file_tree
  project.file_tree
end

#projectStore::Project?

Returns:



19
20
21
# File 'lib/yoda/server/rootless_workspace.rb', line 19

def project
  @project ||= Store::Project.temporal(name: name)
end

#read_at(uri) ⇒ String?

Parameters:

  • uri (String)

Returns:

  • (String, nil)


30
31
32
33
# File 'lib/yoda/server/rootless_workspace.rb', line 30

def read_at(uri)
  path = UriDecoder.path_of_uri(uri)
  path && file_tree.read_at(path)
end

#read_source(uri) ⇒ Object

Parameters:

  • path


36
37
38
39
# File 'lib/yoda/server/rootless_workspace.rb', line 36

def read_source(uri)
  path = UriDecoder.path_of_uri(uri)
  file_tree.clear_editing_at(path)
end

#setupObject



14
15
16
# File 'lib/yoda/server/rootless_workspace.rb', line 14

def setup
  project.setup
end

#store_source(uri:, source:) ⇒ Object

Parameters:

  • uri (String)
  • source (String)


43
44
45
46
# File 'lib/yoda/server/rootless_workspace.rb', line 43

def store_source(uri:, source:)
  path = UriDecoder.path_of_uri(uri)
  file_tree.set_editing_at(path, source)
end

#subpath?(path) ⇒ Boolean

Returns:

  • (Boolean)


52
53
54
# File 'lib/yoda/server/rootless_workspace.rb', line 52

def subpath?(path)
  true
end

#suburi?(uri) ⇒ Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/yoda/server/rootless_workspace.rb', line 48

def suburi?(uri)
  true
end

#uri_of_path(path) ⇒ Object

Parameters:

  • path (String)


24
25
26
# File 'lib/yoda/server/rootless_workspace.rb', line 24

def uri_of_path(path)
  FileStore.uri_of_path(File.expand_path(path))
end