Module: PWD

Extended by:
PWD
Included in:
PWD
Defined in:
lib/pwd.rb

Defined Under Namespace

Modules: CoreExt

Constant Summary collapse

VERSION =
File.read(File.join(File.dirname(__FILE__),'..','..','VERSION'))

Instance Method Summary collapse

Instance Method Details

#join(*path_parts) ⇒ Object



20
21
22
# File 'lib/pwd.rb', line 20

def join(*path_parts)
  File.join(pwd,*path_parts)
end

#pwdObject



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/pwd.rb', line 8

def pwd

  if rails_present?
    Rails.root.to_s
  elsif ENV['BUNDLE_GEMFILE']
    ENV['BUNDLE_GEMFILE'].split(File::Separator)[0..-2].join(File::Separator)
  else
    Dir.pwd.to_s
  end

end

#rails_present?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/pwd.rb', line 24

def rails_present?
  !!(defined?(Rails) && !Rails.root.nil?)
end