Class: Epuber::Compiler::FileFinders::Imaginary
- Defined in:
- lib/epuber/compiler/file_finders/imaginary.rb
Defined Under Namespace
Instance Attribute Summary collapse
- #root ⇒ DirEntry readonly
Attributes inherited from Abstract
#ignored_patterns, #source_path
Class Method Summary collapse
Instance Method Summary collapse
- #__core_file?(path) ⇒ Boolean
- #__core_find_files_from_pattern(pattern) ⇒ Object
- #add_file(file_path) ⇒ Object
-
#initialize(source_path) ⇒ Imaginary
constructor
A new instance of Imaginary.
-
#make_dir_p(path) ⇒ DirEntry
Dir entry for given path.
Methods inherited from Abstract
#assert_one_file, #find_all, #find_file, #find_files, group_filter_paths, relative_paths_from
Constructor Details
Instance Attribute Details
Class Method Details
.path_parts(path) ⇒ Object
111 112 113 |
# File 'lib/epuber/compiler/file_finders/imaginary.rb', line 111 def path_parts(path) path.split(File::SEPARATOR).reject(&:empty?) end |
Instance Method Details
#__core_file?(path) ⇒ Boolean
99 100 101 102 103 104 105 106 107 108 |
# File 'lib/epuber/compiler/file_finders/imaginary.rb', line 99 def __core_file?(path) components = self.class.path_parts(path) current = root components.each do |dir| current = current.respond_to?(:[]) ? current[dir] : nil end current.is_a?(FileEntry) end |
#__core_find_files_from_pattern(pattern) ⇒ Object
92 93 94 95 96 97 |
# File 'lib/epuber/compiler/file_finders/imaginary.rb', line 92 def __core_find_files_from_pattern(pattern) parts = self.class.path_parts(pattern) found_entries = find_recurser(root, parts).flatten file_entries = found_entries.reject { |entry| entry.is_a?(DirEntry) } file_entries.map(&:absolute_path) end |
#add_file(file_path) ⇒ Object
84 85 86 87 88 89 90 |
# File 'lib/epuber/compiler/file_finders/imaginary.rb', line 84 def add_file(file_path) file_path = File.(file_path, source_path) *path, file_name = self.class.path_parts(file_path) make_dir_p(path)[file_name] = FileEntry.new(file_name, file_path) end |
#make_dir_p(path) ⇒ DirEntry
Returns dir entry for given path.
70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/epuber/compiler/file_finders/imaginary.rb', line 70 def make_dir_p(path) components = path.is_a?(Array) ? path : self.class.path_parts(path) current = root components.each do |dir| entry = current[dir] current[dir] = entry = DirEntry.new(dir) if entry.nil? current = entry end current end |