Class: Bazel::Runfiles::ManifestBased
| Relationships & Source Files | |
| Inherits: | Object |
| Defined in: | rb/lib/bazel/runfiles.rb |
Overview
Resolves paths by looking them up in a runfiles MANIFEST file.
Class Method Summary
- .new(manifest_path) ⇒ ManifestBased constructor
Instance Method Summary
- #rlocation(path)
- #parse_entry(line) private
- #parse_manifest(path) private
- #unescape(str) private
Constructor Details
.new(manifest_path) ⇒ ManifestBased
# File 'rb/lib/bazel/runfiles.rb', line 68
def initialize(manifest_path) @entries = parse_manifest(manifest_path) end
Instance Method Details
#parse_entry(line) (private)
[ GitHub ]#parse_manifest(path) (private)
[ GitHub ]# File 'rb/lib/bazel/runfiles.rb', line 88
def parse_manifest(path) entries = {} return entries unless File.exist?(path) File.foreach(path) do |line| line.chomp! next if line.empty? key, value = parse_entry(line) entries[key] = value end entries end
#rlocation(path)
[ GitHub ]# File 'rb/lib/bazel/runfiles.rb', line 72
def rlocation(path) return @entries[path] if @entries.key?(path) prefix = File.dirname(path) while prefix != '.' && prefix != '/' base = @entries[prefix] return "#{base}#{path[prefix.length..]}" if base && !base.empty? prefix = File.dirname(prefix) end nil end
#unescape(str) (private)
[ GitHub ]# File 'rb/lib/bazel/runfiles.rb', line 111
def unescape(str) str.gsub(/\\[snb]/, '\s' => ' ', '\n' => "\n", '\b' => '\\') end