class Delfos::FileSystem::PathDetermination

Public Class Methods

for(*files) click to toggle source
# File lib/delfos/file_system/path_determination.rb, line 5
def self.for(*files)
  files.map { |f| new(f).full_path }
end
new(file) click to toggle source
# File lib/delfos/file_system/path_determination.rb, line 9
def initialize(file)
  @file = Pathname.new(strip_block_message(file))
end

Public Instance Methods

full_path() click to toggle source
# File lib/delfos/file_system/path_determination.rb, line 13
def full_path
  return @file.realpath if File.exist?(@file)

  Delfos.application_directories.map do |d|
    path = try_path { d + @file }

    path || try_path do
      Pathname.new(d + @file.to_s.gsub(%r{[^/]*/}, ""))
    end
  end.compact.first
end

Private Instance Methods

strip_block_message(f) click to toggle source
# File lib/delfos/file_system/path_determination.rb, line 27
def strip_block_message(f)
  f.to_s.split(" in block").first
end
try_path() { || ... } click to toggle source
# File lib/delfos/file_system/path_determination.rb, line 31
def try_path
  path = yield
  path if path.exist?
end