Sha256: 598825292a7238f0885aff64214fee6d7b3acb1c95e4c60e6551c054df0a0994

Contents?: true

Size: 730 Bytes

Versions: 20

Compression:

Stored size: 730 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)
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
bolt-1.37.0 bolt-modules/file/lib/puppet/functions/file/readable.rb
bolt-1.36.0 bolt-modules/file/lib/puppet/functions/file/readable.rb
bolt-1.35.0 bolt-modules/file/lib/puppet/functions/file/readable.rb
bolt-1.34.0 bolt-modules/file/lib/puppet/functions/file/readable.rb
bolt-1.33.0 bolt-modules/file/lib/puppet/functions/file/readable.rb
bolt-1.32.0 bolt-modules/file/lib/puppet/functions/file/readable.rb
bolt-1.31.1 bolt-modules/file/lib/puppet/functions/file/readable.rb
bolt-1.31.0 bolt-modules/file/lib/puppet/functions/file/readable.rb
bolt-1.30.1 bolt-modules/file/lib/puppet/functions/file/readable.rb
bolt-1.30.0 bolt-modules/file/lib/puppet/functions/file/readable.rb
bolt-1.29.1 bolt-modules/file/lib/puppet/functions/file/readable.rb
bolt-1.29.0 bolt-modules/file/lib/puppet/functions/file/readable.rb
bolt-1.28.0 bolt-modules/file/lib/puppet/functions/file/readable.rb
bolt-1.27.1 bolt-modules/file/lib/puppet/functions/file/readable.rb
bolt-1.27.0 bolt-modules/file/lib/puppet/functions/file/readable.rb
bolt-1.26.0 bolt-modules/file/lib/puppet/functions/file/readable.rb
bolt-1.25.0 bolt-modules/file/lib/puppet/functions/file/readable.rb
bolt-1.24.0 bolt-modules/file/lib/puppet/functions/file/readable.rb
bolt-1.23.0 bolt-modules/file/lib/puppet/functions/file/readable.rb
bolt-1.22.0 bolt-modules/file/lib/puppet/functions/file/readable.rb