Class: Bazel::Runfiles
| Relationships & Source Files | |
| Namespace Children | |
|
Classes:
| |
| Inherits: | Object |
| Defined in: | rb/lib/bazel/runfiles.rb |
Overview
Resolves runtime paths to data dependencies using either a manifest file or a runfiles directory.
Class Method Summary
Instance Method Summary
Constructor Details
.new(strategy) ⇒ Runfiles
# File 'rb/lib/bazel/runfiles.rb', line 49
def initialize(strategy) @strategy = strategy end
Class Method Details
.create(env = ENV)
[ GitHub ]# File 'rb/lib/bazel/runfiles.rb', line 29
def self.create(env = ENV) manifest_file = env['RUNFILES_MANIFEST_FILE'] runfiles_dir = env['RUNFILES_DIR'] return new(ManifestBased.new(manifest_file)) if manifest_file && !manifest_file.empty? return new(DirectoryBased.new(runfiles_dir)) if runfiles_dir && !runfiles_dir.empty? create_from_program_name($PROGRAM_NAME) end
.create_from_program_name(program_name)
[ GitHub ]# File 'rb/lib/bazel/runfiles.rb', line 39
def self.create_from_program_name(program_name) if File.exist?("#{program_name}.runfiles_manifest") new(ManifestBased.new("#{program_name}.runfiles_manifest")) elsif File.exist?("#{program_name}.runfiles") new(DirectoryBased.new("#{program_name}.runfiles")) else new(DirectoryBased.new('')) end end
Instance Method Details
#rlocation(path)
# File 'rb/lib/bazel/runfiles.rb', line 53
def rlocation(path) raise ArgumentError, 'path must not be empty' if path.to_s.empty? return path if Pathname.new(path).absolute? invalid_path = %r{\A\.\.[/\\]|[/\\]\.\.[/\\]|\A\.[/\\]|[/\\]\.[/\\]|[/\\]\.\z|[/\\][/\\]} raise ArgumentError, "path is not valid: #{path.inspect}" if path.match?(invalid_path) raise ArgumentError, "path is absolute without a drive letter: #{path.inspect}" if path.start_with?('\\') @strategy.rlocation(path) end