class Ruumba::Iterators::DirectoryIterator
Iterator which returns matching files from the given directory or file list
Attributes
files_or_dirs[R]
temp_dir[R]
Public Class Methods
new(files_or_dirs, temp_dir)
click to toggle source
# File lib/ruumba/iterators.rb, line 29 def initialize(files_or_dirs, temp_dir) @files_or_dirs = files_or_dirs @temp_dir = temp_dir end
Public Instance Methods
each(&block)
click to toggle source
# File lib/ruumba/iterators.rb, line 34 def each(&block) files.map do |file| [file, File.read(file)] end.each(&block) end
Private Instance Methods
expand_path(file_or_dir)
click to toggle source
# File lib/ruumba/iterators.rb, line 66 def expand_path(file_or_dir) Pathname.new(File.expand_path(file_or_dir)) end
files()
click to toggle source
# File lib/ruumba/iterators.rb, line 44 def files full_list.flat_map do |file_or_dir| if file_or_dir.file? file_or_dir if file_or_dir.to_s.end_with?('.erb') else Dir[File.join(file_or_dir, '**/*.erb')].map do |file| Pathname.new(file) unless file.start_with?(temp_dir) end end end.compact end
full_list()
click to toggle source
# File lib/ruumba/iterators.rb, line 56 def full_list if files_or_dirs.nil? || files_or_dirs.empty? [expand_path('.')] else files_or_dirs.map do |file_or_dir| expand_path(file_or_dir) end end end