module Actn::Paths

Public Class Methods

included(base) click to toggle source
# File lib/actn/paths.rb, line 10
def self.included base
  base.extend self
end

Public Instance Methods

root() click to toggle source
# File lib/actn/paths.rb, line 14
def root
  @@root ||= find_root_with_flag(PROCFILE, Dir.pwd).to_s
end

Private Instance Methods

find_root_with_flag(flag, default=nil) click to toggle source

i steal this from rails

# File lib/actn/paths.rb, line 21
def find_root_with_flag(flag, default=nil)
  root_path = self.called_from[0]

  while root_path && ::File.directory?(root_path) && !::File.exist?("#{root_path}/#{flag}")
    parent = ::File.dirname(root_path)
    root_path = parent != root_path && parent
  end

  root = ::File.exist?("#{root_path}/#{flag}") ? root_path : default
  raise "Could not find root path for #{self}" unless root

  RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ ?
  Pathname.new(root).expand_path : Pathname.new(root).realpath
end