Sha256: 649287b4c33e7a9ecb114ac213110f844a443f2037aeeeb0666829db0493f05b

Contents?: true

Size: 729 Bytes

Versions: 162

Compression:

Stored size: 729 Bytes

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
  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

162 entries across 162 versions & 2 rubygems

Version Path
puppet-retrospec-1.5.0 vendor/gems/puppet-4.5.2/lib/puppet/settings/file_or_directory_setting.rb
puppet-retrospec-1.4.1 vendor/gems/puppet-4.5.2/lib/puppet/settings/file_or_directory_setting.rb
puppet-retrospec-1.4.0 vendor/gems/puppet-4.5.2/lib/puppet/settings/file_or_directory_setting.rb
puppet-retrospec-1.3.2 vendor/gems/puppet-4.5.2/lib/puppet/settings/file_or_directory_setting.rb
puppet-retrospec-1.3.1 vendor/gems/puppet-4.5.2/lib/puppet/settings/file_or_directory_setting.rb
puppet-retrospec-1.3.0 vendor/gems/puppet-4.5.2/lib/puppet/settings/file_or_directory_setting.rb
puppet-4.8.2 lib/puppet/settings/file_or_directory_setting.rb
puppet-4.8.2-x86-mingw32 lib/puppet/settings/file_or_directory_setting.rb
puppet-4.8.2-x64-mingw32 lib/puppet/settings/file_or_directory_setting.rb
puppet-4.8.2-universal-darwin lib/puppet/settings/file_or_directory_setting.rb
puppet-4.7.1 lib/puppet/settings/file_or_directory_setting.rb
puppet-4.7.1-x86-mingw32 lib/puppet/settings/file_or_directory_setting.rb
puppet-4.7.1-x64-mingw32 lib/puppet/settings/file_or_directory_setting.rb
puppet-4.7.1-universal-darwin lib/puppet/settings/file_or_directory_setting.rb
puppet-4.8.1 lib/puppet/settings/file_or_directory_setting.rb
puppet-4.8.1-x86-mingw32 lib/puppet/settings/file_or_directory_setting.rb
puppet-4.8.1-x64-mingw32 lib/puppet/settings/file_or_directory_setting.rb
puppet-4.8.1-universal-darwin lib/puppet/settings/file_or_directory_setting.rb
puppet-4.8.0 lib/puppet/settings/file_or_directory_setting.rb
puppet-4.8.0-x86-mingw32 lib/puppet/settings/file_or_directory_setting.rb