class VFS::YAMLVFSWriter

YAMLVFSWriter class. @see llvm.org/doxygen/classllvm_1_1vfs_1_1YAMLVFSWriter.html @abstract

Attributes

case_sensitive[RW]
dir_stack[R]
mappings[R]
overlay_dir[R]
overlay_relative[R]
use_external_names[RW]

Public Class Methods

new() click to toggle source
# File lib/yaml-vfs/yaml_vfs.rb, line 35
def initialize
  @mappings = []
end

Public Instance Methods

add_directory_mapping(virtual_path, real_path) click to toggle source
# File lib/yaml-vfs/yaml_vfs.rb, line 51
def add_directory_mapping(virtual_path, real_path)
  add_entry(virtual_path, real_path, true)
end
add_entry(virtual_path, real_path, is_directory) click to toggle source
# File lib/yaml-vfs/yaml_vfs.rb, line 39
def add_entry(virtual_path, real_path, is_directory)
  raise ArgumentError, 'virtual path not absolute' unless virtual_path.absolute?
  raise ArgumentError, 'real path not absolute' unless real_path.absolute?
  raise ArgumentError, 'path traversal is not supported' if Utils.traversal_component?(virtual_path)

  mappings << YAMLVFSEntry.new(virtual_path, real_path, directory: is_directory)
end
add_file_mapping(virtual_path, real_path) click to toggle source
# File lib/yaml-vfs/yaml_vfs.rb, line 47
def add_file_mapping(virtual_path, real_path)
  add_entry(virtual_path, real_path, false)
end
overlay_dir=(overlay_dir) click to toggle source
# File lib/yaml-vfs/yaml_vfs.rb, line 30
def overlay_dir=(overlay_dir)
  @overlay_relative = true
  @overlay_dir = overlay_dir
end
write() click to toggle source
# File lib/yaml-vfs/yaml_vfs.rb, line 55
def write
  @mappings.sort_by! { |p| p.v_path.to_s }
  JSONWriter.new.write(@mappings, @use_external_names, @case_sensitive, @overlay_relative, @overlay_dir)
end