Sha256: 34173e4b886bda16f79b7534e03861c5c15aca5938df07aa9cbbd82a45d8f04f

Contents?: true

Size: 1.01 KB

Versions: 583

Compression:

Stored size: 1.01 KB

Contents

class Puppet::Settings::FileOrDirectorySetting < Puppet::Settings::FileSetting

  def initialize(args)
    super
  end

  def type
    if Puppet::FileSystem.directory?(self.value) || @path_ends_with_slash
      :directory
    else
      :file
    end
  end

  # Overrides munge to be able to read the un-munged value (the FileSetting.munch removes trailing slash)
  #
  def munge(value)
    if value.is_a?(String) && value =~ /[\\\/]$/
      @path_ends_with_slash = true
    end
    super
  end

  # @api private
  #
  # @param option [String] Extra file operation mode information to use
  #   (defaults to read-only mode 'r')
  #   This is the standard mechanism Ruby uses in the IO class, and therefore
  #   encoding may be explicitly like fmode : encoding or fmode : "BOM|UTF-*"
  #   for example, a:ASCII or w+:UTF-8
  def open_file(filename, option = 'r', &block)
    if type == :file
      super
    else
      controlled_access do |mode|
        Puppet::FileSystem.open(filename, mode, option, &block)
      end
    end
  end
end

Version data entries

583 entries across 583 versions & 3 rubygems

Version Path
puppet-6.25.0 lib/puppet/settings/file_or_directory_setting.rb
puppet-6.25.0-x86-mingw32 lib/puppet/settings/file_or_directory_setting.rb
puppet-6.25.0-x64-mingw32 lib/puppet/settings/file_or_directory_setting.rb
puppet-6.25.0-universal-darwin lib/puppet/settings/file_or_directory_setting.rb
puppet-7.11.0 lib/puppet/settings/file_or_directory_setting.rb
puppet-7.11.0-x86-mingw32 lib/puppet/settings/file_or_directory_setting.rb
puppet-7.11.0-x64-mingw32 lib/puppet/settings/file_or_directory_setting.rb
puppet-7.11.0-universal-darwin lib/puppet/settings/file_or_directory_setting.rb
puppet-7.10.0 lib/puppet/settings/file_or_directory_setting.rb
puppet-7.10.0-x86-mingw32 lib/puppet/settings/file_or_directory_setting.rb
puppet-7.10.0-x64-mingw32 lib/puppet/settings/file_or_directory_setting.rb
puppet-7.10.0-universal-darwin lib/puppet/settings/file_or_directory_setting.rb
puppet-6.24.0 lib/puppet/settings/file_or_directory_setting.rb
puppet-6.24.0-x86-mingw32 lib/puppet/settings/file_or_directory_setting.rb
puppet-6.24.0-x64-mingw32 lib/puppet/settings/file_or_directory_setting.rb
puppet-6.24.0-universal-darwin lib/puppet/settings/file_or_directory_setting.rb
puppet-7.9.0 lib/puppet/settings/file_or_directory_setting.rb
puppet-7.9.0-x86-mingw32 lib/puppet/settings/file_or_directory_setting.rb
puppet-7.9.0-x64-mingw32 lib/puppet/settings/file_or_directory_setting.rb
puppet-7.9.0-universal-darwin lib/puppet/settings/file_or_directory_setting.rb