Method: Pledge#unveil_without_lock

Defined in:
lib/unveil.rb

#unveil_without_lock(paths) ⇒ Object

Same as unveil, but allows for future calls to unveil or unveil_without_lock.

Raises:

  • (NotImplementedError)


38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/unveil.rb', line 38

def unveil_without_lock(paths)
  # :nocov:
  raise NotImplementedError, "unveil not supported" unless Pledge.respond_to?(:_unveil, true)
  # :nocov:

  paths = Hash[paths]

  paths.to_a.each do |path, perm|
    unless path.is_a?(String)
      raise UnveilError, "unveil path is not a string: #{path.inspect}"
    end

    case perm
    when :gem
      unless spec = Gem.loaded_specs[path]
        raise UnveilError, "cannot unveil gem #{path} as it is not loaded"
      end

      paths.delete(path)
      paths[spec.full_gem_path] = 'r'
    when String
      # nothing to do
    else
      raise UnveilError, "unveil permission is not a string: #{perm.inspect}"
    end
  end

  paths.each do |path, perm|
    _unveil(path, perm)
  end

  nil
end