Class: Puppet::FileServing::Fileset::FileSetEntry

Inherits:
Struct
  • Object
show all
Defined in:
lib/puppet/file_serving/fileset.rb

Instance Method Summary collapse

Instance Method Details

#basenameObject



134
135
136
# File 'lib/puppet/file_serving/fileset.rb', line 134

def basename
  File.basename(path)
end

#childrenObject



138
139
140
141
142
143
144
# File 'lib/puppet/file_serving/fileset.rb', line 138

def children
  return [] unless directory?

  Dir.entries(path, encoding: Encoding::UTF_8)
     .reject { |child| ignore?(child) }
     .collect { |child| down_level(child) }
end

#directory?Boolean

Returns:

  • (Boolean)


153
154
155
156
157
# File 'lib/puppet/file_serving/fileset.rb', line 153

def directory?
  Puppet::FileSystem.send(stat_method, path).directory?
rescue Errno::ENOENT, Errno::EACCES
  false
end

#down_level(to) ⇒ Object



130
131
132
# File 'lib/puppet/file_serving/fileset.rb', line 130

def down_level(to)
  FileSetEntry.new(depth + 1, File.join(path, to), ignored, stat_method)
end

#ignore?(child) ⇒ Boolean

Returns:

  • (Boolean)


146
147
148
149
150
151
# File 'lib/puppet/file_serving/fileset.rb', line 146

def ignore?(child)
  return true if child == "." || child == ".."
  return false if ignored == [nil]

  ignored.any? { |pattern| File.fnmatch?(pattern, child) }
end