Module: Pdfrb::DataDir

Defined in:
lib/pdfrb/data_dir.rb

Overview

Resolves the gem's bundled data directory (Arlington TSVs, AFM metrics, default fonts, ICC profiles). Data lives under data/pdfrb/ in the gem, which gem-install places on the load path alongside lib/.

Constant Summary collapse

DELIMITER =
"/"

Class Method Summary collapse

Class Method Details

.arlington(version = "latest") ⇒ Object

Path to the vendored Arlington TSV set for a given PDF version (or "latest"). Versions live under data/pdfrb/arlington/.



30
31
32
# File 'lib/pdfrb/data_dir.rb', line 30

def arlington(version = "latest")
  File.join(root, "arlington", version)
end

.resolve(*segments) ⇒ Object

Resolve a path inside the data root. Raises if the file does not exist; this is a deployment error, not a user error.



19
20
21
22
23
24
25
26
# File 'lib/pdfrb/data_dir.rb', line 19

def resolve(*segments)
  path = File.join(root, *segments)
  unless File.exist?(path)
    raise Error, "missing data file: #{segments.join(DELIMITER)}"
  end

  path
end

.rootObject

Absolute path to the gem's data root.



13
14
15
# File 'lib/pdfrb/data_dir.rb', line 13

def root
  File.expand_path("../../data/pdfrb", __dir__)
end