Class: Delfos::FileSystem::PathDetermination

Inherits:
Object
  • Object
show all
Defined in:
lib/delfos/file_system/path_determination.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ PathDetermination

Returns a new instance of PathDetermination.



9
10
11
# File 'lib/delfos/file_system/path_determination.rb', line 9

def initialize(file)
  @file = Pathname.new(strip_block_message(file))
end

Class Method Details

.for(*files) ⇒ Object



5
6
7
# File 'lib/delfos/file_system/path_determination.rb', line 5

def self.for(*files)
  files.map { |f| new(f).full_path }
end

Instance Method Details

#full_pathObject



13
14
15
16
17
18
19
20
21
22
23
# 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