class VFS::FileCollector

vfs gen

Public Class Methods

new(entry) click to toggle source
# File lib/yaml-vfs/file_collector.rb, line 36
def initialize(entry)
  raise ArgumentError, 'entry must not empty' if entry.empty?

  @entry = entry
  @vfs_writer = YAMLVFSWriter.new
end

Public Instance Methods

write_mapping(name) click to toggle source
# File lib/yaml-vfs/file_collector.rb, line 43
def write_mapping(name)
  add_write_file
  @vfs_writer.case_sensitive = false
  path = Pathname(name).expand_path
  path = path.join('all-product-headers.yaml') if path.directory?
  stream = @vfs_writer.write
  path.dirname.mkpath
  File.open(path, 'w') { |f| f.write(stream) }
end

Private Instance Methods

add_write_file() click to toggle source
# File lib/yaml-vfs/file_collector.rb, line 55
def add_write_file
  wirte_f = lambda { |framework_path, dir, files|
    return if dir.empty?

    paths = framework_path.join(dir)
    files.each do |file|
      path = paths.join(file.basename)
      @vfs_writer.add_file_mapping(path, file)
    end
  }
  @entry.each do |entry|
    wirte_f.call(entry.framework_path, 'Headers', entry.real_headers)
    wirte_f.call(entry.framework_path, 'Modules', entry.real_modules)
  end
end