Sha256: 959e0894d036e0030ab1158919bd1da469f4e7d80a13962b9a9646047ebe706b

Contents?: true

Size: 737 Bytes

Versions: 11

Compression:

Stored size: 737 Bytes

Contents

# frozen_string_literal: true

# check if a file is readable
Puppet::Functions.create_function(:'file::readable', Puppet::Functions::InternalFunction) do
  # @param filename Absolute path or Puppet file path.
  # @example Check a file on disk
  #   file::readable('/tmp/i_dumped_this_here')
  # @example check a file from the modulepath
  #   file::readable('example/files/VERSION')
  dispatch :readable do
    scope_param
    required_param 'String', :filename
    return_type 'Boolean'
  end

  def readable(scope, filename)
    Puppet.lookup(:bolt_executor) {}&.report_function_call(self.class.name)
    found = Puppet::Parser::Files.find_file(filename, scope.compiler.environment)
    found ? File.readable?(found) : false
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
bolt-1.49.0 bolt-modules/file/lib/puppet/functions/file/readable.rb
bolt-1.48.0 bolt-modules/file/lib/puppet/functions/file/readable.rb
bolt-1.47.0 bolt-modules/file/lib/puppet/functions/file/readable.rb
bolt-1.45.0 bolt-modules/file/lib/puppet/functions/file/readable.rb
bolt-1.44.0 bolt-modules/file/lib/puppet/functions/file/readable.rb
bolt-1.43.0 bolt-modules/file/lib/puppet/functions/file/readable.rb
bolt-1.42.0 bolt-modules/file/lib/puppet/functions/file/readable.rb
bolt-1.41.0 bolt-modules/file/lib/puppet/functions/file/readable.rb
bolt-1.40.0 bolt-modules/file/lib/puppet/functions/file/readable.rb
bolt-1.39.0 bolt-modules/file/lib/puppet/functions/file/readable.rb
bolt-1.38.0 bolt-modules/file/lib/puppet/functions/file/readable.rb