Sha256: 35d73af5296f3934bab960994bbfa3a4f982dbc4e66ee31a6b015cc47935b929

Contents?: true

Size: 1.02 KB

Versions: 10

Compression:

Stored size: 1.02 KB

Contents

class Puppet::FileSystem::MemoryImpl
  def initialize(*files)
    @files = files + all_children_of(files)
  end

  def exist?(path)
    path.exist?
  end

  def directory?(path)
    path.directory?
  end

  def file?(path)
    path.file?
  end

  def executable?(path)
    path.executable?
  end

  def children(path)
    path.children
  end

  def each_line(path, &block)
    path.each_line(&block)
  end

  def pathname(path)
    find(path)
  end

  def basename(path)
    path.duplicate_as(File.basename(path_string(path)))
  end

  def path_string(object)
    object.path
  end

  def assert_path(path)
    if path.is_a?(Puppet::FileSystem::MemoryFile)
      path
    else
      find(path) or raise ArgumentError, "Unable to find registered object for #{path.inspect}"
    end
  end

  private

  def find(path)
    @files.find { |file| file.path == path }
  end

  def all_children_of(files)
    children = files.collect(&:children).flatten
    if children.empty?
      []
    else
      children + all_children_of(children)
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
puppet-3.5.1 lib/puppet/file_system/memory_impl.rb
puppet-3.5.1-x86-mingw32 lib/puppet/file_system/memory_impl.rb
puppet-3.5.1.rc1 lib/puppet/file_system/memory_impl.rb
puppet-3.5.1.rc1-x86-mingw32 lib/puppet/file_system/memory_impl.rb
puppet-3.5.0.rc3 lib/puppet/file_system/memory_impl.rb
puppet-3.5.0.rc3-x86-mingw32 lib/puppet/file_system/memory_impl.rb
puppet-3.5.0.rc2 lib/puppet/file_system/memory_impl.rb
puppet-3.5.0.rc2-x86-mingw32 lib/puppet/file_system/memory_impl.rb
puppet-3.5.0.rc1 lib/puppet/file_system/memory_impl.rb
puppet-3.5.0.rc1-x86-mingw32 lib/puppet/file_system/memory_impl.rb