Sha256: 4d3bc92817fe6d4a9396d95510db3d02f4b8f57b6ea722f75380026ff9406439
Contents?: true
Size: 1.15 KB
Versions: 1
Compression:
Stored size: 1.15 KB
Contents
module Munge class System module Readers # Enumerable list of {Munge::Item}s class Filesystem include Enumerable # @param source_path [String] def initialize(source_path) @source_path = source_path end # @yield [Item] # @return [Enumerator] def each return enum_for(:each) unless block_given? filepaths = Dir.glob(File.join(@source_path, "**", "*")) .select { |path| File.file?(path) } filepaths.each do |abspath| filehash = Hash[ relpath: compute_relpath(abspath), content: compute_content(abspath), stat: compute_stat(abspath) ] yield filehash end end private def compute_stat(abspath) File.stat(abspath) end def compute_relpath(abspath) folder = Pathname.new(@source_path) file = Pathname.new(abspath) file.relative_path_from(folder).to_s end def compute_content(abspath) File.read(abspath) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
munge-0.18.0 | lib/munge/system/readers/filesystem.rb |