module PathMapper
Constants
- VERSION
Public Class Methods
new(path, **kwargs)
click to toggle source
# File lib/path_mapper.rb, line 41 def self.new(path, **kwargs) path = Pathname(path) unless path.is_a? Pathname if File.exists? path if File.directory? path self.with_dry_run {|dry_run| self.storage_tree(path) if !self.storage.key?(path) and dry_run } return DirNode.new(path, **kwargs) elsif !File.read(path).strip.empty? self.with_dry_run {|dry_run| self.storage_file_tree(path) if !self.storage.key?(path) and dry_run } return FileNode.new(path, **kwargs) end end self.with_dry_run do |dry_run| if self.storage.key? path and !self.deleted_files.include? path if self.storage[path].nil? return DirNode.new(path, **kwargs) elsif !self.storage[path].strip.empty? return FileNode.new(path, **kwargs) end end if dry_run end NullNode.new(path, **kwargs) end