Sha256: 57f93d4658c8280d2a9ae45d92b6e1ac8d43afac53608885d857ce64036896a0
Contents?: true
Size: 955 Bytes
Versions: 3
Compression:
Stored size: 955 Bytes
Contents
module Munge module Reader class Filesystem include Enumerable def initialize(source_path) @source_path = source_path end 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
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
munge-0.5.0 | lib/munge/readers/filesystem.rb |
munge-0.5.0.beta1 | lib/munge/readers/filesystem.rb |
munge-0.4.0 | lib/munge/readers/filesystem.rb |