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
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
#initialize(source_path) ⇒ Imaginary
Returns a new instance of Imaginary.
53 54 55 56 57 58 |
# File 'lib/epuber/compiler/file_finders/imaginary.rb', line 53 def initialize(source_path) super @root = DirEntry.new('/') make_dir_p(File.(source_path)) end |
Instance Attribute Details
#root ⇒ DirEntry (readonly)
51 52 53 |
# File 'lib/epuber/compiler/file_finders/imaginary.rb', line 51 def root @root end |
Instance Method Details
#__core_file?(path) ⇒ Boolean
96 97 98 99 100 101 102 103 104 105 |
# File 'lib/epuber/compiler/file_finders/imaginary.rb', line 96 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
87 88 89 90 91 92 93 94 |
# File 'lib/epuber/compiler/file_finders/imaginary.rb', line 87 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 do |item| item.absolute_path end end |
#add_file(file_path) ⇒ Object
78 79 80 81 82 83 84 |
# File 'lib/epuber/compiler/file_finders/imaginary.rb', line 78 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.
64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/epuber/compiler/file_finders/imaginary.rb', line 64 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 |