Class: Textus::Store::Geometry

Inherits:
Object
  • Object
show all
Defined in:
lib/textus/store/geometry.rb

Constant Summary collapse

RUN =
".state"
DATA =
"data"
ASSETS =
"assets"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root) ⇒ Geometry

Returns a new instance of Geometry.



8
9
10
11
# File 'lib/textus/store/geometry.rb', line 8

def initialize(root)
  @root = root
  freeze
end

Instance Attribute Details

#rootObject (readonly)

Returns the value of attribute root.



13
14
15
# File 'lib/textus/store/geometry.rb', line 13

def root
  @root
end

Instance Method Details

#asset_path(kind, date_str, zone, filename) ⇒ Object

– asset paths –



39
40
41
# File 'lib/textus/store/geometry.rb', line 39

def asset_path(kind, date_str, zone, filename)
  File.join(@root, ASSETS, kind, date_str, zone.to_s, filename)
end

#audit_dir_pathObject



33
# File 'lib/textus/store/geometry.rb', line 33

def audit_dir_path     = File.join(run_root, "audit")

#audit_log_pathObject



34
# File 'lib/textus/store/geometry.rb', line 34

def audit_log_path     = File.join(audit_dir_path, "audit.log")

#cursor_path(role) ⇒ Object



31
# File 'lib/textus/store/geometry.rb', line 31

def cursor_path(role)  = File.join(run_root, "ephemeral", "cursors", role.to_s)

#data_rootObject

– data paths –



16
# File 'lib/textus/store/geometry.rb', line 16

def data_root = File.join(@root, DATA)

#entry_path(mentry) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/textus/store/geometry.rb', line 19

def entry_path(mentry)
  primary_ext = Format.for(mentry.format).extensions.first
  rel = normalize_relative_path(mentry.path)
  if File.extname(mentry.path) == ""
    File.join(@root, rel + primary_ext)
  else
    File.join(@root, rel)
  end
end

#gitignore_body(untracked_entries: []) ⇒ Object

– gitignore –



53
54
55
56
57
58
59
60
61
# File 'lib/textus/store/geometry.rb', line 53

def gitignore_body(untracked_entries: [])
  lines = ["# textus runtime artifacts — safe to delete, never commit",
           "#{RUN}/"]
  unless untracked_entries.empty?
    lines << "# tracked:false entries — protocol-readable, not committed"
    lines.concat(untracked_entries)
  end
  "#{lines.join("\n")}\n"
end

#hooks_dirObject



49
# File 'lib/textus/store/geometry.rb', line 49

def hooks_dir        = File.join(@root, "hooks")

#lane_floor(path) ⇒ Object

– lane boundary (replaces Writer#zone_floor) –



64
65
66
67
68
69
70
# File 'lib/textus/store/geometry.rb', line 64

def lane_floor(path)
  prefix = "#{data_root}/"
  return nil unless path.start_with?(prefix)

  seg = path.delete_prefix(prefix).split("/").first
  seg && File.join(data_root, seg)
end

#lane_path(lane_name) ⇒ Object



17
# File 'lib/textus/store/geometry.rb', line 17

def lane_path(lane_name) = File.join(data_root, lane_name.to_s)

#lock_path(name) ⇒ Object



32
# File 'lib/textus/store/geometry.rb', line 32

def lock_path(name)    = File.join(run_root, "ephemeral", "locks", "#{name}.lock")

#manifest_pathObject

– config paths –



44
# File 'lib/textus/store/geometry.rb', line 44

def manifest_path = File.join(@root, "manifest.yaml")

#run_rootObject

– runtime paths –



30
# File 'lib/textus/store/geometry.rb', line 30

def run_root           = File.join(@root, RUN)

#schema_path(name) ⇒ Object



46
# File 'lib/textus/store/geometry.rb', line 46

def schema_path(name) = File.join(schemas_dir, "#{name}.yaml")

#schemas_dirObject



45
# File 'lib/textus/store/geometry.rb', line 45

def schemas_dir = File.join(@root, "schemas")

#schemas_globObject



50
# File 'lib/textus/store/geometry.rb', line 50

def schemas_glob     = File.join(schemas_dir, "**", "*")

#sentinels_rootObject



35
# File 'lib/textus/store/geometry.rb', line 35

def sentinels_root = File.join(run_root, "tracking", "sentinels")

#store_db_pathObject



36
# File 'lib/textus/store/geometry.rb', line 36

def store_db_path = File.join(run_root, "store.db")

#template_path(name) ⇒ Object



47
# File 'lib/textus/store/geometry.rb', line 47

def template_path(name) = File.join(@root, "templates", name)

#workflow_dirObject



48
# File 'lib/textus/store/geometry.rb', line 48

def workflow_dir     = File.join(@root, "workflows")