Module: Textus::Protocol::Key::Path

Defined in:
lib/textus/protocol/key/path.rb

Class Method Summary collapse

Class Method Details

.normalize_relative_path(path) ⇒ Object



15
16
17
18
19
# File 'lib/textus/protocol/key/path.rb', line 15

def self.normalize_relative_path(path)
  return path if path.start_with?("data/")

  File.join("data", path)
end

.resolve(data, mentry) ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'lib/textus/protocol/key/path.rb', line 5

def self.resolve(data, mentry)
  primary_ext = Textus::Protocol::Format.for(mentry.format).extensions.first
  rel_path = normalize_relative_path(mentry.path)
  if File.extname(mentry.path) == ""
    File.join(data.root, rel_path + primary_ext)
  else
    File.join(data.root, rel_path)
  end
end